MACHINE LEARNING | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

MACHINE LEARNING

Grid Search Look at the following code for running a grid search. param_grid = { 'max_depth': [5, 15, 25, 35], 'max_leaf_nodes': [10, 20, 35, 50, 75]} dt = DecisionTreeClassifier() gs = GridSearchCV(dt, param_grid, scoring='f1', cv=5) gs.fit(X, y) How many different models are being compared?

25th Nov 2022, 11:20 AM
ARITRA ROY
2 Answers
+ 1
Review Lesson 34 that explains about grid search. When in doubt, you can also look at the sklearn documentation. https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html The point of grid search, is to try running the same model with different parameters, because we intuitively may not guess correctly, which parameter value results in the best predicting power. So the parameters are passed in param_grid. This is a dictionary data structure, where the values contain a list of each possible argument. The total number of models come from the combination of all these values (Cartesian product). So practically you just multiply the sizes of the param_grid values.
26th Nov 2022, 6:07 AM
Tibor Santa
Tibor Santa - avatar
0
20
5th Apr 2023, 9:27 AM
Swaraj Farande
Swaraj Farande - avatar