Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. def predict_proba(self, X):
  2. if(self.voting_scheme == VotingClassifierDIY.SCHEME_COUNTING):
  3. raise AttributeError("This call is not supported for counting scheme mode!")
  4. predictions = []
  5. for i in range(len(self.clfs)):
  6. predictions.append(self.clfs[i].predict_proba(X))
  7.  
  8. predictions = np.array(predictions)
  9. total = [np.average(predictions[:,i],axis=0) for i in range(X.shape[0])]
  10.  
  11. return np.array(total)
  12.  
  13. def predict(self, X):
  14. predictions = []
  15.  
  16. if(self.voting_scheme == VotingClassifierDIY.SCHEME_COUNTING):
  17. for i in range(len(self.clfs)):
  18. predictions.append(self.clfs[i].predict(X))
  19.  
  20. predictions = np.array(predictions)
  21.  
  22. if(self.voting_scheme == VotingClassifierDIY.SCHEME_AVERAGING):
  23. predictions = self.predict_proba(X)
  24. total = []
  25. for i in range(X.shape[0]):
  26. if(self.voting_scheme == VotingClassifierDIY.SCHEME_AVERAGING):
  27. total.append(np.argmax(predictions[i]))
  28. else:
  29. total.append(np.argmax(np.bincount(predictions[:,i])))
  30. return np.array(total,dtype=int64)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement