Exemplo n.º 1
0
def test_private_categorical_hist(example_private_table: PrivateTable):
    """check private hist implementation for categorical column."""
    noisy_hist = example_private_table.cat_hist('Name', PrivacyBudget(10000.))

    err = [1, 1, 1]
    noisy_hist.sort()
    assert all(np.abs(noisy_hist - [1, 1, 2]) < err)
    del noisy_hist
Exemplo n.º 2
0
def test_private_categorical_hist(example_private_table: PrivateTable):
    """check private hist implementation for categorical column of Classes in iris dataset.
    bins:       Iris-setosa, Iris-versicolor, Iris-virginica

    """
    noisy_hist = example_private_table.cat_hist('Class', PrivacyBudget(10000.))

    err = [1, 1, 1]
    noisy_hist.sort()
    assert all(np.abs(noisy_hist-[50, 50, 50]) < err)
    del noisy_hist
Exemplo n.º 3
0
def test_private_categorical_hist(example_private_table: PrivateTable):
    """check private hist implementation for categorical column of Education in adult dataset.
    bins:       HS-grad, Bachelors etc

    """
    noisy_hist = example_private_table.cat_hist('Education',
                                                PrivacyBudget(10000.))

    err = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    noisy_hist.sort()
    assert all(
        np.abs(noisy_hist - [
            51, 168, 333, 413, 433, 514, 576, 646, 933, 1067, 1175, 1382, 1723,
            5355, 7291, 10501
        ]) < err)
    del noisy_hist