Skip to content

Instantly share code, notes, and snippets.

@supachaic
Created September 9, 2017 05:15
Show Gist options
  • Save supachaic/03eac455456b154c444a15edb1ded7e2 to your computer and use it in GitHub Desktop.
Save supachaic/03eac455456b154c444a15edb1ded7e2 to your computer and use it in GitHub Desktop.
ensemble vote
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import ExtraTreesClassifier, VotingClassifier
from xgboost import XGBClassifier
rfo = RandomForestClassifier()
ada = AdaBoostClassifier()
ext = ExtraTreesClassifier()
xgb = XGBClassifier()
vote_list = [('rfo', rfo), ('ada', ada), ('ext', ext), ('xgb', xgb)]
vote = VotingClassifier(estimators=vote_list, voting='soft')
vote.fit(X_train, y_train)
score = vote.score(X_train, y_train)
y_pred = vote.predict(X_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment