Created
June 2, 2022 16:20
-
-
Save slitayem/d60d688d65b4d50448d87c68e6820b27 to your computer and use it in GitHub Desktop.
Get the sklearn classification report as a DataFrame object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import metrics | |
def get_classification_as_df(y_test: list, y_pred: list, sort_by: list =[])-> pd.DataFrame: | |
''' Get the classification report as a DataFrame''' | |
report = metrics.classification_report(y_test, y_pred, output_dict=True) | |
df_classification_report = pd.DataFrame(report).transpose() | |
df_classification_report = df_classification_report.sort_values( | |
by=sort_by, ascending=False) | |
return df_classification_report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment