Esempio n. 1
0
def plot_precision_recall(predicted, event, against="true", max_angle=1.0e-2):
    _, precision, recall = precision_recall(predicted, event, against, max_angle)

    plt.figure()
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.05])
    plt.plot(recall, precision)
    plt.xlabel("Recall")
    plt.ylabel("Precision")

    return plt
Esempio n. 2
0
def plot_precision_recall(predicted, event, against='true', max_angle=1.0e-2):
    _, precision, recall = precision_recall(predicted, event, against,
                                            max_angle)

    plt.figure()
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.05])
    plt.plot(recall, precision)
    plt.xlabel("Recall")
    plt.ylabel("Precision")

    return plt
Esempio n. 3
0
def test():
    # test run using degree-3 polynomial kernel with C=1
    # for the ten main topics in reuters
    dm = data.create_data_manager()

    print 'loading train data . . .'
    X_train, Y_train = dm.load_data('train')
    Y_train_slice = dm.slice_Y(Y_train, topics)

    print 'training svm . . .'
    K = len(topics)
    learner = svm2.MultiSVM(K, 1.0, 'poly', 3)
    learner.train(X_train, Y_train_slice)

    print 'loading test data . . .'
    X_test, Y_test = dm.load_data('test')
    Y_gold = dm.slice_Y(Y_test, topics)

    print 'predicting train . . .'
    Y_pred = learner.batch_predict_classes(X_train)
    
    print 'evaluating . . .'
    precision, recall = evaluate.precision_recall(Y_pred, Y_train_slice)
    f1 = evaluate.f_score(precision, recall)

    print 'Precision: %.3f' % precision
    print 'Recall: %.3f' % recall
    print 'F1: %.3f' % f1

    print 'predicting test . . .'
    Y_pred = learner.batch_predict_classes(X_test)
    
    print 'evaluating . . .'
    precision, recall = evaluate.precision_recall(Y_pred, Y_gold)
    f1 = evaluate.f_score(precision, recall)

    print 'Precision: %.3f' % precision
    print 'Recall: %.3f' % recall
    print 'F1: %.3f' % f1