RollingModeΒΆ
Running mode over a window.
The mode is the most common value.
ParametersΒΆ
-
window_size (int)
Size of the rolling window.
AttributesΒΆ
-
counts (collections.defaultdict)
Value counts.
ExamplesΒΆ
>>> from river import stats
>>> X = ['sunny', 'sunny', 'sunny', 'rainy', 'rainy', 'rainy', 'rainy']
>>> rolling_mode = stats.RollingMode(window_size=2)
>>> for x in X:
... print(rolling_mode.update(x).get())
sunny
sunny
sunny
sunny
rainy
rainy
rainy
>>> rolling_mode = stats.RollingMode(window_size=5)
>>> for x in X:
... print(rolling_mode.update(x).get())
sunny
sunny
sunny
sunny
sunny
rainy
rainy
MethodsΒΆ
get
Return the current value of the statistic.
update
Update and return the called instance.
Parameters
- x (numbers.Number)