示例#1
0
def precision_at_percentages(test_labels, test_predictions, title='Precision at various percentages'):
    '''
        Plots precision for various percent values
    '''
    percents = [0.01 * i for i in range(1, 101)]
    precs_and_cutoffs = [precision_at(test_labels, test_predictions, percent=p) for p in percents]
    precs, cutoffs = zip(*precs_and_cutoffs)
    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    ax.plot(percents, precs)
    ax.set_title(title)
    ax.set_ylabel('Precision')
    ax.set_xlabel('Percentage')
    return fig
示例#2
0
def precision_at_proportions(y_true, y_score, ax=None, **kwargs):
    '''
        Plots precision for various proportions
    '''
    #If not Axes object is passed use the current one in pyplot
    if ax is None:
        ax = plt.gca()

    #Calculate points
    proportions = [0.01 * i for i in range(1, 101)]
    precs_and_cutoffs = [precision_at(y_true, y_score, proportion=p) for p in proportions]
    precs, cutoffs = zip(*precs_and_cutoffs)

    #Plot and set nice defaults for title and axis labels
    ax.plot(proportions, precs, **kwargs)
    ax.set_title('Precision at various proportions')
    ax.set_ylabel('Precision')
    ax.set_xlabel('Proportion')
    return ax
示例#3
0
def precision_at_proportions(test_labels, test_predictions, ax=None, **kwargs):
    '''
        Plots precision for proportions between 0.1 and 1.0
    '''
    #If not Axes object is passed use the current one in pyplot
    if ax is None:
        ax = plt.gca()

    #Calculate points
    percents = [0.01 * i for i in range(1, 101)]
    precs_and_cutoffs = [precision_at(test_labels, test_predictions, percent=p) for p in percents]
    precs, cutoffs = zip(*precs_and_cutoffs)

    #Plot and set nice defaults for title and axis labels
    ax.plot(percents, precs, **kwargs)
    ax.set_title('Precision at various proportions')
    ax.set_ylabel('Precision')
    ax.set_xlabel('Proportion')
    return ax
示例#4
0
def precision_at_proportions(test_labels, test_predictions, ax=None, **kwargs):
    '''
        Plots precision for proportions between 0.1 and 1.0
    '''
    #If not Axes object is passed use the current one in pyplot
    if ax is None:
        ax = plt.gca()

    #Calculate points
    percents = [0.01 * i for i in range(1, 101)]
    precs_and_cutoffs = [
        precision_at(test_labels, test_predictions, percent=p)
        for p in percents
    ]
    precs, cutoffs = zip(*precs_and_cutoffs)

    #Plot and set nice defaults for title and axis labels
    ax.plot(percents, precs, **kwargs)
    ax.set_title('Precision at various proportions')
    ax.set_ylabel('Precision')
    ax.set_xlabel('Proportion')
    return ax