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
6
votes
2 answers
How to fix the error "For multi-metric scoring" for OneClassSVM and GridSearchCV
I am trying to use OnClassSVM for anomaly detection purpose and I tuned its parameters using GridSearchCV() as follows:
I have searched many sites for it including https://stackoverflow.com/ but could not find any proper solution of my…

Mani
- 127
- 1
- 2
- 7
5
votes
0 answers
Hyperparameter Optimization with LGBMRanker
I'm using LGBMRanker for a ranking problem and want optimize the hyperparameters with GridSearchCV.
I have three splits of data (X,y):
X_1, X_2, X_3 , y_1, y_2, y_3
I also have the query group size for each split (three lists): gp_1, gp_2, gp_3
I'm…

Ellie
- 51
- 4
5
votes
1 answer
gridsearchcv with tfidf and count vectorizer
I want to use GridSearchCV for parameter tuning. Is it also possible to check with GridSearchCV whether CountVectorizer or TfidfVectorizer works best? My idea:
pipeline = Pipeline([
('vect', TfidfVectorizer()),
('clf',…

Abtc
- 77
- 1
- 4
5
votes
1 answer
Passing Target/Label data to Scikit-learn GridSearchCV's fit method for OneClassSVM
From my understanding, One-Class SVM's are trained without target/label data.
One answer at Use of OneClassSVM with GridSearchCV suggests passing Target/Label data to GridSearchCV's fit method when the classifier is the OneClassSVM.
How does the…

user3731622
- 4,844
- 8
- 45
- 84
5
votes
1 answer
TypeError: take(): argument 'index' (position 1) must be Tensor, not numpy.ndarray
I'm new to pytorch. I'm trying to do a cross validation, and I found the skorch library, which allow users to use sklearn functions with a torch model. So, I define a neural network class:
torch.manual_seed(42)
class Netcross(nn.Module):
def…

vanessa orani
- 71
- 1
- 1
- 5
5
votes
1 answer
sklearn.model_selection GridSearchCV is throwing KeyError: 'mean_train_score'
I am trying to fetch mean train score from classifierobject.cv_result_ from GridSearchCV method using 5 fold cross-validation but it's giving me *** KeyError: 'mean_train_score' in Google Colab. However, the same code is running fine in local…

Akash Singh
- 171
- 1
- 10
5
votes
2 answers
GridSearchCV progress in Jupiter Notebook
Is it possible to see the progress of GridSearchCV in a Jupyter Notebook? I'm running this script in python:
param_grid = {'learning_rate': [0.05, 0.10, 0.15, 0.20, 0.25, 0.30] ,
'max_depth' : [3, 4, 5, 6, 8, 10, 12, 15],
'min_child_weight' :…

Ralf Hundewadt
- 1,078
- 1
- 13
- 25
4
votes
1 answer
NameError: name 'GridSearchCV' is not defined. I have done the import though : from sklearn.model_selection import GridSearchCV
NameError Traceback (most recent call last)
C:\Users\VAISHN~1\AppData\Local\Temp/ipykernel_6520/2922578464.py in
3 'kernel': ['rbf']}
4
----> 5 optimal_params=GridSearchCV(
6 SVC(),
7 …

Vaishnavi
- 135
- 1
- 2
- 7
4
votes
1 answer
Difference between GridSearchCV and Cross_Val_Score
I have a binary time series classification problem.
Since it is a time series, I can't just train_test_split my data. So, I used the object tscv = TimeSeriesSplit() from this link, and got something like this:
I can see from GridSearchCV and…

Murilo
- 533
- 3
- 15
4
votes
2 answers
RandomizedSearchCV: All estimators failed to fit
I am currently working on the "French Motor Claims Datasets freMTPL2freq" Kaggle competition (https://www.kaggle.com/floser/french-motor-claims-datasets-fremtpl2freq). Unfortunately I get a "NotFittedError: All estimators failed to fit" error…

Django
- 69
- 1
- 6
4
votes
0 answers
NotFittedError: All estimators failed to fit while using CatBoostClassifier with GridSearchCV
I am trying to use GridSearchCV with CatBoostClassifier for multiclass (3), and am getting error. The code seems to work OK in this Kaggle notebook. The estimator also works successfully without GridSearchCV.
Here is the code and error:
model =…

mparikhdspython
- 41
- 1
4
votes
1 answer
GridSearchCV giving score from the best estimator different from the one indicated in refit parameter
I am doing hyperparameter optimization using GridSearchCV
scoring_functions = {'mcc': make_scorer(matthews_corrcoef), 'accuracy': make_scorer(accuracy_score), 'balanced_accuracy': make_scorer(balanced_accuracy_score)}
grid_search =…

Atirag
- 1,660
- 7
- 32
- 60
4
votes
1 answer
Memory error when I am trying to use Gridsearchcv
I am working on a customized estimator that should be passed in gridsearchcv function in sklearn. I have created the estimator now but run into a memory error. In the following code, you will see some constants like 'KxRange[0]' or arrays like…

Jasonyyyy
- 51
- 3
4
votes
1 answer
SKLEARN // Combine GridsearchCV with column transform and pipeline
I am struggling with a machine learning project, in which I am trying to combine :
a sklearn column transform to apply different transformers to my numerical and categorical features
a pipeline to apply my different transformers and estimators
a…

Xavier Fournat
- 63
- 1
- 4
4
votes
2 answers
How to use GridSearchCV for comparing multiple models along with pipeline and hyper-parameter tuning in python
I am using two estimators, Randomforest and SVM
random_forest_pipeline=Pipeline([
('vectorizer',CountVectorizer(stop_words='english')),
('random_forest',RandomForestClassifier())
])
svm_pipeline=Pipeline([
…

Lijin Durairaj
- 4,910
- 15
- 52
- 85