:wave: I'm playing with the target transforms add...
# mlforecast
👋 I'm playing with the target transforms added to
in #14. Are there any examples of these being used in an
? They're all throwing an error equivalent to
AttributeError: 'LocalMinMaxScaler' object has no attribute 'set_column_names'
so far
Hey. These have a slightly different interface, so I'm planning on having wrappers on mlforecast for these. If you want to try them out it should be enough to do this:
Copy code
from mlforecast.grouped_array import GroupedArray
from mlforecast.target_transforms import BaseTargetTransform
from utilsforecast.target_transforms import LocalMinMaxScaler as BaseLocalMinMaxScaler

class LocalMinMaxScaler(BaseTargetTransform):
    def fit_transform(self, df):
        df = df.copy(deep=False)
        ga = GroupedArray.from_sorted_df(df, self.id_col, self.target_col)
        self.scaler_ = BaseLocalMinMaxScaler()
        df[self.target_col] = self.scaler_.fit_transform(ga)
        return df

    def inverse_transform(self, df):
        df = df.copy(deep=False)
        sizes = df.groupby(self.id_col, observed=True).size().cumsum()
        indptr = np.append(0, sizes)
        model_cols = df.columns.drop([self.id_col, self.time_col])
        for model in model_cols:
            df[model] = self.scaler_.inverse_transform(GroupedArray(df[model].values, indptr))
        return df
Let me know if you're using
because that requires another method