Created
May 19, 2019 20:13
-
-
Save netsatsawat/eaefe24300453a93b5937358327ea69c to your computer and use it in GitHub Desktop.
Tune hyperparameters using grid search CV on logit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cv_params = {'C': [0.001, 0.01, 0.1, 1., 10., 100.], | |
'penalty': ['l1', 'l2'], | |
'class_weight': [None, 'balanced'] | |
} | |
fix_params = {'random_state': SEED} | |
log_cv_1 = GridSearchCV(LogisticRegression(**fix_params), cv_params, scoring='f1', cv=5) | |
log_cv_1.fit(X_train, y_train) | |
log_clf_all = LogisticRegression(**{**fix_params, **log_cv_1.best_params_}) | |
_ = myUtilityFunction.prediction_evaluation(log_clf_all, X_train, X_test, y_train, y_test, | |
X_train.columns, "coefficients") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment