def test_other(self): ret = information_value(self.df, "total", ["p1", "p2", "p3"]) ps = np.array([5 / 10, 2 / 10, 3 / 10]) entr = -sum(ps * np.log(ps)) delta = np.log(3) - entr norm = np.log(10) / np.log(15) self.assertAlmostEqual(ret["wother"], norm * delta)
def test_for_max(self): ret = information_value(self.df, "total", ["p1", "p2", "p3"], normalize=True) self.assertAlmostEqual(ret["w2"], (np.log(2) / np.log(14)) * np.log(3))
def test_for_min(self): ret = information_value(self.df, "total", ["p1", "p2", "p3"], normalize=True) self.assertAlmostEqual(ret["w1"], 0)
def test_for_min_information_value(self): ret = information_value(self.df, "total", ["p1", "p2", "p3"]) self.assertAlmostEqual(ret["wmin"], 0)
def test_for_max_information_value(self): ret = information_value(self.df, "total", ["p1", "p2", "p3"]) self.assertAlmostEqual(ret["wmax"], np.log(3))