Seamlessly transform target valuesSince mlforecast uses a single global model it can be helpful to apply some transformations to the target to ensure that all series have similar distributions. They can also help remove trend for models that can’t deal with it out of the box.
Transformations applied per serie
Transformations applied to all series
GlobalSklearnTransformer
, which takes a scikit-learn
compatible transformer and applies it to all series. Here’s an example
on how to define a transformation that applies logarithm to each value
of the series + 1, which can help avoid computing the log of 0.
Implementing your own target transformationsIn order to implement your own target transformation you have to define a class that inherits from
mlforecast.target_transforms.BaseTargetTransform
(this takes care of
setting the column names as the id_col
, time_col
and target_col
attributes) and implement the fit_transform
and inverse_transform
methods. Here’s an example on how to define a min-max scaler.
target_transforms
argument.