- Decision Tree Modelling Introduction
- Decision Tree Python Algorithm
- Decision Tree Workflow
- Decision Tree 4 Rows
- Decision Tree – Only Six Rows
- Decision Trees and Random Forests
A random forest is a collection of decision trees whose results are aggregated into one final result. Their ability to limit overfitting without substantially increasing error due to bias is why they are such powerful models.
- Instantiate the random forest classifier rf and set the random state.
- Create a dictionary cv_params of any of the following hyperparameters and their corresponding values to tune. The more you tune, the better your model will fit the data, but the longer it will take.
- max_depth
- max_features
- max_samples
- min_samples_leaf
- min_samples_split
- n_estimators
- Define a set scoring of scoring metrics for GridSearch to capture (precision, recall, F1 score, and accuracy).
- Instantiate the GridSearchCV object rf1. Pass to it as arguments:
- estimator=rf
- param_grid=cv_params
- scoring=scoring
- cv: define the number of you cross-validation folds you want (cv=_)
- refit: indicate which evaluation metric you want to use to select the model (refit=_)
Here is an article at Medium called Decision Trees and Random Forests.