Created
December 29, 2018 20:10
-
-
Save rohanjoseph93/698da261394b9c8c35f48a5c0707640d to your computer and use it in GitHub Desktop.
This file contains 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
#Grid Search | |
from sklearn.model_selection import GridSearchCV | |
clf = LogisticRegression() | |
grid_values = {'penalty': ['l1', 'l2'],'C':[0.001,.009,0.01,.09,1,5,10,25]} | |
grid_clf_acc = GridSearchCV(clf, param_grid = grid_values,scoring = 'recall') | |
grid_clf_acc.fit(X_train, y_train) | |
#Predict values based on new parameters | |
y_pred_acc = grid_clf_acc.predict(X_test) | |
# New Model Evaluation metrics | |
print('Accuracy Score : ' + str(accuracy_score(y_test,y_pred_acc))) | |
print('Precision Score : ' + str(precision_score(y_test,y_pred_acc))) | |
print('Recall Score : ' + str(recall_score(y_test,y_pred_acc))) | |
print('F1 Score : ' + str(f1_score(y_test,y_pred_acc))) | |
#Logistic Regression (Grid Search) Confusion matrix | |
confusion_matrix(y_test,y_pred_acc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment