-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[ENH] Expose seasonality parameters of ProphetPiecewiseLinearTrendForecaster #5834
[ENH] Expose seasonality parameters of ProphetPiecewiseLinearTrendForecaster #5834
Conversation
quick question, does this change the default behaviour? I would hope not? |
The default behavior does not change. It just makes the parameters accessible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-principle ok, though I would suggest to improve the docstring (non-blocking)
Thanks @fkiraly for asking for a more precise description. Reading into the exact meaning of the parameters made me realise this change will just create a lot of confusion and constraining the model just to do a piece wise linear fit seems a lot clearer. If you agree, I will create a new branch and constrain the model just to do the piece wise linear fit. |
I think that this is a better idea and would make this trend forecaster's behaviour more intuitive 👍 |
hmmmmm - could you explain the two options? I will also reopen the PR even if we do not merge it, until the discussion is complete, as closed PRs have much lower visibility for developers. If discussionn gets longer, we should open an issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be merged until discussion is complete
@fkiraly fair enough (good policy!) For the record, I will quickly re-iterate and extend on some of the points I mentioned in the original PR. Why I'm not a fan of the current solutionI don't think that a separate
My preferred solutionI think that the solution to this problem that would be simplest, cleanest, and clearest-to-the-end-user, is to simply expose an extra parameter to the existing For instance # this:
forecaster = Prophet(extract_components="trend")
# would be the same as this:
forecaster = ProphetPiecewiseLinearTrendForecaster() and # this:
forecaster = Prophet(yearly_seasonality=False, extract_components="trend")
# would be the same as this:
forecaster = ProphetPiecewiseLinearTrendForecaster(yearly_seasonality=False) and # this:
forecaster = Prophet(yearly_seasonality=False, extract_components=["daily", "weekly"])
# would be the same as this
forecaster = ProphetDeseasonalizer(yearly_seasonality=False) The implementation is very straightforward and clear:
i.e., - y_pred = out.loc[:, "yhat"]
+ component = self.extract_component or "yhat"
+ y_pred = out.loc[:, component] This ☝️ could be extended to accept multiple components (e.g., |
I would like to answer why we should not expose the seasonal components and rather fix them all to What the current implementation does, is to fit a complex model to the data and it is not clear if there are seasonal components added or not. I see two problems with this.
To me, it was frustrating not finding a way to do this type of detrending and that is why I suggested it. How to best add this to the code base, I don't know but having something with a clear intended usage is appealing to me. |
Hm, I think this is a very interesting discussion. Let me see if I understand things correctly, please let me know if not.
Am I understanding well? If yes, I do think both viewpoints are valid and not contradictory.
Some semi-ordered thoughts:
|
apologies for the ping, @hliebert, I meant @tpvasconcelos. The reason is very mundane, GitHub web API has an auto-complete dropdown menu where possible pings are ordered by - not sure - likelihood estimated by an AI or similar. I misclicked. I wonder though whether the model in question knows something. I would find it scary if you actually end up finding this discussion highly relevant for you, @hliebert. |
@fkiraly good summary and I agree with your points! i.e.,
|
@fkiraly I think it would be used in a transformer however I'm not sure what the best way to implement this is. I usually use the A bit unrelated to this conversation, but I think that it's a shame that the So, back to your question, here's a toy example of how I could use the Prophet components with the forecaster = TransformedTargetForecaster(
[
# Remove the trend component w/ a linear Lasso detrender
("detrender": Detrender(TrendForecaster(Lasso()))),
# Remove daily, weekly, and yearly seasonal components using Prophet
("deseasonalizer-dwy": Detrender(Prophet(trend="flat", extract_components=["daily", "weekly", "yearly"]))),
# Forecast the residuals
("forecaster", StatsForecastAutoARIMA()),
]
) I hope you see now why I wish Does this make sense to you? |
Well, we try to not accidentally impact users' downstream code without giving advance warning. Not everyone has the capacity to run the full staging/testing/deploy/monitor mlops cycle, and with a sufficiently large user base there is always someone who (a) relies heavily on any given component and (b) ends up getting their pipeline killed if the change were breaking and unannounced... On the other hand, two months are not as long as one might think. |
Yes, "subtractor" would be more accurate, at the cost of being orders of magnitude more confusing... We did have this conversation at the very start, btw - But agreed that naming is hard. |
|
|
Thanks @tpvasconcelos for the example. Now I got how you want to extract and use the other parts of the model. I wonder though if there are no tools for a Fourier-sum in the
We could also try to wrap another implementation of a piecewise linear regression that is not from the prophet model. Personally, I would like that a lot more even though prophet has shown to work quite well. A quick search revealed this code base (https://github.com/chasmani/piecewise-regression) |
Hm, that seems not to be If you can find a |
@fkiraly I wonder how we should proceed to set the seasonality defaults to |
Imo that's the simplest compliant pathway to the end state where they are internally different and not exposed. I would aim for a differet end state, exposed but default as Yes, this PR could be the start - we could even add a warning right away that the default will change to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - almost done, but I think the warning trigger condition is not right.
The warning should be triggered in every case where the user has code that changes logic witih 0.28.0. I've added a recipe here on how to ensure that: #5875
The case we need to cover is where the user does not set the seasonality parameter explicitly. Under the current condition, no user would see the warning with the version that contains this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conition is now right, but now the requirement "values of self params should always mirror values of init params" is violated.
I've created an example specifically for htis case and would appreciate feedback on how easy it is to understand!
https://www.sktime.net/en/latest/developer_guide/deprecation.html#id1
Of course I can also make the change (it is small), but (a) it's probably interesting to do and (b) it would be great if we can "test" the new example in the developer guide.
@fkiraly Thanks for the example and the doc extension. It makes the deprecation very clear and i will change the script accordingly. Could you elaborate why the trick with |
That's coming from an overriding Good idea to add that to the docs. Would you like to add an explanatory sentence at the end of the first example, or elsewhere were it might be useful (and not to distracting)? The best place would be the point at which the reader starts to ask the question, but late enough so they have had time to digest the example. That is, the best place might be the point at which you started to wonder. |
The PR exposes the seasonal parameters of the ProphetPiecewiseLinearTrendForecaster.
Reference Issues/PRs
The PR is the result of the discussion in this (#5592).
What does this implement/fix? Explain your changes.
This is a simple change to allow the user to define what the seasonality parameters should be. @tpvasconcelos suggested they should be
but as the discussion (#5592) showed it is not clear if this is the best setting.
Does your contribution introduce a new dependency? If yes, which one?
No there are no new dependencies.
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
I added no new test since it is such a simple change.
Any other comments?
PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
sktime
root directory (not theCONTRIBUTORS.md
). Common badges:code
- fixing a bug, or adding code logic.doc
- writing or improving documentation or docstrings.bug
- reporting or diagnosing a bug (get this pluscode
if you also fixed the bug in the PR).maintenance
- CI, test framework, release.See here for full badge reference
See here for further details on the algorithm maintainer role.
For new estimators
docs/source/api_reference/taskname.rst
, follow the pattern.Examples
section.python_dependencies
tag and ensureddependency isolation, see the estimator dependencies guide.