# How to select the best parameters for GridSearchCV?

I've created a couple of models during some assignments and hackathons using algorithms such as Random Forest and XGBoost and used GridSearchCV to find the best combination of parameters. But what I'm not able to understand is how to select those parameters for GridSearchCV. I randomly put the parameters such as

params = {"max_depth" : [5, 7, 10, 15, 20, 25, 30, 40, 50,100],
"min_samples_leaf" : [5, 10, 15, 20, 40, 50, 100, 200, 500, 1000,10000],
"criterion": ["gini","entropy"],
"n_estimators" : [10, 15, 20, 40, 50, 75, 100,1000],
"max_features" : ["auto", "sqrt","log2"]}


But how do I decide if I could select better parameters which might be computationally better as well? I can't use the same above parameters for a Random Forest Classifier every single time surely?

• When using GridSearch I always try that my param range includes the default ones. For example for RandomForestClassifier the default value for n_estimators = 100 so I always go for a range that includes 100 say [75,100,150]. You could also run a validation curve on the most relevant numeric parameter to check whether increasing or decreasing helps your model scikit-learn.org/stable/modules/learning_curve.html – Julio Jesus Mar 1 at 19:32