In machine learning, grid search refers to multiple runs to find the optimal value of parameter(s)/hyperparameter(s) of a model, e.g. mtry for random-forest or alpha, beta, lambda for glm, or C, kernel and gamma for SVM.
Questions tagged [grid-search]
865 questions
5
votes
1 answer
How would you do RandomizedSearchCV with VotingClassifier for Sklearn?
I'm trying to tune my voting classifier. I wanted to use randomized search in Sklearn. However how could you set parameter lists for my voting classifier since I currently use two algorithms (different tree algorithms)?
Do I have to separately run…

user3368526
- 2,168
- 10
- 37
- 52
5
votes
2 answers
Python sklearn : fit_transform() does not work for GridSearchCV
I am creating a GridSearchCV classifier as
pipeline = Pipeline([
('vect', TfidfVectorizer(stop_words='english',sublinear_tf=True)),
('clf', LogisticRegression())
])
parameters= {}
gridSearchClassifier = GridSearchCV(pipeline,…

AbtPst
- 7,778
- 17
- 91
- 172
5
votes
1 answer
scikit-learn pipeline: grid search over parameters of transformer to generate data
I would like to use the first step of a scikit-learn pipeline to generate a toy data set in order to evaluate the performance of my analysis. An as-simple-as-it-gets-example solution I came up with looks like the following:
import numpy as np
from…

Milla Well
- 3,193
- 3
- 35
- 50
5
votes
1 answer
Custom 'Precision at k' scoring object in sklearn for GridSearchCV
I am currently trying to tune hyperparameters using GridSearchCV in scikit-learn using a 'Precision at k' scoring metric which will give me precision if I classify the top kth percentile of my classifier's score as the positive class. I know it is…

user3821273
- 151
- 1
- 3
- 9
5
votes
1 answer
error in GridsearchCV sklearn
I am trying to tune a GB Classifier in sklearn using GridsearchCV. Here is the code:
from sklearn.grid_search import GridSearchCV
from sklearn.ensemble import GradientBoostingClassifier
param_grid = {'learning_rate': [0.1, 0.01, 0.001],
…

Nitin
- 2,624
- 7
- 29
- 43
4
votes
4 answers
Activation parameter not working in GridSearch
I am trying to make a GridSearch for best parameters, like this:
def MultiPerceptron(optimizer = 'adam', loss = 'binary_cross_entropy', kernel_initializer = 'random_uniform', activation = 'relu', units = 16):
model = Sequential()
…

Murilo
- 533
- 3
- 15
4
votes
1 answer
OSError: [Errno 9] Bad file descriptor using GridSearchCV
I'm having little hard times figure out what's the problem with my code.
I'm a newbie in the fabulous world of python, so forgive me for any kind of syntax problem.
Thanks to anyone who's gonna spend his time to help me.
Here's my…

wrong_tactic
- 41
- 1
4
votes
1 answer
Preprocessing on GridsearchCV
I'm using GridsearchCV for tuning hyperparameters and now I want to do a min-max Normalization(StandardScaler()) in training and validating step.But I think I cannot do this.
The question is :
If I apply preprocess step on whole training set and…

Puntawat Ponglertnapakorn
- 83
- 1
- 8
4
votes
1 answer
Hyperparameter Tuning in Random forest
I was trying Random Forest Algorithm on Boston dataset to predict the house prices medv with the help of sklearn's RandomForestRegressor.In all I tried 3 iterations as below
Iteration 1: Using the model with default hyperparameters
#1. import the…

Rookie_123
- 1,975
- 3
- 15
- 33
4
votes
2 answers
Which model: Best estimator from gridsearchCV or all training data?
I am a little confused when it comes to gridsearch and fitting the final model. I split the in 2: training and testing. The testing set is only used for final evaluation. I perform grid search only using the training data.
Say one has done a grid…

KJA
- 313
- 3
- 14
4
votes
1 answer
Grid search with LightGBM regression
I want to train a regression model using Light GBM, and the following code works fine:
import lightgbm as lgb
d_train = lgb.Dataset(X_train, label=y_train)
params = {}
params['learning_rate'] = 0.1
params['boosting_type'] =…

Helen
- 533
- 12
- 37
4
votes
1 answer
Finding top features with SGD classifier & GridsearchCV
# Implementing Linear_SGD classifier
clf = linear_model.SGDClassifier(max_iter=1000)
Cs = [0.0001,0.001, 0.01, 0.1, 1, 10]
tuned_parameters = [{'alpha': Cs}]
model = GridSearchCV(clf, tuned_parameters, scoring = 'accuracy', cv=2)
model.fit(x_train,…

ravi
- 93
- 2
- 12
4
votes
2 answers
H2OResponseError in Grid Search Get Grid Sorting
When I run:
data_h = h2o.H2OFrame(data)
### Edit: added asfactor() below to change integer target array.
data_h["BPA"] = data_h["BPA"].asfactor()
train, valid = data_h.split_frame(ratios=[.7], seed = 1234)
features = ["bq_packaging_consumepkg",…

Roy Z
- 67
- 1
- 5
4
votes
1 answer
LightGBM- Classification metrics can't handle a mix of binary and continuous targets
I am facing a trouble when I use lightgbm to conduct grid search.
lgb_classifer = lgb.LGBMRegressor(random_state=12)
grid_lgb = {
'learning_rate': [0.01,0.05],
'num_iterations': [5,10,20]}
gbm_lgb = GridSearchCV(estimator…

Rya
- 329
- 2
- 15
4
votes
1 answer
GridSearchCV, representation of each class in each part of the dataframe
I have to do a multiclass classification (3). I search the best parameter for my classifier with GridSearchCV.
But I have a imbalanced x_train (and x_test) : 3079 intances for 0, 12 for 1 and 121 for 3.
I have this error:
Target is multiclass but…

Ahammad
- 41
- 1
- 2