def test_setattr_new(self): int_missing_data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(int_missing_data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="", target_mapping=None, report_name="test", test_split_percentage=0.5, ) base.col4 = 4 self.assertIsNotNone(base.col4)
def test_setter(self): data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] int_missing_data_rep = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] base = MethodBase( x_train=data, x_test=None, split=False, target_field="", target_mapping=None, report_name="test", test_split_percentage=0.5, ) base.x_train = int_missing_data_rep self.assertEqual(base.x_train, int_missing_data_rep)
def test_write_traindata_tocsv(self): int_missing_data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(int_missing_data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="", report_name="test", target_mapping=None, test_split_percentage=0.5, ) base.to_csv("titanic123") os.remove("titanic123_train.csv") os.remove("titanic123_test.csv") self.assertTrue(True)
def test_where(self): data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=False, target_field="", report_name="test", target_mapping=None, test_split_percentage=0.5, ) subset = base.where(col1=0, col2=2, col3=[3, 4]) validate = subset.values.tolist() self.assertListEqual(validate, [[0, 2, 3]])
def test_groupbyanalysis(self): data = pd.DataFrame({ "A": [1, 1, 2, 2], "B": [1, 2, 3, 4], "C": np.random.randn(4), "D": ["A", "A", "B", "B"], }) base = MethodBase( x_train=data, x_test=None, split=False, target_field="", target_mapping=None, report_name="test", test_split_percentage=0.5, ) base.groupby_analysis(["A"]) self.assertTrue(True)
def test_ytest_dne(self): data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="", report_name=None, target_mapping=None, test_split_percentage=0.5, ) base.y_test = [1, 1] validate = base.y_test.tolist() == [ 1, 1 ] and base._data_properties.x_test["label"].tolist() == [1, 1] self.assertTrue(validate)
def test_setattr_old(self): int_missing_data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(int_missing_data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="", report_name="test", target_mapping=None, test_split_percentage=0.5, ) base._data_properties.target_field = "col3" self.assertEqual("col3", base.target_field)
def test_ytest_split(self): data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="col3", report_name=None, target_mapping=None, test_split_percentage=0.5, ) validate = len(base.y_test) == 2 self.assertTrue(validate)
def test_setitem_tupleeven(self): int_missing_data = [[1, 0, 0], [0, 2, 3], [0, 3, 4], [1, 2, 3]] columns = ["col1", "col2", "col3"] data = pd.DataFrame(int_missing_data, columns=columns) base = MethodBase( x_train=data, x_test=None, split=True, target_field="", target_mapping=None, report_name=None, test_split_percentage=0.5, ) base["col4"] = ([5, 5], [2, 2]) validate = any(base.x_train["col4"].isnull()) and any( base.x_test["col4"].isnull()) self.assertFalse(validate)