This tag is for questions on the process of running an exhaustive search over specified parameter values for an estimator using the class GridSearchCV from Python's scikit-learn library.
Questions tagged [gridsearchcv]
597 questions
-1
votes
1 answer
Identify the number of neighbors that resulted in the max score in the training/testing dataset
enter image description here
I am working on GridSearchKNN case study and am confused on how to "Identify the number of neighbors that resulted in the max score in the training/testing dataset." This is my first time working with KNN.
I Tried:
from…

Patricia Miranda
- 1
- 1
-1
votes
2 answers
Grid_search (RandomizedSearchCV) extremely slow with SVM (SVC)
I'm testing hyperparameters for an SVM, however, when I resort to Gridsearch or RandomizedSearchCV, I haven't been able to get a resolution, because the processing time is exceeding hours.
My dataset is relatively small: 4303 rows and 67 attributes,…

PM92
- 87
- 4
-1
votes
1 answer
How do you use GridSearchCV to search values for alpha in lasso and ridge regression models?
I'm doing an exercise on using sklearn Pipelines and GridSearchCV to find values for values for alpha in lasso and ridge regression models, where we also use SimpleImputer to take care of some missing values.
However, I keep getting the following…

Daniel Hardej
- 3
- 1
-1
votes
1 answer
Metric for ML algorithm evaluation
I have a question. Is the best score from GridSearchCV, which corresponds to mean cross-validation score, the right metric to evaluate an algorithm trained with unbalanced data?

alesechi
- 23
- 7
-1
votes
1 answer
How to find out precision, recall, specificity & F1 score of the best model which is selected in Grid Search in Python?
This is the Grid Selection step for my model. I am able to find out the best accuracy score and best parameters of that selected model but I want to find out precision, recall, specificity & F1 score of the best model which is selected in Grid…

Shritej Shirsath
- 9
- 3
-1
votes
1 answer
TypeError: __init__() got an unexpected keyword argument 'iid' while running GridSearchCV for time series data
I have a data Gemini_ETHUSD_d.csv which you can download from this link
I try to re-run the code below from this link:
from sklearn.model_selection import TimeSeriesSplit
from sklearn.model_selection import KFold
import numpy as np
import…

ah bon
- 9,293
- 12
- 65
- 148
-1
votes
1 answer
GridsearchCV doesn't check all splits
I have a complicated project which includes multioutput predictions and a custom scoring function (low is better).
I got a gap between the "mean-test-score" of the grid and the grade of my test set.
Turns out, the grid checks only the first split;…

Yosef Cohen
- 91
- 2
- 8
-1
votes
1 answer
ValueError: Invalid parameter C for estimator LogisticRegressionCV
Can't seem to perform a gridsearch on a logistic regression using an l1 penalty.
reg = LogisticRegressionCV(cv=5,random_state=42, solver='liblinear',penalty='l1')
grid = {'C': [0.001, 0.01, 0.05, 0.1, 1, 10, 100]}
grid_search = GridSearchCV(reg,…

Nick
- 39
- 5
-1
votes
1 answer
AttributeError: 'SVC' object has no attribute 'best_estimator_'
I'm trying to use GridSearchCV for SVM linear but I get this error:
AttributeError: 'SVC' object has no attribute 'best_estimator_'
the code of the SVM linear:
classifier = SVC()
classifier = GridSearchCV(classifier, {'C':[0.001, 0.01, 0.1, 1,…

Alhanoof
- 98
- 1
- 2
- 8
-1
votes
1 answer
What's the error when I used the GridSearchCV?
When I used GridSearhCV to find the best parameters setting for SVR, some errors happened.
The following is the code.
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVR
param_grid = [
{'kernel':["poly"], 'degree':[2, 3,…
-1
votes
1 answer
Is it required to do CV , if I use grid search cv?
I am using a grid search for hyper tuning my algorithm in ML. I have a doubt If I am using grid search cv is it mandatory to use cross-validation later?
Because grid search also does cross-validation, so I think doing grid search cv is enough. Am I…

krish
- 61
- 9
-1
votes
1 answer
Using cross-validation to determine weights of machine learning algorithms (GridSearchCv,RidgeCV,StackingClassifier)
My question has to do with GridSearchCV, RidgeCV, and StackingClassifier/Regressor.
Stacking Classifier/Regressor-AFAIK, it first trains the whole train set individually for each base estimator. Then, it uses a cross validation scheme, using the…

varun413
- 141
- 6
-1
votes
1 answer
GridSearchCV doesn't give best score on same dataset
I am trying to get the best score using GridSearchCV with the below code.
params = {'C':[15,20,25],'epsilon':[.003,.005,.008],'gamma':[.0001,.0003,.0006]}
svr = SVR()
grid=GridSearchCV(svr,param_grid=params)
grid.fit(X,train_labels)
gridCV =…
-1
votes
1 answer
Optimize hyper-parameters of a decision tree
I am trying to use to sklearn grid search to find the optimal parameters for the decision tree.
Dtree= DecisionTreeRegressor()
parameter_space = {'max_features': ['auto', 'sqrt', 'log2'],
'ccp_alpha':…

Simpson's Paradox
- 141
- 7
-1
votes
1 answer
Gridsearch CV give different best parameters when trained in different data
I am looking for the best way to tune a Randomforest Classifier and MLP Classifier in sklearn. The problem is that the Grisearch CV gives me slightly different best parameters each time I run my code. I assume that this happens because each time my…