def _build_transforms(transforms: Union[Params, List[Params]]):
    if isinstance(transforms, list):
        transforms = [
            RegistrableTransform.from_params(param) for param in transforms
        ]
    else:
        transforms = RegistrableTransform.from_params(transforms)
    return transforms
示例#2
0
    def test_registrable_transform(self) -> None:

        registered_list = set(
            Registrable._registry[RegistrableTransform].keys())

        assert registered_list == set([
            "standard-scaler",
            "min-max-scaler",
            "label-encoder",
            "logarithmer",
            "flatten",
            "hashname",
        ])

        assert (RegistrableTransform.by_name("standard-scaler").__name__ ==
                "StandardScaler")
        assert RegistrableTransform.by_name(
            "min-max-scaler").__name__ == "MinMaxScaler"
        assert RegistrableTransform.by_name(
            "label-encoder").__name__ == "LabelEncoder"
        assert RegistrableTransform.by_name(
            "logarithmer").__name__ == "Logarithmer"
        assert RegistrableTransform.by_name(
            "flatten").__name__ == "FlattenTransformer"
        assert RegistrableTransform.by_name("hashname").__name__ == "HashName"
 def test_flatten(self):
     params = Params.from_file(self.FIXTURES_ROOT / "transforms" /
                               "preprocessing" / "flatten.jsonnet")
     transform = RegistrableTransform.from_params(params=params)
     assert isinstance(transform, FlattenTransformer)
 def test_logarithmer(self):
     params = Params.from_file(self.FIXTURES_ROOT / "transforms" /
                               "preprocessing" / "logarithmer.jsonnet")
     transform = RegistrableTransform.from_params(params=params)
     assert isinstance(transform, Logarithmer)
 def test_min_max_scalar(self):
     params = Params.from_file(self.FIXTURES_ROOT / "transforms" /
                               "preprocessing" / "min_max_scalar.jsonnet")
     transform = RegistrableTransform.from_params(params=params)
     assert isinstance(transform, MinMaxScaler)
 def test_hash_name_from_params(self):
     params = Params.from_file(self.FIXTURES_ROOT / "transforms" /
                               "hash_name" / "hash_name.jsonnet")
     transform = RegistrableTransform.from_params(params=params)
     assert isinstance(transform, HashName)