Advertisement
sheiser1

My run_model function

Feb 10th, 2017
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def runModel(file_list, plot=False):
  2.   for file1 in file_list:
  3.     save = False
  4.     file_name = os.path.splitext(file1)[0]
  5.     path = '/home/sheiser1/nupic/examples/opf/clients/hotgym/anomaly/one_gym$' + file_name  
  6.     model = None
  7.     if os.path.exists(path):
  8.       model = Model.load(path)
  9.     else:
  10.       model = createModel(getModelParamsFromName(GYM_NAME))
  11.       save = True
  12.      
  13.     print "Creating model from %s..." % file_name
  14.     inputData = "%s/%s.csv" % (DATA_DIR, file_name.replace(" ", "_"))
  15.     runIoThroughNupic(inputData, model, file_name, plot)
  16.     if save:
  17.       model.save(path)
  18.  
  19.     for file2 in file_list:
  20.       file2_name = os.path.splitext(file2)[0]
  21.       model.disableLearning()    
  22.       print "Running model: " + file_name + ' on: ' + file2_name
  23.       inputData = "%s/%s.csv" % (DATA_DIR, file2_name.replace(" ", "_"))
  24.       runIoThroughNupic(inputData, model, file2_name, plot)
  25.       os.rename(file2_name + '_out.csv', file_name + '_' + file2_name + '_out.csv')
Advertisement
RAW Paste Data Copied
Advertisement