grid-search

Can I get F1 score each time from GridSearchCV?

Can I get F1 score each time from GridSearchCV? Question: I want to show F1 score from gridsearch each loop of change parameter. I use f1_micro in the GridSearchCV like this. params = { ‘max_depth’: [None, 2, 4, 6, 8, 10], ‘max_features’: [None, ‘sqrt’, ‘log2’, 0.2, 0.4, 0.6, 0.8], } clf = GridSearchCV( estimator=DecisionTreeClassifier(), param_grid=params, …

Total answers: 1

Return pipeline score as one of multiple evaluation metrics

Return pipeline score as one of multiple evaluation metrics Question: I am using a pipeline in a hyperparameter gridsearch in sklearn. I would like the search to return multiple evaluation scores – one a custom scoring function that I wrote, and the other the default score function of the pipeline. I tried using the parameter …

Total answers: 1

Hurdle models – gridsearchCV

Hurdle models – gridsearchCV Question: I am currently trying to build a hurdle model – zero inflated regressor to predict the revenue from each of out customers. We use zero inflated regressor because most (80%) of our customers have 0 as revenue and only 20% have revenue > 0. So, we build two models like …

Total answers: 1

Error while doing SVR for multiple outputs

Error while doing SVR for multiple outputs Question: Trying to do SVR for multiple outputs. Started by hyper-parameter tuning which worked for me. Now I want to create the model using the optimum parameters but I am getting an error. How to fix this? from sklearn.svm import SVR from sklearn.model_selection import GridSearchCV from sklearn.multioutput import …

Total answers: 1

Retrieve Model Results for Shapley values from GridSearch CV

Retrieve Model Results for Shapley values from GridSearch CV Question: I have tuned a model using GridSearchCV. Now I would like to calculate the Shapley values and visualize them. The difficulty is that the shap package excepts a model, not the GridSearch Results. Likewise it does not like when I pass it the best_estimator_ attribute. …

Total answers: 1

"OverflowError: Python int too large to convert to C long" when running a RandomizedSearchCV with scipy distributions

"OverflowError: Python int too large to convert to C long" when running a RandomizedSearchCV with scipy distributions Question: I want to run the following RandomizedSearch: from scipy.stats import reciprocal, uniform tree_reg = DecisionTreeRegressor() param_grid = { "max_depth": np.arange(1, 12, 1), "min_samples_leaf": np.arange(2, 2259, 10), "min_samples_split": np.arange(2, 2259, 2), "max_leaf_nodes": np.arange(2, 2259, 2), "max_features": np.arange(2, len(features)) …

Total answers: 2

How can I plot validation curves using the results from GridSearchCV?

How can I plot validation curves using the results from GridSearchCV? Question: I am training a model with GridSearchCV in order to find the best parameters Code: grid_params = { ‘n_estimators’: [100, 200, 300, 400], ‘criterion’: [‘gini’, ‘entropy’], ‘max_features’: [‘auto’, ‘sqrt’, ‘log2’] } gs = GridSearchCV( RandomForestClassifier(), grid_params, cv=2, verbose=1, n_jobs=-1 ) clf = gs.fit(X_train, …

Total answers: 2

AttributeError: 'GridSearchCV' object has no attribute 'best_params_'

AttributeError: 'GridSearchCV' object has no attribute 'best_params_' Question: Grid search is a way to find the best parameters for any model out of the combinations we specify. I have formed a grid search on my model in the below manner and wish to find best parameters identified using this gridsearch. from sklearn.model_selection import GridSearchCV # …

Total answers: 2

More than one estimator in GridSearchCV(sklearn)

More than one estimator in GridSearchCV(sklearn) Question: I was checking sklearn documentation webpage about GridSearchCV. One of attributes of GridSearchCV object is best_estimator_. So here is my question. How to pass more than one estimator to GSCV object? Using a dictionary like: {‘SVC()’:{‘C’:10, ‘gamma’:0.01}, ‘ DecTreeClass()’:{….}}? Asked By: mikinoqwert || Source Answers: GridSearchCV works on …

Total answers: 1

Using Smote with Gridsearchcv in Scikit-learn

Using Smote with Gridsearchcv in Scikit-learn Question: I’m dealing with an imbalanced dataset and want to do a grid search to tune my model’s parameters using scikit’s gridsearchcv. To oversample the data, I want to use SMOTE, and I know I can include that as a stage of a pipeline and pass it to gridsearchcv. …

Total answers: 1