Advertisement
Guest User

basic model

a guest
Dec 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from sklearn.ensemble import RandomForestClassifier
  2.  
  3. #assume data is already loaded as xtrain, ytrain and xdev, ydev
  4.  
  5.  
  6. clf = RandomForestClassifier()
  7. clf.fit(xtrain,ytrain)
  8. closed_out = clf.predict(xtrain)
  9. open_out = clf.predict(xdev)
  10.  
  11. #calculate error -- note: he actually has a script for this and you should use his style but this will work while you're just figuring shit out
  12.  
  13.  
  14. #closed loop
  15. num_wrong = 0.
  16.  
  17. for i in xrange(len(ytrain)):
  18.     if closed_out[i]!=ytrain[i]:
  19.         num_wrong+=1.
  20.  
  21. print("open loop error: " + str(num_wrong/len(ytrain)))
  22.  
  23.  
  24. #open loop
  25. num_wrong = 0.
  26.  
  27. for i in xrange(len(ydev)):
  28.     if open_out[i]!=ydev[i]:
  29.         num_wrong+=1.
  30.  
  31. print("open loop error: " + str(num_wrong/len(ydev)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement