官术网_书友最值得收藏!

  • Ensemble Machine Learning Cookbook
  • Dipayan Sarkar Vijayalakshmi Natarajan
  • 255字
  • 2021-07-02 13:21:56

How it works...

VotingClassifier implements two types of voting—hard and soft voting. In hard voting, the final class label is predicted as the class label that has been predicted most frequently by the classification models. In other words, the predictions from all classifiers are aggregated to predict the class that gets the most votes. In simple terms, it takes the mode of the predicted class labels. 

In hard voting for the class labels,  is the prediction based on the majority voting of each classifier , where i=1.....n observations, we have the following:

As shown in the previous section, we have three models, one from the decision tree, one from the SVMs, and one from logistic regression. Let's say that the models classify a training observation as class 1, class 0, and class 1 respectively. Then with majority voting, we have the following:

In this case, we would classify the observation as class 1.

In the preceding section, in Step 1, we imported the required libraries to build our models. In Step 2, we created our feature set. We also split our data to create the training and testing samples. In Step 3, we trained three models with the decision tree, SVMs, and logistic regression respectively. In Step 4, we looked at the accuracy score of each of the base learners, while in Step 5, we ensembled the models using VotingClassifier() and looked at the accuracy score of the ensemble model.

主站蜘蛛池模板: 哈密市| 开远市| 新乡市| 义马市| 永靖县| 建昌县| 华容县| 沙坪坝区| 金沙县| 永清县| 庆安县| 莒南县| 宜黄县| 竹溪县| 呈贡县| 水城县| 华坪县| 左云县| 天津市| 皋兰县| 嘉义市| 冷水江市| 湘潭市| 彭水| 凤翔县| 内黄县| 余庆县| 大庆市| 宁强县| 平泉县| 大邑县| 安新县| 阳山县| 福贡县| 阜城县| 吉水县| 荃湾区| 宿州市| 海伦市| 高邮市| 郴州市|