Skip to content

Rolling

Wrapper for measuring probability distributions over a window.

Parameters

  • dist (river.proba.base.Distribution)

    A distribution.

  • window_size (int)

    A window size.

Attributes

  • n_samples

    The number of observed samples.

Examples

>>> import datetime as dt
>>> from river import proba

>>> X = ['red', 'green', 'green', 'blue', 'blue']

>>> dist = proba.Rolling(
...     proba.Multinomial(),
...     window_size=3
... )

>>> for x in X:
...     dist = dist.update(x)
...     print(dist)
...     print()
P(red) = 1.000
<BLANKLINE>
P(red) = 0.500
P(green) = 0.500
<BLANKLINE>
P(green) = 0.667
P(red) = 0.333
<BLANKLINE>
P(green) = 0.667
P(blue) = 0.333
P(red) = 0.000
<BLANKLINE>
P(blue) = 0.667
P(green) = 0.333
P(red) = 0.000
<BLANKLINE>

Methods

revert

Reverts the parameters of the distribution for a given observation.

Parameters

  • x
  • w – defaults to 1
update

Updates the parameters of the distribution given a new observation.

Parameters

  • x