figure - model performance metrics for random forest for wine quality predictive model the model prediction results on the test dataset depict an overall score and model accuracy of approximately %as seen in figure - this is definitely an improvement of from what we obtained with just decision trees proving that ensemble learning is working better another way to further improve on this result is model tuning to be more specificmodels have hyperparameters that can be tunedas we have discussed previously in detail in the "model tuning and hyperparameter tuningsections in hyperparameters are also known as meta-parameters and are usually set before we start the model training process these hyperparameters do not have any dependency on being derived from the underlying data on which the model is trained usually these hyperparameters represent some high level concepts or knobswhich can be used to tweak and tune the model during training to improve its performance our random forest model has several hyperparameters and you can view its default values as follows in [ ]print(wqp_rf get_params(){'bootstrap'true'random_state'none'verbose' 'min_samples_leaf' 'min_weight_ fraction_leaf' 'max_depth'none'class_weight'none'max_leaf_nodes'none'oob_score'false'criterion''gini''n_estimators' 'max_features''auto''min_ impurity_split' - 'n_jobs' 'warm_start'false'min_samples_split' from the preceding outputyou can see number of hyperparameters we recommend checking out the official documentation at randomforestclassifier html to learn more about each parameter for hyperparameter tuningwe will keep things simple and focus our attention on n_estimators which represents the total number of base tree models in the forest ensemble model and max_features which represents the number of features to consider during each best split we use standard grid search method with five-fold cross validation to select the best hyperparameters in [ ]from sklearn model_selection import gridsearchcv param_grid 'n_estimators'[ ]'max_features'['auto'none'log 'wqp_clf gridsearchcv(randomforestclassifier(random_state= )param_gridcv= scoring='accuracy'wqp_clf fit(wqp_train_sxwqp_train_yprint(wqp_clf best_params_{'max_features''auto''n_estimators' we can see the chosen value of the hyperparameters obtained after the grid search in the preceding output we have estimators and auto maximum features which represents the square root of the total number of features to be considered during the best split operations the scoring parameter was set to