def evaluation_prcevaluation_modular(ground_truth, predicted): from shogun.Features import Labels from shogun.Evaluation import PRCEvaluation ground_truth_labels = Labels(ground_truth) predicted_labels = Labels(predicted) evaluator = PRCEvaluation() evaluator.evaluate(predicted_labels,ground_truth_labels) return evaluator.get_PRC(), evaluator.get_auPRC()
def evaluation_prcevaluation_modular(ground_truth, predicted): from shogun.Features import BinaryLabels from shogun.Evaluation import PRCEvaluation ground_truth_labels = BinaryLabels(ground_truth) predicted_labels = BinaryLabels(predicted) evaluator = PRCEvaluation() evaluator.evaluate(predicted_labels, ground_truth_labels) return evaluator.get_PRC(), evaluator.get_auPRC()
## plot points subplot(211) plot(pos[0,:], pos[1,:], "r.") plot(neg[0,:], neg[1,:], "b.") grid(True) title('Data',size=10) # plot PRC for SVM subplot(223) PRC_evaluation=PRCEvaluation() PRC_evaluation.evaluate(svm.classify(),labels) PRC = PRC_evaluation.get_PRC() plot(PRC[:,0], PRC[:,1]) fill_between(PRC[:,0],PRC[:,1],0,alpha=0.1) text(0.55,mean(PRC[:,1])/3,'auPRC = %.5f' % PRC_evaluation.get_auPRC()) grid(True) xlabel('Precision') ylabel('Recall') title('LibSVM (Gaussian kernel, C=%.3f) PRC curve' % svm.get_C1(),size=10) # plot PRC for LDA subplot(224) PRC_evaluation.evaluate(lda.classify(),labels) PRC = PRC_evaluation.get_PRC() plot(PRC[:,0], PRC[:,1]) fill_between(PRC[:,0],PRC[:,1],0,alpha=0.1) text(0.55,mean(PRC[:,1])/3,'auPRC = %.5f' % PRC_evaluation.get_auPRC()) grid(True) xlabel('Precision') ylabel('Recall')