penalty = ['l1', 'l2']
C = np.logspace(0, 4, 10)

grid_model = GridSearchCV(log_model, param_grid={'C':C, 'penalty':penalty})

grid_model.fit(scaled_X_train, y_train)

I was getting the error in the last line.

I was expecting it to fit the training data but got an error. Is it due to something which happened while creating the categorical column from a numeric one?

1

There are 1 best solutions below

0
TheHungryCub On

Ensure that there are no missing values (None or NaN) in your training data (scaled_X_train and y_train).

You can use the following to check for missing values:

import numpy as np

# Check for missing values in scaled_X_train
print(np.any(np.isnan(scaled_X_train)))

# Check for missing values in y_train
print(np.any(np.isnan(y_train)))

If you find missing values, handle them appropriately, either by imputing or removing them.

Additionally, make sure your categorical column conversion is done correctly and that all features are in a compatible format for logistic regression.