- Mastering Predictive Analytics with scikit:learn and TensorFlow
- Alan Fontaine
- 267字
- 2021-07-23 16:42:26
Boosting model
Boosting is also an ensemble learning model. Here, we are using the AdaBoostRegressor model, and we will again produce 50 estimators. The following screenshot shows the algorithm used for this model:
The following screenshot shows the train_mse and test_mse results that we get after training all these models:
The following screenshot shows the algorithm and gives the comparison of all of these models on the basis of the values of the test mean squared error. The result is shown with the help of a horizontal bar graph:
Now, when we compare the result of all of these models, we can see that the random forest model is the most successful. The bagging and KNN models come second and third, respectively. This is why we use the KNN model with the bagging model.
The following screenshot shows the algorithm used to produce a graphical representation between the predicted prices and the observed prices while testing the dataset, and also shows the performance of the random forest model:
On using this model again with a predict API or with a predict method, we can get individual predictions.
For example, let's predict the values for the first ten predictions that we get from the testing dataset. The following algorithm shows the prediction that is made by this random forest model, which in turns shows us the real price and the predicted price of the diamonds that we have from the testing dataset:
From this screenshot, we can see that the values for Real price and Predicted price are very close, both for the expensive and inexpensive diamonds.