One-Tank Incremental Learning
This example identifies a one-step predictor from the same deterministic water-tank simulation as the offline learning variant. The difference is the learning strategy: training observations are delivered in order, one row at a time, to an incremental learner.
Shared System and Data
The water level \(x\) follows
with tank area \(A = 5\), outflow rate \(a = 0.5\), inflow rate \(b = 2\), initial level \(x(0) = 1\), and
examples/one_tank/system.py defines this model once as a single-location HybridSystem with no transitions. simulate_one_tank() simulates 0 to 25 seconds at 0.1-second intervals and returns the sampled t and h columns used by both examples.
A three-sample SlidingWindow creates h_0, h_1, and h_2. The learner predicts the next level h_2 from h_0 and h_1.
Incremental Workflow
run_incremental.py performs these steps:
- Simulate the shared one-tank system and construct sliding-window samples.
- Split the ordered observations into 80 percent training and 20 percent test data without shuffling.
- Wrap the training partition in a
StreamingOfflineEnvironmentwith batch size 1. - Train a River
HoeffdingTreeRegressorthroughRiverLearnerandlearn_incremental. - Evaluate the final model on the fixed holdout data with mean absolute error and mean squared error.
This preserves the incremental-learning intent while using the same simulation and evaluation boundary as the offline example. The script prints the training time and evaluation report.
Run
From the repository root:
uv run --directory ./examples/one_tank python run_incremental.py
To run both one-tank variants:
just examples-one_tank
See Learning Strategies for the distinction between offline and incremental learning.