online-ml / river

🌊 Online machine learning in Python
https://riverml.xyz
BSD 3-Clause "New" or "Revised" License
5k stars 540 forks source link

preprocessing.StandardScaler.learn_one returns None #1608

Open arevalirio opened 2 weeks ago

arevalirio commented 2 weeks ago

Versions

river version: 0.21.2 Python version: 3.9.19 Operating system: Windows 10 22H2

Describe the bug

The preprocessing.StandardScaler.learn_one method returns None

Steps/code to reproduce

# Sample code to reproduce the problem
# Please do your best to provide a Minimal, Reproducible Example: https://stackoverflow.com/help/minimal-reproducible-example

import random from river import preprocessing

random.seed(42) X = [{'x': random.uniform(8, 12), 'y': random.uniform(8, 12)} for _ in range(6)] for x in X: print(x)

scaler = preprocessing.StandardScaler(with_std=False)

for x in X: scaler.learn_one(x).transform_one(x)

MaxHalford commented 2 weeks ago

This is expected. You have to do this:

import random
from river import preprocessing

random.seed(42)
X = [{'x': random.uniform(8, 12), 'y': random.uniform(8, 12)} for _ in range(6)]
for x in X:
    print(x)

scaler = preprocessing.StandardScaler(with_std=False)

for x in X:
    scaler.learn_one(x)
    scaler.transform_one(x)

I hope this is ok 🤗