Skip to Content
OchreML

Getting Started with ochreml CLI

Train, inspect, verify, predict, and evaluate machine learning models from your terminal without writing Python.

The ochreml CLI lets you run end-to-end machine learning workflows directly from your shell with zero external Python dependencies (^▽^).

Installation

The ochreml CLI is bundled with the ochreml Python package (no extra dependencies required). Install it with pip, uv, or pipx:

# Using pip
pip install ochreml

# Using uv (global CLI tool)
uv tool install ochreml

# Run one-off without installing globally (uvx)
uvx --from ochreml ochreml info

# Using pipx
pipx install ochreml

To install the latest pre-release (e.g., 0.3.7a1):

pip install --pre ochreml

Every command is available through two equivalent entry points:

ochreml <subcommand> [options]
python -m ochreml <subcommand> [options]

1. Check Your Environment

Verify that the Rust extension is loaded and inspect detected CPU, RAM, and hardware accelerators (cuda, wgpu, tpu):

ochreml info
ochreml doctor

If you want a quick synthetic benchmark across linear models, trees, gradient boosting, and clustering:

ochreml bench --device auto

2. Profile a Dataset

Inspect column types, missingness, summary statistics, and inferred task type (classification or regression) before training. CSV and TSV files work out of the box; Parquet files are supported when pyarrow, polars, or pandas is installed.

ochreml profile housing.csv --target price

Limit the scan on large files with --max-rows:

ochreml profile housing.csv --target price --max-rows 10000

3. Train and Save a .dit Model

Train any OchreML Classical ML estimator (or a basic Sequential MLP) and persist it directly to OchreML's native DIT\x01 binary format:

ochreml train housing.csv \
  --target price \
  --model Ridge \
  --params '{"alpha": 1.0}' \
  --device auto \
  --out models/ridge.dit

ochreml train automatically:

  • Imputes missing numeric feature values with column means.
  • Encodes categorical feature columns deterministically via sorted ordinal mapping.
  • Infers the task (classification vs regression) unless overridden with --task.
  • Reports train_score (accuracy for classification, r2 for regression), elapsed training time, and output file size.

4. Inspect and Verify the .dit Artifact

Check the binary header, model tag, category, and extracted metadata (n_features_in_, coef_shape, hyperparameters) without writing a loader script:

ochreml inspect models/ridge.dit

Validate file extension, binary header integrity, and full deserialization in CI/CD pipelines with verify:

ochreml verify models/ridge.dit

ochreml verify exits with code 0 when the .dit file is valid and 1 if verification fails.

5. Run Batch Predictions

Generate predictions on unlabeled (or labeled) data and optionally write them to CSV or JSON:

# Write predictions to CSV (single column: "prediction")
ochreml predict models/ridge.dit test.csv --out preds.csv

# Write predictions to JSON ({"predictions": [...]})
ochreml predict models/ridge.dit test.csv --out preds.json

If test.csv still contains the target column, pass --target price so predict drops it automatically before inference.

6. Evaluate on Labeled Data

Compute task-appropriate metrics directly on a labeled test set:

ochreml eval models/ridge.dit test.csv --target price
  • Regression outputs r2, rmse, mae, and mse.
  • Classification outputs accuracy, f1_macro, precision_macro, recall_macro, and log_loss (when the estimator implements predict_proba).

7. Machine-Readable Output with --json

Every data-returning subcommand (info, doctor, bench, profile, inspect, verify, train, predict, eval, compare) accepts --json either before or after the subcommand name:

ochreml --json eval models/ridge.dit test.csv --target price
ochreml eval models/ridge.dit test.csv --target price --json

Example JSON response from ochreml eval --json:

{
  "model_path": "models/ridge.dit",
  "model_type": "Ridge",
  "task": "regression",
  "n_samples": 200,
  "metrics": {
    "r2": 0.941283,
    "rmse": 12.408112,
    "mae": 9.61542,
    "mse": 153.961243
  }
}

When --json is enabled and an error occurs, the CLI exits with status 1 and writes structured JSON to stderr:

{"error": "Dataset file not found: 'missing.csv' (´;ω;`)"}

On this page