示例#1
0
def plotPRC(output, LTE, figure_fname = "", prc_label = 'PRC'):
    """Plots a precision recall curve into the supplied
    figure_fname file"""
    from matplotlib import use
    use("Agg")  # matplotlib save without display
    from pylab import figure, plot, axis, xticks, yticks, ylabel, xlabel, legend, savefig

    figure(2, dpi = 150, figsize = (4, 4))

    pm = PerformanceMeasures(Labels(numpy.array(LTE)), Labels(numpy.array(output)))

    points = pm.get_PRC()
    points = numpy.array(points).T # for pylab.plot
    plot(points[0], points[1], 'b-', label = prc_label)
    axis([0, 1, 0, 1])
    ticks = numpy.arange(0., 1., .1, dtype = numpy.float64)
    xticks(ticks, size = 10)
    yticks(ticks, size = 10)
    xlabel('sensitivity (true positive rate)', size = 10)
    ylabel('precision (1 - false discovery rate)', size = 10)
    legend(loc = 'lower right')
    
    if figure_fname != None:
        warnings.filterwarnings('ignore', 'Could not match*')
        tempfname = figure_fname + '.png'
    savefig(tempfname)
    shutil.move(tempfname, figure_fname)
    
    auPRC = pm.get_auPRC()
    return auPRC 
示例#2
0
def calcPRC(output, LTE):
    """Uses shogun functions to calculate the precision recall curve"""
    pm = PerformanceMeasures(Labels(numpy.array(LTE)), Labels(numpy.array(output)))

    auPRC = pm.get_auPRC()
    return auPRC