New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] MSTL.inverse_transform
fails if return_components=False
#6397
Comments
How odd. Strictly speaking it is superfluous to wrap the I can see the issue: it is the From a methodological standpoint, the inverse works correctly only in the I see that one would expect that the seasonal component is continued periodically and added back. So, returning Perchance, do you know, @eangius, is there an easy way to get an extrapolated form of all seasonal components in Also FYI @luca-miniati who is the author and maintainer. |
To clarify, I think
|
MSTL.inverse_transform
fails if return_components=False
updated the issue title - imo the root cause is that |
there is also a wider issue, namely that |
Hi Franz, long time no see! I'd like to implement the functionality for Let me know if I understand the solution correctly:
And a clarifying question: why would the index seen in fit potentially not match the index of |
Thanks for the quick diagnostic @fkiraly. Unfortunately I’m still a knob at For context, we are wrapping As an extra bit of context, we tried with |
@eangius, as possible workarounds for de/re-trending in a pipeline:
|
Nice to hear from you again, as well!
Great, let me know if I can help.
Yes, this should happen when it is pipelined with a forecaster. Though, the So, we need to take the indices in
If you work out what happens in a forecasting pipeline, the transformer gets the historic indices in If we have patterns of periodicities 3, 5, 7, denoting the indices of the periodic patterm by 3-0, 3-1, 3-2; 5-0, 5-1, ..., 5-4; 7-0, ..., 7-6, (dashes just for notation, not "minus") then for incides 101, 102, 103 we should forecast, for components, the indices 3-2, 3-0, 3-1; 5-1, 5-2, 5-3; 7-4, 7-5, 7-6. I think this already must be done somewhere in |
Describe the bug
Sktime is a great library thanks. Perhaps this is user error, but running the
MSTL
to remove multiple seasonalities from endogenous variables as a standalone component or within a regular pipeline works as expected but fails to generate predictions when within aTransformedTargetForecaster
.To Reproduce
Expected behavior
No exception at predict time. Seems like something is returning a
pd.Series
& something downstream is expecting apd.DataFrame
Additional context
Traceback (most recent call last): File ".venv/lib/python3.9/site-packages/pandas/core/generic.py", line 575, in _get_axis_number return cls._AXIS_TO_AXIS_NUMBER[axis] KeyError: 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() File "<input>", line 12, in <module> File ".venv/lib/python3.9/site-packages/sktime/forecasting/base/_base.py", line 448, in predict y_pred = self._predict(fh=fh, X=X_inner) File “.venv/lib/python3.9/site-packages/sktime/forecasting/compose/_pipeline.py", line 531, in _predict return self.forecaster_.predict(fh, X) File ".venv/lib/python3.9/site-packages/sktime/forecasting/base/_base.py", line 448, in predict y_pred = self._predict(fh=fh, X=X_inner) File “.venv/lib/python3.9/site-packages/sktime/forecasting/compose/_pipeline.py", line 1053, in _predict y_pred = self._get_inverse_transform(self.transformers_pre_, y_pred, X) File ".venv/lib/python3.9/site-packages/sktime/forecasting/compose/_pipeline.py", line 149, in _get_inverse_transform y = transformer.inverse_transform(y, X) File ".venv/lib/python3.9/site-packages/sktime/transformations/base.py", line 738, in inverse_transform Xt = self._inverse_transform(X=X_inner, y=y_inner) File ".venv/lib/python3.9/site-packages/sktime/transformations/series/detrend/mstl.py", line 203, in _inverse_transform row_sums = X.sum(axis=1) File ".venv/lib/python3.9/site-packages/pandas/core/series.py", line 6519, in sum return NDFrame.sum(self, axis, skipna, numeric_only, min_count, **kwargs) File ".venv/lib/python3.9/site-packages/pandas/core/generic.py", line 12503, in sum return self._min_count_stat_function( File ".venv/lib/python3.9/site-packages/pandas/core/generic.py", line 12486, in _min_count_stat_function return self._reduce( File ".venv/lib/python3.9/site-packages/pandas/core/series.py", line 6430, in _reduce self._get_axis_number(axis) File ".venv/lib/python3.9/site-packages/pandas/core/generic.py", line 577, in _get_axis_number raise ValueError(f"No axis named {axis} for object type {cls.__name__}") ValueError: No axis named 1 for object type Series
Versions
The text was updated successfully, but these errors were encountered: