Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created August 21, 2019 15:52
Show Gist options
  • Save dipanjanS/3e33e69399b6a984d7f4f719de4b2f44 to your computer and use it in GitHub Desktop.
Save dipanjanS/3e33e69399b6a984d7f4f719de4b2f44 to your computer and use it in GitHub Desktop.
import pandas as pd
from sklearn.metrics import classification_report, confusion_matrix
def evaluate_model_results(model, test_data, test_labels,
class_label_mapping, class_labels):
predictions = model.predict(test_data, verbose=1)
prediction_labels = [class_label_mapping[idx] for idx in predictions.argmax(axis=1)]
print(classification_report(y_true=test_labels, y_pred=prediction_labels))
return pd.DataFrame(confusion_matrix(y_true=test_labels, y_pred=prediction_labels, labels=class_labels),
index=class_labels, columns=class_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment