Exemplo n.º 1
0
    def test_custom_trans_primitives(self):
        """ Test changing the default trans primitives. """
        feat = feature.Creator(data, target, features)
        feat.transform(trans_primitives=["add_numeric"])
        custom_n_cols = len(feat._x.columns)

        feat = feature.Creator(data, target, features)
        feat.transform(trans_primitives=None)
        default_n_cols = len(feat._x.columns)
        assert default_n_cols > custom_n_cols
Exemplo n.º 2
0
    def test_custom_max_depth(self):
        """ Test changing the default trans primitives. """
        feat = feature.Creator(data, target, features)
        feat.transform(trans_primitives=["greater_than", "and"], max_depth=1)
        depth1_n_cols = len(feat._x.columns)

        feat = feature.Creator(data, target, features)
        feat.transform(trans_primitives=["greater_than", "and"], max_depth=2)
        depth2_n_cols = len(feat._x.columns)

        assert depth2_n_cols > depth1_n_cols
Exemplo n.º 3
0
 def test_not_all_nan(self):
     """ Test that no NA features are created. """
     feat = feature.Creator(data, target, features)
     feat.transform(trans_primitives=["greater_than"])
     before = len(feat._x.columns)
     after = len(feat._x.dropna(1, how="all").columns)
     assert before == after
Exemplo n.º 4
0
 def test_create(self):
     """ Test creating variables. """
     feat = feature.Creator(data, target, features)
     old_n_cols = len(feat._x.columns)
     feat.transform()
     new_n_cols = len(feat._x.columns)
     assert new_n_cols > old_n_cols
Exemplo n.º 5
0
 def test_export_files(self):
     """ Test if files are exported accordingly. """
     feat = feature.Creator(data, target, features)
     feat.transform(
         trans_primitives=["greater_than"],
         entity_set_folder_name="entityset",
         features_file_name="features.json",
     )
     assert os.path.exists("entityset") and os.path.exists("features.json")
Exemplo n.º 6
0
 def test_export_files(self):
     """ Test if files are exported accordingly. """
     feat = feature.Creator(data, target, features)
     feat.transform(
         trans_primitives=["greater_than"],
         entity_set_folder_name="entityset",
         features_file_name="features.json",
     )
     feat_matrix = feature.load("entityset", "features.json")
     pd.testing.assert_frame_equal(feat._x, feat_matrix)
Exemplo n.º 7
0
 def setup_class(cls):
     cls.feat = feature.Creator(data, target, features)
Exemplo n.º 8
0
 def test_not_single_value(self):
     """ Test that no single values features are created. """
     feat = feature.Creator(data, target, features)
     feat.transform(trans_primitives=["greater_than"])
     uniques_count = [len(feat._x[col].unique()) for col in feat._x.columns]
     assert 1 not in uniques_count