Ejemplo n.º 1
0
def test_platt_correction():
    F=numpy.ones(10)
    L=numpy.ones(10)
    F[:5] *= -1
    L[:5] *= 0
    A,B=learn_sigmoid_constants(F,L)
    assert 1./(1.+numpy.exp(+10*A+B)) > .99
    assert 1./(1.+numpy.exp(-10*A+B)) <.01
Ejemplo n.º 2
0
def test_platt_correction():
    F = numpy.ones(10)
    L = numpy.ones(10)
    F[:5] *= -1
    L[:5] *= 0
    A, B = learn_sigmoid_constants(F, L)
    assert 1. / (1. + numpy.exp(+10 * A + B)) > .99
    assert 1. / (1. + numpy.exp(-10 * A + B)) < .01
Ejemplo n.º 3
0
def test_learn_sigmoid_contants():
    Y = np.repeat((0,1),100)
    np.random.seed(3)
    for i in xrange(10):
        F = np.random.rand(200)-.3
        F[100:] *= -1
        old = old_learn_sigmoid_constants(F,Y)
        new = svm.learn_sigmoid_constants(F,Y)
        assert np.allclose(old, new)
Ejemplo n.º 4
0
def test_learn_sigmoid_contants():
    Y = np.repeat((0, 1), 100)
    np.random.seed(3)
    for i in xrange(10):
        F = np.random.rand(200) - .3
        F[100:] *= -1
        old = old_learn_sigmoid_constants(F, Y)
        new = svm.learn_sigmoid_constants(F, Y)
        assert np.allclose(old, new)
Ejemplo n.º 5
0
def test_platt_correction_class():
    F=numpy.ones(10)
    L=numpy.ones(10)
    F[:5] *= -1
    L[:5] *= 0
    corrector = svm_sigmoidal_correction()
    A,B = learn_sigmoid_constants(F,L)
    model = corrector.train(F,L)
    assert model.A == A
    assert model.B == B
    assert model.apply(10) > .99
    assert model.apply(-10) < .01
Ejemplo n.º 6
0
def test_platt_correction_class():
    F = numpy.ones(10)
    L = numpy.ones(10)
    F[:5] *= -1
    L[:5] *= 0
    corrector = svm_sigmoidal_correction()
    A, B = learn_sigmoid_constants(F, L)
    model = corrector.train(F, L)
    assert model.A == A
    assert model.B == B
    assert model.apply(10) > .99
    assert model.apply(-10) < .01