Skip to content

Instantly share code, notes, and snippets.

@Kamaldeep0077
Last active October 1, 2020 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kamaldeep0077/ec6d72173a47a6b8c65430fd656a0ac6 to your computer and use it in GitHub Desktop.
Save Kamaldeep0077/ec6d72173a47a6b8c65430fd656a0ac6 to your computer and use it in GitHub Desktop.
#importing and training the model
from sklearn.linear_model import LogisticRegression
lr = LogisticRegression(solver='newton-cg', class_weight='balanced')
lr.fit(x_train, y_train)
# Predicting on the test data
pred_test = lr.predict(x_test)
#Calculating and printing the f1 score
f1_test = f1_score(y_test, pred_test)
print('The f1 score for the testing data:', f1_test)
#Ploting the confusion matrix
conf_matrix(y_test, pred_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment