思路:建立表格通过pandas的操作对数据进行整理

主要是提取出安预测大小排序的真实类型
然后通过假设筛选 设什么概率为判断为正例(如 预测为正例的概率为0.39为正,那概率小于他的就会为反例)这样我就可以得到预测的样本
def precision_score(y_true, y_predict):
FP = np.sum((y_true == 1) & (y_predict ==0 )) # FN
TP = np.sum((y_true == 0) & (y_predict ==0)) # TP
return TP / (TP + FP)
def recall_score(y_true, y_predict):
FN = np.sum((y_true == 0) & (y_predict == 1))#FN
TP = np.sum((y_true == 0) & (y_predict == 0))#TP
return TP/(TP+FN)
def TPR(y_true, y_predict):
FN = np.sum((y_true == 0) & (y_predict == 1))#FN
TP = np.sum((y_true == 0) & (y_predict ==0)) # TP
return TP / (TP + FN)
def FPR(y_true, y_predict):
TN = np.sum((y_true == 1) & (y_predict == 1))#TN
FP = np.sum((y_true == 1) & (y_predict == 0))#FP
return FP/(FP+TN)
难得写了
