different hyperparameters running same gridsearch code

Viewed 21

im a newbey in matter of python and datascience and i was trying to do a gridsearch for a classifier tree and each time i run the code the best_estimator_ change even in some cases i dont have some of the hyperparameters chosen, i set a random_state for the folds so i dont know why keeps changing. How can i fix it so it only show me one best_estimator every time without changes. Here is an example

ftwo_scorer = make_scorer(fbeta_score, beta=1)
tree_params = {'max_depth': list(range(1,4)),'min_samples_leaf': list(range(1,20)),'criterion': ["gini", "entropy"]}
tree=GridSearchCV(estimator=DecisionTreeClassifier(),param_grid=tree_params,cv=folds,n_jobs=-1,verbose=1,scoring=ftwo_scorer, refit= True)
tree.fit(X_train,y_train)
tree.best_estimator_

it returns DecisionTreeClassifier(max_depth=3) Thanks!

0 Answers
Related