# -*- coding: utf-8 -*-
import math
import sklearn
import numpy as np
import matplotlib.pyplot as plt
import skimage
import caffe
import sklearn.metrics.pairwise as pw
#读取标签文件
def read_labels(labelfile):
fin=open(labelfile)
lines=fin.readlines()
labels=np.empty((len(lines),))
k=0;
for line
in lines:
labels[k]=int(line)
k=k+1;
fin.close()
return
labels
def read_Feautures(labelfile):
fin=open(labelfile)
lines=fin.readlines()
labels=np.empty((len(lines),))
k=0;
for line
in lines:
labels[k]=float(line)
k=k+1;
fin.close()
return
labels
#画ROC曲线图
def draw_roc_curve(fpr1,tpr1,fpr2,tpr2,
title='cosine',save_name='roc_lfw'):
plt.figure()
plt.plot(fpr1, tpr1,'r')
plt.plot(fpr2, tpr2,'g')
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])
plt.xlabel('FPR')
plt.ylabel('TPR')
plt.title('ROC(Receiver operating characteristic)using:
'+title)
plt.legend(loc="lower right")
plt.show()
plt.savefig(save_name+'.png')
if __name__=='__main__':
labels =
read_labels(u"e:/xxx/tlf-1.txt")
predicts
= read_Feautures(u"e:/xxx/tlf-2.txt")
fpr1,
tpr1, threshold1s=sklearn.metrics.roc_curve(labels,predicts)
threshold1s
#draw_roc_curve(fpr1,tpr1,title='JSS',save_name='lfw_evaluate')
labels =
read_labels(u"e:/xxx/alf-1.txt")
predicts
= read_Feautures(u"e:/xxx/alf-2.txt")
fpr2,
tpr2, threshold2s=sklearn.metrics.roc_curve(labels,predicts)
threshold2s
draw_roc_curve(fpr1,tpr1,fpr2,tpr2,title='AS',save_name='lfw_evaluate')
生成的图表