Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import multiprocessing
  2.  
  3. ET = ExtraTreesClassifier(n_estimators=10, criterion='gini', max_features='auto', bootstrap=False) # .76
  4. RF = RandomForestClassifier(n_estimators=25, random_state=1)# .75
  5. GB = GradientBoostingClassifier() # .74
  6. ET = ExtraTreesClassifier(n_estimators=10, criterion='gini', max_features='auto', bootstrap=False) # .77 # without this lil fucker, Acc: 0.75 [Ensemble]
  7. clfList = [ET,RF,GB,ET]
  8.  
  9. def spawn(clf):
  10. clf.fit(x,y)
  11. print("Done another one!")
  12.  
  13. import time
  14. start = time.time()
  15.  
  16. if __name__ == '__main__':
  17.  
  18. for i in clfList:
  19. print(i)
  20. #spawn(i) # 16 secounds
  21.  
  22. # # 16 secounds
  23. # p = threading.Thread(target=spawn, args=(i,))
  24. # p.start()
  25. # p.join()
  26.  
  27. p=multiprocessing.Pool(6) # 15.65
  28. results = p.map(spawn,clfList) # clfList has 4 models, first 2 are fast, last 2 are slow
  29. results
  30.  
  31.  
  32. end = time.time()
  33. print(end - start)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement