def test_compute_p_value(self, scale_contingency_table, expected): X = pd.Series(data=(["c1"] * 70 + ["c2"] * 20 + ["c3"] * 10)) y = pd.Series(data=([0] * 35 + [1] * 35 + [0] * 15 + [1] * 5 + [0] * 8 + [1] * 2)) category = "c1" actual = (CategoricalDataProcessor._compute_p_value( X, y, category, scale_contingency_table)) assert pytest.approx(actual, abs=1e-5) == expected
def test_compute_p_value_regression(self, seed, expected): np.random.seed(seed) X = pd.Series(data=(["c1"] * 70 + ["c2"] * 20 + ["c3"] * 10)) y = pd.Series(data=np.random.uniform(0, 1, 100) * 5) category = "c1" actual = (CategoricalDataProcessor._compute_p_value( X, y, category, "regression", None)) assert pytest.approx(actual, abs=1e-5) == expected