def test_perc_d4_1():
    global x_tr, y_tr

    # public 
    labels = set(y_tr)
    theta_perc = hand_weights.theta_hand_original.copy()

    update = perceptron.perceptron_update(x_tr[110],y_tr[110],theta_perc,labels)
    eq_(len(update),0)

    update = perceptron.perceptron_update(x_tr[20],y_tr[20],theta_perc,labels)
    eq_(len(update),146)
    eq_(update[('science','and')],2)
    eq_(update[('iama','200')],-1)
Exemple #2
0
def test_perc_d4_1():
    global x_tr, y_tr

    # public 
    labels = set(y_tr)
    theta_perc = hand_weights.theta_hand_original.copy()

    update = perceptron.perceptron_update(x_tr[110],y_tr[110],theta_perc,labels)
    eq_(len(update),0)

    update = perceptron.perceptron_update(x_tr[20],y_tr[20],theta_perc,labels)
    eq_(len(update),146)
    eq_(update[('science','and')],2)
    eq_(update[('iama','200')],-1)
def test_d4_1_perc_update():
    global x_tr_pruned, y_tr

    labels = set(y_tr)

    theta_perc = Counter()
    update = perceptron.perceptron_update(x_tr_pruned[20],y_tr[20],theta_perc,labels)
    eq_(len(update),0)

    update = perceptron.perceptron_update(x_tr_pruned[110],y_tr[110],theta_perc,labels)
    eq_(len(update),122)
    eq_(update[('2000s','with')],1)
    eq_(update[('1980s','shes')],-2)
    eq_(update[('2000s',constants.OFFSET)],1)
    eq_(update[('1980s',constants.OFFSET)],-1)