score_dataset.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:snape 作者: mbernico 项目源码 文件源码
def score_binary_classification(y, y_hat, report=True):
    """
    Create binary classification output
    :param y: true value
    :param y_hat: class 1 probabilities
    :param report:
    :return:
    """
    y_hat_class = [1 if x >= 0.5 else 0 for x in y_hat]  # convert probability to class for classification report

    report_string = "---Binary Classification Score--- \n"
    report_string += classification_report(y, y_hat_class)
    score = roc_auc_score(y, y_hat)
    report_string += "\nAUC = " + str(score)

    if report:
        print(report_string)

    return score, report_string
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号