From 7435a2409d56840817e3e0b3f0ce7fc3c0f1430a Mon Sep 17 00:00:00 2001 From: wassname Date: Wed, 14 Oct 2020 07:04:27 +0800 Subject: [PATCH] classification_report --- deep_ml_curriculum/classification_report.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 deep_ml_curriculum/classification_report.py diff --git a/deep_ml_curriculum/classification_report.py b/deep_ml_curriculum/classification_report.py new file mode 100644 index 0000000..aec0898 --- /dev/null +++ b/deep_ml_curriculum/classification_report.py @@ -0,0 +1,12 @@ +import pandas as pd +import sklearn.metrics +import numpy as np + +def pd_classification_report(*args, **kwargs): + out_df = pd.DataFrame(sklearn.metrics.classification_report(*args, **kwargs, output_dict=True)).T + # Order cols + out_df[["precision","recall","f1-score","support"]] + # Round + out_df[["precision","recall","f1-score"]]= out_df[["precision","recall","f1-score"]].apply(lambda x: round(x,2)) + out_df[["support"]]= out_df[["support"]].apply(lambda x: x.astype(np.int)) + return out_df