Rolling Means behaviour #705
-
Hi friends!, I have a doubt with the following code: from river import compose, stats
from river import feature_extraction as fx
import numbers
data = [
{"store":1, "x":1, "y":1},
{"store":2, "x":1, "y":0},
{"store":2, "x":1, "y":1},
{"store":1, "x":1, "y":0},
{"store":1, "x":1, "y":0},
{"store":2, "x":1, "y":0},
{"store":2, "x":1, "y":1},
{"store":1, "x":1, "y":1},
]
features_pipeline = compose.TransformerUnion(
fx.Agg(on='y' ,
by=['store','x'],
how=stats.RollingMean(window_size=3)),
)
numerical_features = compose.Pipeline(
compose.SelectType(numbers.Number),
)
model = compose.Pipeline(features_pipeline,
numerical_features)
for x in data:
model = model.learn_one(x)
test = [{"store":1, "x":1, "y":1},
{"store":1, "x":1, "y":1},
{"store":1, "x":1, "y":1},
{"store":1, "x":1, "y":0},
{"store":1, "x":1, "y":0},
{"store":1, "x":1, "y":0}
]
for t in test:
print(model.transform_one(t)) What I should expect (and I can be wrong), is that if I use the This is the output of the prints:
Thank you if someone can help me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello friend! It's not a bug, it's a feature. In online learning, unsupervised stuff is update at prediction time, not at learning time. I know it's not intuitive, probably we've all been used to batch fit/predict paradigm. But if you think about it, it actually makes so much sense for online learning. |
Beta Was this translation helpful? Give feedback.
Hello friend!
It's not a bug, it's a feature.
In online learning, unsupervised stuff is update at prediction time, not at learning time. I know it's not intuitive, probably we've all been used to batch fit/predict paradigm. But if you think about it, it actually makes so much sense for online learning.