Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def predict_proba(self, X):
- if(self.voting_scheme == VotingClassifierDIY.SCHEME_COUNTING):
- raise AttributeError("This call is not supported for counting scheme mode!")
- predictions = []
- for i in range(len(self.clfs)):
- predictions.append(self.clfs[i].predict_proba(X))
- predictions = np.array(predictions)
- total = [np.average(predictions[:,i],axis=0) for i in range(X.shape[0])]
- return np.array(total)
- def predict(self, X):
- predictions = []
- if(self.voting_scheme == VotingClassifierDIY.SCHEME_COUNTING):
- for i in range(len(self.clfs)):
- predictions.append(self.clfs[i].predict(X))
- predictions = np.array(predictions)
- if(self.voting_scheme == VotingClassifierDIY.SCHEME_AVERAGING):
- predictions = self.predict_proba(X)
- total = []
- for i in range(X.shape[0]):
- if(self.voting_scheme == VotingClassifierDIY.SCHEME_AVERAGING):
- total.append(np.argmax(predictions[i]))
- else:
- total.append(np.argmax(np.bincount(predictions[:,i])))
- return np.array(total,dtype=int64)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement