Skip to content

Instantly share code, notes, and snippets.

@mohcinemadkour
Forked from terrah27/lr_gridsearch.py
Created August 12, 2019 13:57
Show Gist options
  • Save mohcinemadkour/72f8ecd5afa364ec3cc9db106545533d to your computer and use it in GitHub Desktop.
Save mohcinemadkour/72f8ecd5afa364ec3cc9db106545533d to your computer and use it in GitHub Desktop.
penalty = ['l1', 'l2']
C = [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]
class_weight = [{1:0.5, 0:0.5}, {1:0.4, 0:0.6}, {1:0.6, 0:0.4}, {1:0.7, 0:0.3}]
solver = ['liblinear', 'saga']
param_grid = dict(penalty=penalty,
C=C,
class_weight=class_weight,
solver=solver)
grid = GridSearchCV(estimator=logistic,
param_grid=param_grid,
scoring='roc_auc',
verbose=1,
n_jobs=-1)
grid_result = grid.fit(X_train, y_train)
print('Best Score: ', grid_result.best_score_)
print('Best Params: ', grid_result.best_params_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment