Skip to Content
OchreML
How-To Guides

AutoML & Constant-RAM Streaming

Compare top estimators with cross-validation using ochreml compare, and train on large CSV/TSV files in constant memory with --stream.

This guide covers two production CLI workflows: automated model selection with ochreml compare and out-of-core training with ochreml train --stream (o´∀`o).

Lightweight AutoML with ochreml compare

ochreml compare runs deterministic K-fold cross-validation (fixed seed 42) across a curated set of fast OchreML estimators, ranks them on a leaderboard, and optionally retrains the winning model on the full dataset and saves it to .dit.

Run a Comparison and Save the Winner

ochreml compare train.csv \
  --target label \
  --cv 5 \
  --device auto \
  --out models/best.dit \
  --json

Key options:

  • --cv: Number of cross-validation folds (default: 3; must be >= 2).
  • --task: auto (default), classification, or regression.
  • --device: Target device (auto, cpu, cuda:0, wgpu, tpu).
  • --out: Optional .dit path. When provided, the top-ranked candidate is refit on 100% of the dataset and written to disk.

Candidate Pools and Scoring Metrics

ochreml compare selects its candidate pool and primary metric based on the resolved task:

TaskPrimary MetricCandidate Estimators
classificationaccuracyLogisticRegression, RidgeClassifier, DecisionTreeClassifier (max_depth=8), RandomForestClassifier (n_estimators=20, max_depth=8), ExtraTreesClassifier (n_estimators=20, max_depth=8), HistGradientBoostingClassifier (max_iter=30), GaussianNB
regressionr2LinearRegression, Ridge (alpha=1.0), DecisionTreeRegressor (max_depth=8), RandomForestRegressor (n_estimators=20, max_depth=8), ExtraTreesRegressor (n_estimators=20, max_depth=8), HistGradientBoostingRegressor (max_iter=30)

Example JSON Leaderboard

{
  "task": "classification",
  "metric": "accuracy",
  "cv": 3,
  "device": "auto",
  "n_samples": 1500,
  "n_features": 12,
  "best_model": "HistGradientBoostingClassifier",
  "best_score": 0.946667,
  "out_path": "models/best.dit",
  "leaderboard": [
    {
      "model": "HistGradientBoostingClassifier",
      "mean_score": 0.946667,
      "std_score": 0.008165,
      "cv_time_sec": 0.1421,
      "status": "ok"
    },
    {
      "model": "RandomForestClassifier",
      "mean_score": 0.938,
      "std_score": 0.0112,
      "cv_time_sec": 0.0984,
      "status": "ok"
    }
  ]
}

If an individual candidate fails (for example, due to data constraints), compare records "status": "error" with the error message at the bottom of the leaderboard and continues evaluating the remaining candidates.


Constant-RAM Streaming with --stream

When a CSV or TSV dataset is too large to fit comfortably in memory, pass --stream to ochreml train. Instead of loading the entire table into RAM, OchreML streams rows from disk in fixed 2,048-row chunks and updates the model incrementally via partial_fit().

Stream-Train a Classifier

ochreml train huge_events.csv \
  --target clicked \
  --model GaussianNB \
  --stream \
  --out models/gnb_stream.dit

Stream-Train a Neural Regressor

ochreml train sensor_readings.tsv \
  --target temperature \
  --model MLPRegressor \
  --params '{"hidden_layer_sizes": [64, 32]}' \
  --stream \
  --out models/mlp_stream.dit

Supported Streaming Estimators

Any estimator implementing partial_fit() works with --stream:

  • GaussianNB
  • MultinomialNB
  • BernoulliNB
  • ComplementNB
  • MLPClassifier
  • MLPRegressor

Passing an estimator without partial_fit() (such as Ridge or RandomForestClassifier) returns a clear error prompting you to switch estimators or omit --stream.

Streaming Constraints and Behavior

  • File formats: --stream supports .csv and .tsv files. Parquet files are not supported in streaming mode.
  • Class discovery: For classification tasks, --stream performs a lightweight first pass over the target column to collect the sorted classes list and passes classes=... on the first partial_fit() call.
  • Numeric parsing: Rows with a missing or non-numeric target are skipped; missing feature values default to 0.0 so no full-dataset mean pass is required.
  • Post-training evaluation: Because the full dataset is never materialized in memory, train_score is null in streaming mode. Run ochreml eval on a holdout file afterward to measure performance:
ochreml eval models/gnb_stream.dit holdout.csv --target clicked --json

On this page