Registry / ai-ml / river
library0.25.0pypypi✓ verified 87d ago

River is a Python library for online machine learning, stream processing, and incremental learning. It provides a comprehensive set of estimators, transformers, and metrics that process data one sample at a time, with built-in drift detection and model evaluation. Current version 0.24.2, released irregularly (several releases per year).

pip install river
INSTALL
IMPORT
SIG · RIVER
R
river
ai-mlpythonv0.25.0
Install
10.4s avg
Import
2995ms
Disk
275MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.25.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 9.3s
py 3.12
✓ —
✓ 9.3s
py 3.13
✓ —
✓ 9.3s
py 3.9
✓ —
✓ 13.5s
275MB installed
● package 275MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

metrics
from river import metrics
import river.metrics
The top-level 'river' submodules are lazy-loaded; accessing via dotted import may fail on first import.
linear_model.LinearRegression
from river import linear_model
from river.linear_model import LinearRegression
While this works, the recommended pattern is to import the module and then access the class.

Basic online learning with a pipeline and metric.

import os from river import stream, linear_model, metrics, preprocessing # Simulate a stream of data (dicts) X_y = [ ({'a': 1, 'b': 2}, 3.0), ({'a': 4, 'b': 5}, 9.0), ({'a': 7, 'b': 8}, 15.0), ] model = preprocessing.StandardScaler() | linear_model.LinearRegression() metric = metrics.MAE() for x, y in stream.iter_array(X_y): # stream.iter_array expects tuples (x_dict, y) y_pred = model.predict_one(x) if y_pred is not None: metric.update(y, y_pred) model.learn_one(x, y) print(f'MAE: {metric.get():.4f}')
Debug
Known issues
breakingRiver 0.20.0 dropped Python 3.10 support; Python >=3.11 is required.
fix
Upgrade Python to 3.11 or later.
affects: >=0.20.0
breakingRiver 0.21.0 removed the `optim` module; optimizers are now part of individual estimators or the `optim` package was integrated.
fix
Use estimator-specific SGD parameters or import `optim` from river if available (check docs).
affects: >=0.21.0
deprecated`stream.iter_pandas` is deprecated in 0.24.0; use `stream.iter_array` or `stream.iter_dict` instead.
fix
Replace `stream.iter_pandas(df, y)` with `stream.iter_array(df.to_dict('records'), df[y].values)`.
affects: >=0.24.0
gotchaMany estimators require `predict_one` after `learn_one` before first predict, else return None. Forgetting this leads to missing predictions.
fix
Always check `y_pred is not None` before using it, or use a warm-up sample.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'river.metrics'
Trying to import a submodule before the parent module is fully loaded; lazy loading causes this.
fix
Use `from river import metrics` instead of `import river.metrics`.
AttributeError: 'NoneType' object has no attribute 'predict_one'
Model not instantiated correctly, or pipeline returned None for step.
fix
Ensure the model is a callable estimator; check pipeline composition.
ValueError: could not broadcast input array from shape (X,) into shape (Y,)
Mismatched dimensions or data type in streaming examples.
fix
Ensure each sample is a dict with matching keys and values are numeric.
RuntimeError: This model has not been trained yet
Called `predict_one` before `learn_one` on models that require training first.
fix
Always call `model.learn_one(x, y)` at least once before prediction.
Upgrade
Version history
0.25.0latest on PyPI · released May 31, 2026
Audit
Dependencies
numpyrequiredCore numerical arrays
pandasoptionalDataFrame conversion and utilities
scipyoptionalOptimization and linear algebra
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
river — pip install river · libregistry