RollingMode¶
Running mode over a window.
The mode is the most common value.
Parameters¶
-
window_size
Type → 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:
rolling_mode.update(x)
print(rolling_mode.get())
sunny
sunny
sunny
sunny
rainy
rainy
rainy
rolling_mode = stats.RollingMode(window_size=5)
for x in X:
rolling_mode.update(x)
print(rolling_mode.get())
sunny
sunny
sunny
sunny
sunny
rainy
rainy
Methods¶
get
Return the current value of the statistic.
update
Update the called instance.
Parameters
- x — 'numbers.Number'