zoukankan      html  css  js  c++  java
  • sklearn 评估指标auc和(归一化)基尼系数

    auc的解释:

    https://blog.csdn.net/u013385925/article/details/80385873

    Gini和AUC的关系(Gini=2AUC-1真的成立吗?):

    https://blog.csdn.net/dongweionly/article/details/83573878

    gini原版测试代码(较长):

    https://blog.csdn.net/u010665216/article/details/78528261 

    sklearn 和 多分类上的auc例子:

    注意,auc是计算曲线下的面积,曲线自己来定义。roc_auc_score 是专门计算roc曲线的面积。

    https://www.pianshen.com/article/517880764/

    import numpy as np
    
    def gini(actual, pred):
        assert (len(actual) == len(pred))
        all = np.asarray(np.c_[actual, pred, np.arange(len(actual))], dtype=np.float)
        all = all[np.lexsort((all[:, 2], -1 * all[:, 1]))]
        totalLosses = all[:, 0].sum()
        giniSum = all[:, 0].cumsum().sum() / totalLosses
    
        giniSum -= (len(actual) + 1) / 2.
        return giniSum / len(actual)
    
    def gini_norm(actual, pred):
        return gini(actual, pred) / gini(actual, actual)
    
    predictions = [0.9, 0.3, 0.8, 0.75, 0.65, 0.6, 0.78, 0.7, 0.05, 0.4, 0.4, 0.05, 0.5, 0.1, 0.1]
    actual = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    k = gini_norm(actual, predictions)
    k
  • 相关阅读:
    ftp命令行敲不了
    转载 vsftpd安装
    ftp上传不了故障
    mysql导入数据方法和报错解决
    time使用方法
    python 进程Queue
    python 进程事件
    python 进程信号量
    python 进程锁
    python 守护进程
  • 原文地址:https://www.cnblogs.com/qiezi-online/p/14139682.html
Copyright © 2011-2022 走看看