Esempio n. 1
0
def test_entropy_empty():
    series = pd.Series([], dtype=float)
    res = _entropy(series, False)

    assert pytest.approx(res, 0.001) == 0
    res_norm = _entropy(series, True)
    assert pytest.approx(res_norm, 0.01) == 0
Esempio n. 2
0
def test_entropy_string():

    series = pd.Series(["hat", "jug", "hat"])
    res = _entropy(series, False)
    assert pytest.approx(res, 0.001) == 0.636
    res_norm = _entropy(series, True)
    assert pytest.approx(res_norm, 0.01) == 0.918
Esempio n. 3
0
def test_entropy_ints():
    series = pd.Series([0, 1, 2, 4])
    res = _entropy(series, False)

    assert pytest.approx(res, 0.001) == 1.386
    res_norm = _entropy(series, True)
    assert pytest.approx(res_norm, 0.01) == 1