示例#1
0
def test_pyss3_functions():
    """Test pyss3 functions."""
    assert pyss3.sigmoid(1, 0) == 0
    assert pyss3.sigmoid(1, 1) == .5
    assert pyss3.sigmoid(.2, .2) == .5
    assert pyss3.sigmoid(.5, .5) == .5
    assert round(pyss3.sigmoid(0, .5), 5) == .00247
    assert round(pyss3.sigmoid(1, .5), 5) == .99753
    assert round(pyss3.sigmoid(1, 2), 5) == .04743

    assert pyss3.mad([1, 1, 1], 3) == (1, .0)
    assert pyss3.mad([1, 1, 1], 3) == (1, .0)
    assert pyss3.mad([], 1) == (0, .0)
    assert round(pyss3.mad([1, 2, 1], 3)[1], 5) == .33333
    assert round(pyss3.mad([1, 10, 1], 3)[1], 5) == 3.0

    with pytest.raises(IndexError):
        pyss3.mad([], 0)
示例#2
0
def test_pyss3_functions():
    """Test pyss3 functions."""
    assert pyss3.sigmoid(1, 0) == 0
    assert pyss3.sigmoid(1, 1) == .5
    assert pyss3.sigmoid(.2, .2) == .5
    assert pyss3.sigmoid(.5, .5) == .5
    assert round(pyss3.sigmoid(0, .5), 5) == .00247
    assert round(pyss3.sigmoid(1, .5), 5) == .99753
    assert round(pyss3.sigmoid(1, 2), 5) == .04743

    assert pyss3.mad([1, 1, 1], 3) == (1, .0)
    assert pyss3.mad([1, 1, 1], 3) == (1, .0)
    assert pyss3.mad([], 1) == (0, .0)
    assert round(pyss3.mad([1, 2, 1], 3)[1], 5) == .33333
    assert round(pyss3.mad([1, 10, 1], 3)[1], 5) == 3.0

    r = [(6, 8.1), (7, 5.6), (2, 5.5), (4, 1.5),
         (5, 1.3), (3, 1.2), (0, 1.1), (1, 0.4)]
    assert pyss3.kmean_multilabel_size(r) == 3
    assert pyss3.kmean_multilabel_size([(0, 0), (1, 0)]) == 2

    with pytest.raises(IndexError):
        pyss3.mad([], 0)