Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mypath = '/home/sheiser1/Desktop/zaychik_proj1-master/Dr_Zaychik_Data/selectedData/newData/1D_Data/ready' #'/home/sheiser1/Desktop/zaychik_proj1-master/Dr_Zaychik_Data/selectedData/newData/ready'
- only_csv_files = [f for f in listdir(mypath) if isfile(join(mypath, f)) and os.path.splitext(f)[1] == '.csv']
- train_files = [f for f in only_csv_files if f[-5] == 'n']
- test_files = [f for f in only_csv_files if f[-5] == 't']
- def runModel(file_list, train_list, test_list, plot=False):
- for file1 in train_list: #train_list #was --> file_list
- save = False
- file_name = os.path.splitext(file1)[0]
- ## MAYBE CHANGE PATH?
- #path = '/home/sheiser1/Desktop/zaychik_proj1-master/Dr_Zaychik_Data/selectedData/newData/ready$' + file_name
- path = '/home/sheiser1/nupic/examples/opf/clients/hotgym/anomaly/one_gym$' + file_name
- model = None
- if os.path.exists(path):
- model = Model.load(path)
- else:
- model = createModel(getModelParamsFromName(GYM_NAME))
- save = True
- print ("Creating model from %s..." % file_name)
- inputData = "%s/%s.csv" % (DATA_DIR, file_name.replace(" ", "_"))
- runIoThroughNupic(inputData, model, file_name, plot)
- if save:
- model.save(path)
- for file2 in test_list: #was --> file_list
- file2_name = os.path.splitext(file2)[0]
- model.disableLearning()
- print ("Running model: " + file_name + ' on: ' + file2_name)
- inputData = "%s/%s.csv" % (DATA_DIR, file2_name.replace(" ", "_"))
- runIoThroughNupic(inputData, model, file2_name, plot)
- os.rename(file2_name + '_out.csv', file_name + '_' + file2_name + '_out.csv')
- if __name__ == "__main__":
- print (DESCRIPTION)
- plot = False
- new_model = False
- args = sys.argv[1:]
- if "--plot" in args:
- plot = True
- runModel(only_csv_files,train_files,test_files,plot=plot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement