연구 노트/R Python

def get_clf_eval() 함수 코드

airmaster 2022. 1. 17. 16:21
728x90
from sklearn.metrics import accuracy_score, precision_score, recall_score, confusion_matrix, f1_score, roc_auc_score
from sklearn.metrics import roc_curve
def get_clf_eval(y_test, pred=None, pred_proba=None):
    confusion = confusion_matrix(y_test, pred)
    accuracy= accuracy_socre(y_test, pred)
    precision = precision_score(y_test, pred)
    recall = recall_score(y_test, pred)
    f1 = f1_score(y_test, pred)
    roc_auc = roc_auc_score(y_test, pred_proba)
    print('error matrix')
    print(confusion)
    print('Accu : {0:.4f}, Prec : {1:.4f}, Recu : {2:.4f},\
             F1 : {3:.4f},  AUC : {4:.4f}'.format(accuracy, precision, recall, f1, roc_auc))
728x90