[ENH] Add online regressor support and River adapter - #1068
[ENH] Add online regressor support and River adapter#1068patelchaitany wants to merge 5 commits into
Conversation
88ea31c to
732a597
Compare
6ca8dfc to
57f3208
Compare
ed314f0 to
4424926
Compare
fkiraly
left a comment
There was a problem hiding this comment.
Nice! Though I think there is somet duplication going on.
- I think the new base class,
BaseOnlineRegressor, can be merged intoBaseProbaRegressor, there is no substantial added functionality. - The new jackknife-plus regressor can be merged into the existing one (the non-MAPIE regressor), simply add the
updatelogic.
4424926 to
90cd8a6
Compare
| ------- | ||
| self : reference to self | ||
| """ | ||
| errs, bs_vs_ix_new, estimators = self._bootstrap_batch(X, y, self.estimators_) |
There was a problem hiding this comment.
As I understand, update is behaving just like a brand new fit on the new batch. Shouldn't _boostrap_batch call _update on the new estimators instead of fit, if the user hass called EnbpiRegressor.update?
There was a problem hiding this comment.
I think I made mistake The original EnbpiRegressor dose not update the trained model it only update the residuals
d64477d to
43fd983
Compare
| return TestAllRegressors | ||
|
|
||
|
|
||
| class regressor_online(_BaseScitypeOfObject): |
There was a problem hiding this comment.
Now that there is no BaseOnlineRegressor, we can remove this object type.
There was a problem hiding this comment.
Yes we can remove that but for the river using we are using separate tag named regressor_online and in future if create separate test for online_regressor it would be easy to add test, wdyt.
There was a problem hiding this comment.
Our API won't be supporting online regression directly, right? Except for update. I believe it would better to follow YAGNI than add this tag at the moment. In addition, this would need to be a separate tag, not a object type value.
| } | ||
|
|
||
|
|
||
| class capability__pred_int(_BaseTag): |
There was a problem hiding this comment.
Could you explain the motivation for this new tag?
There was a problem hiding this comment.
Until now all skpro regressors supported probabilistic prediction, so this tag wasn't needed. The River adapter is the first point-prediction-only estimator, so capability:pred_int is needed to distinguish which regressors support predict_interval/predict_proba - matching sktime's convention.
Add River adapter package (utils, clone, RiverRegressor) and a coerce_to_skpro_regressor helper. Introduce BaseOnlineRegressor and capability:pred_int tag; update BaseProbaRegressor to check pred_int for probabilistic methods.
43fd983 to
bde44e9
Compare
cfe3cfb to
871c953
Compare
| bool | ||
| True if ``obj`` is a River estimator, False otherwise. | ||
| """ | ||
| if obj is None: |
There was a problem hiding this comment.
I think you can preface this with a _check_soft_dependencies call, then you can assume that river is present. That is: if check_soft_dependencies("river"...) is False, return False. Anything that comes after can assume that river is present in the environment.
Why this works: if river is not present, the passed object cannot be a river instance.
| @@ -294,6 +298,7 @@ def predict_proba(self, X): | |||
| y : skpro BaseDistribution, same length as `X` | |||
| labels predicted for `X` | |||
| """ | |||
There was a problem hiding this comment.
are we missing a check_is_fitted here? Unrelated to your PR but it is still missing and shoudl be fixed?
| "matplotlib>=3.3.2", | ||
| "polars<1.43.0", | ||
| "pymc; python_version < '3.13'", | ||
| "river", |
There was a problem hiding this comment.
we should not add it here - this should be an estimator specific dependency.
fkiraly
left a comment
There was a problem hiding this comment.
Great, thanks!
Since this would now add "online-only" regressors to the zoo, we also need to check compatibility with:
- tuners, grid search, etc
- pipelines
- further compositions, if any
For instance, there also, the capability:pred_int tag needs to be set consistently with a potential online update regressor.
You could add this in this PR together with tests, or in a PR building on top of this.
Implement online EnbPI: do not refit clones on update; predict with stored estimators, append new residuals and slide out oldest entries to maintain a fixed pool size. Refactor _bootstrap_batch to initialize estimators_ and fix prediction/residual array shapes and indexing. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
871c953 to
8c679cd
Compare
Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
…gressor Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com> # Conflicts: # skpro/regression/online/_dont_refit.py # skpro/regression/online/_refit.py # skpro/regression/online/_refit_every.py
Reference Issues/PRs
#1066
What does this implement/fix? Explain your changes.
This PR adds the foundation for online regression in skpro, including a new regressor_online scitype and BaseOnlineRegressor with capability:update and capability:pred_int. It introduces the capability:pred_int tag and gates probabilistic prediction methods on regressors that do not support them. It also adds RiverRegressor as a point-prediction adapter for River models, with deepcopy-based cloning and coerce_to_skpro_regressor() for wrapping raw River estimators.
Does your contribution introduce a new dependency? If yes, which one?
No
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Any other comments?
PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot 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 pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.