logistic regression hyperparameter tuning
from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import classification_report from sklearn.model_selection import GridSearchCV import numpy as np X_train, X_test, y_train, y_test = train_test_split(df, y, test_size=0.25, random_state=42) scaler = MinMaxScaler() X_train = scaler.fit_transform(X_train) X_test = scaler.transform(X_test) model = LogisticRegression(max_iter=4000) param_grid = {'penalty' : ['l1','l2'], 'C': np.logspace(-3,3,7),'solver' : ['liblinear','elasticnet']} gridsearchcv = GridSearchCV(model, param_grid, cv = 3, verbose=True, n_jobs=-1) best_parameters = gridsearchcv.fit(X_train, y_train) best_parameters