7.7 非均衡分类问题

2023-07-21 08:08:2818:25 409
声音简介




def plotROC(predStrengths, classLabels):  

    import matplotlib.pyplot as plt  

    cur = (1.0,1.0#cursor  

    ySum = 0.0 #variable to calculate AUC  

    numPosClas = sum(array(classLabels)==1.0)  

    yStep = 1/float(numPosClas); xStep = 1/float(len(classLabels)-numPosClas)  

    sortedIndicies = predStrengths.argsort()#get sorted index, it's reverse  

    fig = plt.figure()         #这三行代码用于构建画笔  

    fig.clf()  

    ax = plt.subplot(111)  

    #loop through all the values, drawing a line segment at each point  

    for index in sortedIndicies.tolist()[0]:  

        if classLabels[index] == 1.0:  

            delX = 0; delY = yStep;  

        else:  

            delX = xStep; delY = 0;  

            ySum += cur[1]  

        #draw line from cur to (cur[0]-delX,cur[1]-delY)  

        ax.plot([cur[0],cur[0]-delX],[cur[1],cur[1]-delY], c='b')  

        cur = (cur[0]-delX,cur[1]-delY)  

    ax.plot([0,1],[0,1],'b--')  

    plt.xlabel('False positive rate'); plt.ylabel('True positive rate')  

    plt.title('ROC curve for AdaBoost horse colic detection system')  

    ax.axis([0,1,0,1])  

    plt.show()  

    print "the Area Under the Curve is: ",ySum*xStep 

用户评论

表情0/300
喵,没有找到相关结果~
暂时没有评论,下载喜马拉雅与主播互动
猜你喜欢
纳什均衡与博弈论

纳什博弈论及对自然法则的研究

by:哈默林吹笛人

均衡饮食与科学控糖

节目内容:用通俗的语言,从实用的角度,为大家分享科学控糖知识,帮助大家解决营养均衡摄入的难题主播介绍:刘欣老师,15年资深营养师,长期从事三高症人群的健康管理,...

by:刘欣专注私人健康管理

懒的分类

没有简介就是最好的简介!

by:芭拉美小屋

分类作文

嗯这本书是作文的对孩子成长帮助给人孩子更加写作文儿本书是哈尔滨出版社能让孩子在阅读中轻松提升写作能力的作文范本李志锋主编

by:凉寒_四月

未分类

个人品味,愿者欣赏。

by:听友13002286