Last active
November 30, 2019 04:36
-
-
Save Mehdi-Amine/923e682e2fda336a06c48c829a86a89b to your computer and use it in GitHub Desktop.
Creating, training, predicting, and evaluating an ensemble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Combining the three models into an ensemble | |
from sklearn.ensemble import VotingClassifier | |
# The ensemble is a voting classifier that aggregates our three models | |
voting_clf = VotingClassifier(estimators=[('svm', svm_clf), ('tree', tree_clf), ('log', log_clf)], | |
voting='hard') | |
voting_clf.fit(X_train, y_train) # training | |
y_pred_voting = voting_clf.predict(X_test) # predicting | |
accuracy_score(y_test, y_pred_voting) # evaluating | |
# Output of the evaluation: 0.904 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment