Skip to content

Instantly share code, notes, and snippets.

@PratyushTripathy
Last active September 3, 2019 11:16
Show Gist options
  • Save PratyushTripathy/3080f80deb8f9a7da371c8734533d69a to your computer and use it in GitHub Desktop.
Save PratyushTripathy/3080f80deb8f9a7da371c8734533d69a to your computer and use it in GitHub Desktop.
from sklearn.metrics import confusion_matrix, precision_score, recall_score
# Predict for test data
yTestPredicted = model.predict(xTest)
yTestPredicted = yTestPredicted[:,1]
# Calculate and display the error metrics
yTestPredicted = (yTestPredicted>0.5).astype(int)
cMatrix = confusion_matrix(yTest, yTestPredicted)
pScore = precision_score(yTest, yTestPredicted)
rScore = recall_score(yTest, yTestPredicted)
print("Confusion matrix: for 14 nodes\n", cMatrix)
print("\nP-Score: %.3f, R-Score: %.3f" % (pScore, rScore))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment