ochreml_train
Train any OchreML Classical ML estimator or nn.Sequential MLP on CSV, TSV, or Parquet and save to .dit.
ochreml_train loads a tabular dataset, trains a Classical ML estimator (or a 2-layer ochreml.nn.Sequential MLP), and persists the fitted model to a .dit file. It also supports constant-RAM CSV/TSV streaming via partial_fit.
It is backed by ochreml._ops.op_train().
Input Schema
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
data_path | string | Yes | — | Path to training dataset (CSV, TSV, or Parquet). |
target | string | Yes | — | Target column name. |
model_name | string | Yes | — | Estimator name (e.g. Ridge, RandomForestClassifier, Sequential, nn.Sequential). |
out_path | string | Yes | — | Output .dit model file path (.dit extension enforced). |
device | string | No | "auto" | Target device (auto, cpu, cuda:0, cuda:all, wgpu, tpu). |
task | string | No | "auto" | Enum: "auto", "classification", or "regression". |
params | object | No | null | Optional estimator hyperparameters passed as keyword arguments. |
stream | boolean | No | false | Stream CSV/TSV in constant-RAM chunks (2048 rows) using partial_fit(). |
Guardrails & Preprocessing
- Both
data_pathandout_pathare validated via_resolve_contained().out_pathadditionally requires a.ditextension (require_dit=True). - Missing values in numeric feature columns are mean-imputed; categorical feature columns are deterministically ordinal-encoded. Missing values in
targetraise an error. - Parent directories for
out_path(inside the MCP root) are created automatically.
Deep Learning (Sequential / nn.Sequential)
When model_name is "Sequential" or "nn.Sequential", OchreML builds a 2-layer Linear -> ReLU -> Linear network trained with cross_entropy (classification) or mse (regression). Supported keys in params:
hidden_dim(default32)epochs(default30)lr(default0.01)batch_size(defaultmin(64, n_samples))
Streaming Mode (stream: true)
Streaming mode supports CSV and TSV files only, and requires an estimator implementing partial_fit() (such as GaussianNB, MultinomialNB, BernoulliNB, ComplementNB, MLPClassifier, MLPRegressor). In streaming mode, train_score is returned as null.
Example JSON-RPC Call
{
"jsonrpc": "2.0",
"id": 6,
"method": "tools/call",
"params": {
"name": "ochreml_train",
"arguments": {
"data_path": "data/housing.csv",
"target": "price",
"model_name": "Ridge",
"out_path": "models/housing_ridge.dit",
"device": "auto",
"params": {
"alpha": 0.5
}
}
}
}Response Fields
| Field | Type | Description |
|---|---|---|
model_name | string | Estimator name requested. |
task | string | Resolved task ("classification" or "regression"). |
device | string | Device used for training. |
stream | boolean | Whether streaming partial_fit mode was used. |
n_samples | integer | Number of training rows. |
n_features | integer | Number of feature columns. |
feature_names | string[] | Ordered list of feature column names. |
target | string | Target column name. |
train_score | number | null | In-sample accuracy (classification) or r2 (regression); null when stream: true. |
train_time_sec | number | Wall-clock training + save time in seconds. |
out_path | string | Resolved .dit output path. |
size_bytes | integer | Saved .dit file size in bytes. |