Skip to content

Commit

Permalink
Add test for typical usage of FeatureCollector in conjunction with
Browse files Browse the repository at this point in the history
FeatureGeneratorRegistry
  • Loading branch information
opcode81 committed Jul 28, 2023
1 parent 53053f0 commit d6e4c36
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/base/test_feature_collector_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from enum import Enum

from sensai.data_transformation import DFTNormalisation, SkLearnTransformerFactoryFactory
from sensai.featuregen import FeatureGeneratorRegistry, FeatureGeneratorTakeColumns


def test_feature_collector_with_registry(irisClassificationTestCase):
class FeatureName(Enum):
ALL = "all"

registry = FeatureGeneratorRegistry()
registry.register_factory(FeatureName.ALL, lambda: FeatureGeneratorTakeColumns(
normalisation_rule_template=DFTNormalisation.RuleTemplate(independent_columns=True)))

fc = registry.collect_features(FeatureName.ALL)

fgen = fc.get_multi_feature_generator()
features_df = fgen.fit_generate(irisClassificationTestCase.data.inputs)

dft_normalisation = fc.create_dft_normalisation(default_transformer_factory=SkLearnTransformerFactoryFactory.MaxAbsScaler())
normalised_features_df = dft_normalisation.fit_apply(features_df)

max_values = normalised_features_df.max(axis=0)
assert all(max_values == 1.0) # test correctness of independent_columns=True

0 comments on commit d6e4c36

Please sign in to comment.