def _make_transformer(self) -> Transformer: """Build a `Transformer` to transform and inverse-transform samples in the space Returns ------- Transformer Precise architecture and parameters based on :attr:`transform_` and :attr:`prior`""" if self.transform_ == "normalize": if self.prior == "uniform": return Pipeline([Identity(), Normalize(self.low, self.high)]) else: return Pipeline([ Log10(), Normalize(np.log10(self.low), np.log10(self.high)) ]) else: if self.prior == "uniform": return Identity() else: return Log10()
def _make_transformer(self) -> Transformer: """Build a `Transformer` to transform and inverse-transform samples in the space Returns ------- Transformer `Normalize` with bounds (:attr:`low`, :attr:`high`) if :attr:`transform_` == "onehot". Else, `Identity`""" if self.transform_ == "normalize": return Normalize(self.low, self.high, is_int=True) else: return Identity()
def _make_transformer(self) -> Transformer: """Build a `Transformer` to transform and inverse-transform samples in the space Returns ------- Transformer `CategoricalEncoder` fit to :attr:`categories` if :attr:`transform_` == "onehot". Else, `Identity`""" if self.transform_ == "onehot": t = CategoricalEncoder() t.fit(self.categories) return t else: return Identity()
def test_identity_encoder(): transformer = Identity() X = [1, 5, 9, 9, 5, 1] transformer.fit(X) assert_array_equal(transformer.transform(X), X) assert_array_equal(transformer.inverse_transform(X), X) X = ['a', True, 1, 'a', True, 1] transformer.fit(X) assert_array_equal(transformer.transform(X), X) assert_array_equal(transformer.inverse_transform(X), X) X = ["a", "b", "c", "a", "b", "c"] transformer.fit(X) assert_array_equal(transformer.transform(X), X) assert_array_equal(transformer.inverse_transform(X), X)