A generic wrapper for performing rolling computations.
This can be wrapped around any object which implements both an
update and a
revert method. Inputs to
update are stored in a queue. Elements of the queue are popped when the window is full.
Type → Rollable
An object that implements both an
updatemethod and a
Type → int
Size of the window.
For instance, here is how you can compute a rolling average over a window of size 3:
from river import stats, utils X = [1, 3, 5, 7] rmean = utils.Rolling(stats.Mean(), window_size=3) for x in X: rmean.update(x) print(rmean.get())
1.0 2.0 3.0 5.0