Commit 61438b13 authored by 张彦钊's avatar 张彦钊

fix bug

parent 0b3210d9
...@@ -16,28 +16,25 @@ def get_roc_curve(label,pred): ...@@ -16,28 +16,25 @@ def get_roc_curve(label,pred):
""" """
计算二分类问题的roc和auc 计算二分类问题的roc和auc
""" """
try:
test_label = pd.read_table(label)
pred_label = pd.read_table(pred)
y = test_label.values
p = pred_label.values
fpr, tpr, thresholds = metrics.roc_curve(y, p) test_label = pd.read_table(label)
pred_label = pd.read_table(pred)
y = test_label.values
p = pred_label.values
fpr, tpr, thresholds = metrics.roc_curve(y, p)
# plt.plot(fpr,tpr,marker = 'o') # plt.plot(fpr,tpr,marker = 'o')
# plt.xlabel('False positive rate') # plt.xlabel('False positive rate')
# plt.ylabel('True positive rate') # plt.ylabel('True positive rate')
# plt.title("roc_curev") # plt.title("roc_curev")
AUC = auc(fpr, tpr) AUC = auc(fpr, tpr)
AUC = "auc={}".format(AUC) AUC = "auc={}".format(AUC)
# plt.text(0.5,0.8,AUC,color='blue',ha='center') # plt.text(0.5,0.8,AUC,color='blue',ha='center')
# # plt.savefig(output) # # plt.savefig(output)
print(AUC) print(AUC)
except:
print("the format of the file must be the n*1")
print("the test_label must be 0 or 1")
print("the test_pred must be at [0,1]")
# #
# if __name__ == "__main__": # if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment