ensemble learning
ensemble learning
Ensemble learning
Key idea: Run a base learning algorithm multiple times, then
combine the predictions of the different learners to get a final
prediction.
Hard Voting:
In the setting of binary classification, hard voting is a simple way for
an ensemble of classifiers to make predictions, that is, to output the
majority winner between the two classes.
Soft Voting
If the classifiers in the ensemble have class probabilities, we may use soft voting to
aggregate.
Soft voting: the ensemble will predict the class with the highest class probability,
averaged over all the individual classifiers.
Often better than hard voting.
Random forest
It is part of the decision tree idea, where we first identify a random part of our data
(10% of which is) and build a tree.
Decisions of its own, then take another random part (another 10%)
and build another tree, and so on in the rest of the trees for the rest of the data . . .
And when we get information, we want to do a forecast, apply it to all the trees, and
get the average output of all the trees.
Bagging
boosting
Boosting is a learning method for ensemble models, where individual predictors are
trained sequentially, each trying to correct its predecessor. (AdaBoost)
57 #Calculating Prediction
58 y_pred = RandomForestClassifierModel.predict(X_test)
59 y_pred_prob = RandomForestClassifierModel.predict_proba(X_test)
60 print('Predicted Value for RandomForestClassifierModel is : ' , y_pred[:1
61 print('Prediction Probabilities Value for RandomForestClassifierModel is
62
63 #----------------------------------------------------
64 #Calculating Confusion Matrix
65 CM = confusion_matrix(y_test, y_pred)
66 print('Confusion Matrix is : \n', CM)
67
68 # drawing confusion matrix
69 sns.heatmap(CM, center = True)
70 plt.show()