Created
November 30, 2019 23:19
-
-
Save Mehdi-Amine/b4ce19f1735ae77bee296049fdb4a211 to your computer and use it in GitHub Desktop.
An ensemble classifier that relies on soft voting.
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
# Out of the three models, | |
# only SVC requires some tweaking to output its confidence | |
# this is done by setting probability=True: | |
svm_clf_tweaked = SVC(gamma='scale', probability=True, random_state=42) | |
soft_voting_clf = VotingClassifier(estimators=[('svm', svm_clf_tweaked), ('tree', tree_clf), ('log', log_clf)], | |
voting='soft') | |
soft_voting_clf.fit(X_train, y_train) # training | |
y_pred_voting = soft_voting_clf.predict(X_test) # predicting | |
accuracy_score(y_test, y_pred_voting) # evaluating | |
# Output of the evaluation: 0.912 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment