gor.py 文件源码

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

项目:PyProt 作者: StanIsAdmin 项目源码 文件源码
def plotROC(self):
        for classifier in self.structures:
            x, y = [], []
            for threshold in np.arange(self.minScore, self.maxScore, 0.1):
                tp, tn, fp, fn = 0, 0, 0, 0
                for realS in self.structures:
                    for score in self.scores[(classifier, realS)]:
                        if score >= threshold:  # Positive
                            if classifier == realS:  # True
                                tp += 1
                            else:  # False
                                fp += 1
                        else:  # Negative
                            if classifier != realS:  # True
                                tn += 1
                            else:  # False
                                fn += 1
                tpr = tp / (tp + fn)
                fpr = fp / (tn + fp)
                x.append(fpr)
                y.append(tpr)
            print("----- Receiver Operating Characteristic Curve -----")
            print("Classifier:", classifier)
            x.sort()
            y.sort()
            auc = np.trapz(y, x)  # Area Under Curve
            print("AUC:", auc)
            pyplot.title("Classifier " + classifier)
            pyplot.xlabel('False Positive Rate')
            pyplot.ylabel('True Positive Rate')
            pyplot.plot([0, 1], [0, 1])
            pyplot.plot(x, y)
            pyplot.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号