Question: Random Forest Model: Build a Random Forest model. Tune hyperparameters such as max _ depth, min _ samples _ split, n _ estimators, and min

Random Forest Model:
Build a Random Forest model.
Tune hyperparameters such as max_depth, min_samples_split,
n_estimators, and min_samples_leaf using Grid Search.
3. K-Nearest Neighbors Model:
Build a K-Nearest Neighbors (KNN) model.
Tune hyperparameters such as n_neighbors, weights, and p (dis-
tance metric) using Grid Search.
Which metric, accuracy or F1-score, would you use to run the Grid-
SearchCV?
Select the metric (accuracy or F1-score) that you believe best suits
your use case.
Below are the grids for GridSearchCV:
param_grid_dt ={
'max_depth': [3,5,10, None],
'min_samples_split': [2,10,20],
'min_samples_leaf': [1,5,10]
}
param_grid_rf ={
'n_estimators': [50,100,200],
'max_depth': [None,10,20],
'min_samples_split': [2,10],
'min_samples_leaf': [1,5]
}
param_grid_knn ={
'n_neighbors': [3,5,7,9],
'weights': ['uniform', 'distance'],
'p': [1,2]
}
Decision Tree (DT) Grid:
max_depth: Controls the maximum depth of the tree. Options: 3,
5,10, or no limit (None).
2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!