I was using the following code for transformation in pymc marketing package,
class StandardizeTarget:
target_transformer: Pipeline
@preprocessing_method_y
def standardize_target_data(self, data: pd.Series) -> pd.Series:
target_vector = data.reshape(-1, 1)
transformers = [("scaler", StandardScaler())]
pipeline = Pipeline(steps=transformers)
self.target_transformer: Pipeline = pipeline.fit(X=target_vector)
data = self.target_transformer.transform(X=target_vector).flatten()
return data
But for certain reasons I needed to change the code into the following,
class AbsStandardizeTarget:
target_transformer: Pipeline
@preprocessing_method_y
def standardize_target_data(self, data: pd.Series) -> pd.Series:
target_vector = data.reshape(-1, 1)
transformers = [("scaler", StandardScaler())]
pipeline = Pipeline(steps=transformers)
self.target_transformer: Pipeline = pipeline.fit(X=target_vector)
data = self.target_transformer.transform(X=target_vector).flatten()
data = np.abs(data)
return data
Now I want to unscale the data again using the folloing code again,
if original_scale:
all_contributions_over_time = pd.DataFrame(
data=self.get_target_transformer().inverse_transform(
all_contributions_over_time
),
columns=all_contributions_over_time.columns,
index=all_contributions_over_time.index,
)
all_contributions_over_time.columns = (
all_contributions_over_time.columns.map(
lambda x: f"channel_{x}" if isinstance(x, int) else x
)
)
But here the code self.get_target_transformer() is unscaling the data using standardscaler() function which is inbuilt but not using the function I have defined. How can I change the code so that I get the original unscaled data back.