def _evaluate_pos_tagger(): words, real_tags = _get_data() tagger = POSTagger() _w, pred_tags = _split_tagged_words(tagger.tag(words)) for i in range(100): print(words[i], real_tags[i], pred_tags[i]) return accuracy(real_tags, pred_tags)
def test_bool_66(): y_true = [True, False, True] y_pred = [True, False, False] assert accuracy(y_true, y_pred) == 0.6667
def test_str(): y_true = ['a', 'b', 'c'] y_pred = ['d', 'b', 'a'] assert accuracy(y_true, y_pred) == 0.3333
def test_list(): y_true = [['a', 'b'], ['c']] y_pred = [['a', 'b'], ['d']] assert accuracy(y_true, y_pred) == 0.5
def test_bool_100(): y_true = [True, False, True] y_pred = [True, False, True] assert accuracy(y_true, y_pred) == 1.0
def test_float(): y_true = [10.4, 4.7, 3.0, 5.02] y_pred = [10.40, 4.74, 3, 5.02] assert accuracy(y_true, y_pred) == 0.75
def test_int(): y_true = [10, 4, 3, 5] y_pred = [3, 4, 7, 5] assert accuracy(y_true, y_pred) == 0.5
def _evaluate_classifier(name): x_train, y_train, x_test, y_test = _get_data() classifier = name() classifier.train(x_train, y_train) y_pred = classifier.classify(x_test) return accuracy(y_test, y_pred)
def evaluate_classifier(y_true, y_prediction): print('* Accuracy: {:.2%}'.format(accuracy(y_true, y_prediction)))