def test_threshold(self): p = Prim(TestPrimInitMethod.df, lambda x: x["x1"] * x["x2"] + 0.3 * x["x3"] > 0.5) box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def test_threshold(self): p = Prim(TestPrimInitMethod.df, lambda x : x["x1"]*x["x2"] + 0.3*x["x3"] > 0.5) box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def test_init_numpy(self): df = TestPrimInitMethod.df.to_records(index=False) response = TestPrimInitMethod.response.values p = Prim(df, response, threshold=0.5, threshold_type=">") box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def setUpClass(cls): cls.df = pd.DataFrame(np.random.rand(1000, 3), columns=["x1", "x2", "x3"]) cls.response = cls.df["x1"]*cls.df["x2"] + 0.3*cls.df["x3"] p = Prim(cls.df, cls.response, threshold=0.5, threshold_type=">") box = p.find_box() cls.expected_output = str(box)
def setUpClass(cls): cls.df = pd.DataFrame(np.random.rand(1000, 3), columns=["x1", "x2", "x3"]) cls.response = cls.df["x1"] * cls.df["x2"] + 0.3 * cls.df["x3"] p = Prim(cls.df, cls.response, threshold=0.5, threshold_type=">") box = p.find_box() cls.expected_output = str(box)
def test_string(self): df = copy.deepcopy(TestPrimInitMethod.df) df["y"] = df["x1"]*df["x2"] + 0.3*df["x3"] p = Prim(df, "y", threshold=0.5, threshold_type=">") box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def test_function(self): p = Prim(TestPrimInitMethod.df, lambda x : x["x1"]*x["x2"] + 0.3*x["x3"], threshold=0.5, threshold_type=">") box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def test_string(self): df = copy.deepcopy(TestPrimInitMethod.df) df["y"] = df["x1"] * df["x2"] + 0.3 * df["x3"] p = Prim(df, "y", threshold=0.5, threshold_type=">") box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)
def test_function(self): p = Prim(TestPrimInitMethod.df, lambda x: x["x1"] * x["x2"] + 0.3 * x["x3"], threshold=0.5, threshold_type=">") box = p.find_box() output = str(box) self.assertEqual(output, TestPrimInitMethod.expected_output)