Inverse-transforming forecasts with the Diff transformer is tedious. It requires prepending the transformed insample target series to the forecasts for inverse_transform() to work.
We could add an optional parameter insample: TimeSeriesLike | None = None to inverse_transform() of InvertibleDataTransformer and Pipeline, that would simplify this process for the user.
This parameter would at the moment only be used by the Diff transformer and ignored by others.
Some requirements:
- The
insample time series must be the transformed target series returned by Diff().fit_transform(series)
- Time frame:
- It must start at the same time as the transformed target series
- It must extend to at least one step before forecast start, but it can extend further into the future.
- Similar to how we handle
insample for metrics such as mase(), we would extract the relevant parts of the series and prepend it the (forecast) series pass to Diff.inverse_transform()
Expected user flow:
from darts.dataprocessing.transformers import Diff
from darts.datasets import AirPassengersDataset
from darts.models import NaiveSeasonal
# `Diff()` or `Pipeline([Diff()])`
tf = Diff()
series = AirPassengersDataset().load()
series_tf = tf.fit_transform(series)
pred_tf = NaiveSeasonal(K=12).fit(series).predict(n=12)
pred = tf.inverse_transform(pred_tf, insample=series_tf)
That means that the data transformer handling in historical forecasts should also always pass the insample series.
Inverse-transforming forecasts with the
Difftransformer is tedious. It requires prepending the transformed insample target series to the forecasts forinverse_transform()to work.We could add an optional parameter
insample: TimeSeriesLike | None = Nonetoinverse_transform()ofInvertibleDataTransformerandPipeline, that would simplify this process for the user.This parameter would at the moment only be used by the
Difftransformer and ignored by others.Some requirements:
insampletime series must be the transformed target series returned byDiff().fit_transform(series)insamplefor metrics such asmase(), we would extract the relevant parts of the series and prepend it the (forecast) series pass toDiff.inverse_transform()Expected user flow:
That means that the data transformer handling in historical forecasts should also always pass the insample series.