Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.47 KB | None | 0 0
  1. def TMrunModel(train_list, test_list, plot=False):
  2.  
  3.   for file1 in train_list: #train_list #was --> file_list
  4.     subj_str = file1.split('_')[0]
  5.     subj_test_list = [f for f in test_files if f.split('_')[0] == subj_str]
  6.     save = False
  7.     file_name = os.path.splitext(file1)[0]
  8.     #path = '/home/sheiser1/Desktop/zaychik_proj1-master/Dr_Zaychik_Data/selectedData/newData/ready$' + file_name
  9.     #path = '/home/nupic/examples/opf/clients/hotgym/anomaly/one_gym$' + file_name  
  10.     path = '/home/sheiser1/nupic-master/examples/opf/clients/hotgym/anomaly/one_gym/MCYT_100/models$' + file_name
  11.  
  12.     model = None
  13.     if os.path.exists(path):
  14.       model = Model.load(path)
  15.     else:
  16.       model = createModel(getModelParamsFromName(GYM_NAME))
  17.       save = True
  18.      
  19.     print ("Creating model from %s..." % file_name)
  20.     inputData = "%s/%s.csv" % (train_path, file_name.replace(" ", "_"))    
  21.    
  22.     runIoThroughNupic(inputData, model, file_name, plot)
  23.     #print 'Ran ' + file1 + ' thru Nupic'    
  24.    
  25.     if save:
  26.       model.save(path)
  27.  
  28.     for file2 in subj_test_list: #was --> file_list    
  29.       file2_name = os.path.splitext(file2)[0]
  30.       model.disableLearning()    
  31.       #print ("Running model: " + file_name + ' on: ' + file2_name)
  32.       inputData = "%s/%s.csv" % (test_path, file2_name.replace(" ", "_"))
  33.       runIoThroughNupic(inputData, model, file2_name, plot)
  34.       os.rename(file2_name + '_out.csv', file_name + '_' + file2_name + '_out.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement