Skip to content

TimeRolling

Wrapper for measuring probability distributions over a period of time.

Parameters

  • dist (river.proba.base.Distribution)

    A distribution.

  • period (datetime.timedelta)

    A period of time.

Attributes

  • n_samples

    The number of observed samples.

Examples

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

>>> X = ['red', 'green', 'green', 'blue']
>>> days = [1, 2, 3, 4]

>>> dist = proba.TimeRolling(
...     proba.Multinomial(),
...     period=dt.timedelta(days=2)
... )

>>> for x, day in zip(X, days):
...     dist = dist.update(x, dt.datetime(2019, 1, day))
...     print(dist)
...     print()
P(red) = 1.000
<BLANKLINE>
P(red) = 0.500
P(green) = 0.500
<BLANKLINE>
P(green) = 1.000
P(red) = 0.000
<BLANKLINE>
P(green) = 0.500
P(blue) = 0.500
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
  • t (datetime.datetime)