Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created September 29, 2020 09:39
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 amankharwal/3666a3b3c3db3a950e7b70a1e5053ba3 to your computer and use it in GitHub Desktop.
Save amankharwal/3666a3b3c3db3a950e7b70a1e5053ba3 to your computer and use it in GitHub Desktop.
y_pred = np.array(clf.predict(x_test))
conf_mat = pd.DataFrame(confusion_matrix(y_test, y_pred),
columns=["Pred.Negative", "Pred.Positive"],
index=['Act.Negative', "Act.Positive"])
tn, fp, fn, tp = confusion_matrix(y_test, y_pred).ravel()
accuracy = round((tn+tp)/(tn+fp+fn+tp), 4)
print(conf_mat)
print(f'\n Accuracy = {round(100*accuracy, 2)}%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment