-1

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, param_grid=grid)

grid_search.fit(X_train, y_train)

grid_search.cv_results_['mean_test_score']
Nick
  • 39
  • 5

1 Answers1

1

LogisticRegressionCV() does cross-validation by itself

Try this code:

reg = LogisticRegressionCV(Cs=[0.001, 0.01, 0.05, 0.1, 1, 10, 100],cv=5,random_state=42, solver='liblinear',penalty='l1')

Best regards.

Patricio Loncomilla
  • 1,048
  • 3
  • 11