[ENH] Add OnlineSlidingWindow and OnlineExponentialForgetting meta-strategies - #1098
[ENH] Add OnlineSlidingWindow and OnlineExponentialForgetting meta-strategies#1098utsab345 wants to merge 2 commits into
Conversation
…rategies (sktime#1096) Adds two new online learning meta-strategies: - OnlineSlidingWindow(estimator, window_size=100): keeps only the most recent window_size observations, refits on retained window. - OnlineExponentialForgetting(estimator, alpha=0.95, min_weight=1e-3): decays observation weights by alpha each update, prunes below min_weight, refits on survivors. Both extend _DelegatedProbaRegressor and follow the existing OnlineRefit pattern.
|
@utsab345 , thanks for the picking up issue i left some review regarding the doc string, other wise the code looks good to me. |
|
Hi @patelchaitany, thanks for reviewing! I can see your comment that there are a few docstring suggestions, but I don't seem to see the inline review comments under Files changed. Could you please point me to the specific lines or re-submit the review? I'll update them right away. |
| @@ -0,0 +1,230 @@ | |||
| """Meta-strategy for online learning: exponential forgetting.""" | |||
|
|
|||
| __author__ = ["patelchaitany"] | |||
There was a problem hiding this comment.
It should be you not me as this module is created by you
| In ``update``, decays the weight of all previously seen observations | ||
| by ``alpha``. New observations enter with weight 1. Observations whose | ||
| weight drops below ``min_weight`` are pruned. The regressor is then | ||
| refitted on the surviving (weighted) data. |
There was a problem hiding this comment.
there is not weighted data so
should say "surviving data" not "surviving (weighted) data"
|
|
||
| Parameters | ||
| ---------- | ||
| estimator : skpro regressor, descendant of BaseProbaRegressor |
There was a problem hiding this comment.
It should say:
estimator : skpro regressor, descendant of BaseProbaRegressor
regressor to be update-refitted on surviving data, blueprint
Or more precisely: "regressor to be refitted on data surviving the weight threshold, blueprint"
|
Now you can see |
|
Changed as requested: updated |
Reference Issues/PRs
Towards #1096.
What does this implement/fix? Explain your changes.
Adds two new online learning meta-strategies:
OnlineSlidingWindow(
estimator,window_size=100)Keeps only the most recent
window_sizeobservations. Old data beyond the window is discarded. Refits the estimator on the retained window after each update. Suited for non-stationary data with abrupt distribution shifts.OnlineExponentialForgetting(
estimator,alpha=0.95,min_weight=1e-3)Decays all previously seen observations' weights by
alphaat each update. New data enters with weight 1. Observations whose weight drops belowmin_weightare pruned. Refits on surviving data. Acts as a soft sliding window where the effective window length is approximatelylog(min_weight) / log(alpha)updates.Both follow the existing
OnlineRefitpattern - extend_DelegatedProbaRegressor, setcapability:updatetag, clone capability tags from the wrapped estimator, and provideget_test_params.Files changed:
skpro/regression/online/_sliding_window.py(new)skpro/regression/online/_exponential_forgetting.py(new)skpro/regression/online/__init__.py(updated exports)Test changed:
Covered by the existing genericTestAllRegressorscontract test suite viaget_test_params`. Also manually tested with a smoke test (fit → predict_proba → update → predict_proba).