Пример #1
0
 def transform(self, fp):
     found_feature = False
     for f in fp:
         if f.name == self.name:
             yield Feature.apply_config(
                 f,
                 feature_type=FeatureType.TARGET
             )
             found_feature = True
         else:
             yield Feature.apply_config(
                 f,
                 feature_type=FeatureType.PREDICTOR
             )
     assert found_feature, "Feature `{}` is not found in the FeaturePool".format(self.name)
Пример #2
0
    def transform(self, fp):
        train_a, test_a = train_test_split(
            FeaturePool(fp).array(),
            test_size = self.test_size,
            random_state = self.random_state,
        )

        for f_id, f in enumerate(fp):
            yield Feature.apply_config(
                Feature(f.name, train_a[:, f_id], f.st),
                split_type=SplitType.TRAIN
            )

        for f_id, f in enumerate(fp):
            yield Feature.apply_config(
                Feature(f.name, test_a[:, f_id], f.st),
                split_type=SplitType.TEST
            )
Пример #3
0
    def transform(self, fp):
        fm, train_x, train_y = FeaturePool.to_train_arrays(fp)

        os = SMOTE(random_state = self.random_state)
        os_train_x, os_train_y = os.fit_sample(train_x, train_y[:, 0])
        os_train_y = os_train_y.reshape((os_train_y.shape[0], 1))

        for f in FeaturePool.from_train_arrays(fm, os_train_x, os_train_y):
            yield Feature.apply_config(f, is_over_sampled=True)
        for f in fp:
            if f.split_type == SplitType.TEST:
                yield f