Tuning parameters in a machine learning model play a critical role. Here, we are showing a grid search example on how to tune a random forest model:
# Random Forest Classifier - Grid Search >>> from sklearn.pipeline import Pipeline >>> from sklearn.model_selection import train_test_split,GridSearchCV >>> pipeline = Pipeline([ ('clf',RandomForestClassifier(criterion='gini',class_weight = {0:0.3,1:0.7}))])
Tuning parameters are similar to random forest parameters apart from verifying all the combinations using the pipeline function. The number of combinations to be evaluated will be (3 x 3 x 2 x 2) *5 =36*5 = 180 combinations. Here 5 is used in the end, due to the cross-validation of five-fold:
>>> parameters ...