Пример #1
0
def test_training(pairwise):
    '''Tests that training does something.'''
    from numpy.testing import assert_approx_equal

    content_objs, labels = interesting_training_data()
    indiced = mod_pairwise.labels_to_indexed_coref_values(content_objs, labels)
    names, model, vec = pairwise.train(content_objs, indiced)

    assert names == vec.get_feature_names()
    assert_approx_equal(model.coef_[0][0], 0.61903921)
    assert model.classes_.tolist() == [-1, 1]
Пример #2
0
def test_training(pairwise):
    '''Tests that training does something.'''
    from numpy.testing import assert_approx_equal

    content_objs, labels = interesting_training_data()
    indiced = mod_pairwise.labels_to_indexed_coref_values(content_objs, labels)
    names, model, vec = pairwise.train(content_objs, indiced)

    assert names == vec.get_feature_names()
    assert_approx_equal(model.coef_[0][0], 0.61903921)
    assert model.classes_.tolist() == [-1, 1]
Пример #3
0
def test_label_indexing():
    '''Make sure labels get converted to indices correctly.'''
    content_objs = [
        ('a', counter_fc({})),
        ('b', counter_fc({})),
        ('c', counter_fc({})),
    ]
    labels = [
        pos_label('a', 'c'),
        pos_label('c', 'b'),
        neg_label('b', 'a'),
    ]
    indiced = mod_pairwise.labels_to_indexed_coref_values(content_objs, labels)
    assert indiced == [
        # ({-1, 1}, index1, index2)
        (1, 0, 2),
        (1, 1, 2),
        (-1, 0, 1),
    ]
Пример #4
0
def test_label_indexing():
    '''Make sure labels get converted to indices correctly.'''
    content_objs = [
        ('a', counter_fc({})),
        ('b', counter_fc({})),
        ('c', counter_fc({})),
    ]
    labels = [
        pos_label('a', 'c'),
        pos_label('c', 'b'),
        neg_label('b', 'a'),
    ]
    indiced = mod_pairwise.labels_to_indexed_coref_values(content_objs, labels)
    assert indiced == [
        # ({-1, 1}, index1, index2)
        (1, 0, 2),
        (1, 1, 2),
        (-1, 0, 1),
    ]