Skip to content

[ENH] Add OnlineSlidingWindow and OnlineExponentialForgetting meta-strategies - #1098

Open
utsab345 wants to merge 2 commits into
sktime:mainfrom
utsab345:fix/online-sliding-window-exponential-forgetting
Open

[ENH] Add OnlineSlidingWindow and OnlineExponentialForgetting meta-strategies#1098
utsab345 wants to merge 2 commits into
sktime:mainfrom
utsab345:fix/online-sliding-window-exponential-forgetting

Conversation

@utsab345

@utsab345 utsab345 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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_size observations. 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 alpha at each update. New data enters with weight 1. Observations whose weight drops below min_weight are pruned. Refits on surviving data. Acts as a soft sliding window where the effective window length is approximately log(min_weight) / log(alpha) updates.

Both follow the existing OnlineRefit pattern - extend _DelegatedProbaRegressor, set capability:update tag, clone capability tags from the wrapped estimator, and provide get_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).

…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.
@patelchaitany

Copy link
Copy Markdown
Member

@utsab345 , thanks for the picking up issue i left some review regarding the doc string, other wise the code looks good to me.

@utsab345

utsab345 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

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"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not weighted data so

should say "surviving data" not "surviving (weighted) data"


Parameters
----------
estimator : skpro regressor, descendant of BaseProbaRegressor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@patelchaitany

Copy link
Copy Markdown
Member

Now you can see

@utsab345

utsab345 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Changed as requested: updated __author__ to utsab345, fixed docstring wording (removed "(weighted)"), and updated estimator parameter description. Please review, @patelchaitany.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants