Skip to main content

:::note Generated reference Generated from honeyframeapi 0.1.8 — do not edit by hand. :::

honeyframeapi.ml

ML recipes — create, configure, run, and read back trained models.

The training counterpart to SavedModel (which only reads models). ML jobs are Flow "AI recipes" of type train_model / score_model / cluster_model / evaluate_model: you create one with a run_config (the table, target, features, algorithm) and run it; a train run registers a SavedModel.

proj = client.get_project(1)
rec = proj.train_model(
"cancel_clf",
input_table="marts.fact_orders",
target_column="is_cancelled",
task_type="classification",
algorithm="random_forest",
features=["store_name", "booking_channel", "is_member"],
run=True, wait=True,
)
print(rec.last_result["metrics"]) # accuracy / AUC / …
model = proj.get_model(rec.last_result["model_id"])

Backed by /api/flow/ai-recipes (create/get/update/run/runs/delete).

class MlRecipe​

A handle to a Flow ML recipe (train/score/cluster/evaluate).

MlRecipe.get()​

get() -> dict

Fetch the recipe row (incl. run_config).

MlRecipe.config​

property

config: dict

The recipe's run_config (the ML params).

MlRecipe.update_config()​

update_config(config: dict, *, merge: bool = True) -> MlRecipe

Update run_config (PUT). merge=True patches onto the existing config; False replaces it wholesale.

MlRecipe.run()​

run(*, wait: bool = False, poll_interval: float = 5.0, timeout: float = 1800.0) -> dict

Execute the recipe. Returns the run result (status, metrics, model_id for a train, error on failure). Result is cached on last_result. wait is accepted for symmetry; the run endpoint is synchronous (it returns once the subprocess finishes). timeout (seconds) bounds the HTTP call, since the run happens inside it.

MlRecipe.runs()​

runs(*, limit: int = 20) -> list[dict]

Execution history for this recipe.

MlRecipe.delete()​

delete() -> None

Delete the recipe (does not delete already-trained models).

Functions​

create_ml_recipe()​

create_ml_recipe(project, name: str, recipe_type: str, *, inputs: list, config: dict, output_datasets: Optional[list] = None) -> MlRecipe

Create an ML recipe of any type and return its MlRecipe handle.

recipe_type ∈ train_model | score_model | cluster_model | evaluate_model. config is the run_config (the runner injects action + project_id). Prefer train_model / score_model / cluster_model / evaluate_model for the common shapes.

train_model()​

train_model(project, name: str, *, input_table: str, target_column: str, task_type: str, algorithm: str, features: Optional[list] = None, hyperparams: Optional[dict] = None, test_size: Optional[float] = None, max_rows: Optional[int] = None, model_name: Optional[str] = None, run: bool = True, wait: bool = True) -> MlRecipe

Train a supervised model (classification/regression).

algorithm must be valid for task_type (e.g. classification: logistic_regression/random_forest/…). features=None lets the runner auto-select columns. With run=True it trains immediately and the result (metrics, model_id) is on MlRecipe.last_result.

score_model()​

score_model(project, name: str, *, input_table: str, model_id: int, output_table: Optional[str] = None, output_schema: Optional[str] = None, max_rows: Optional[int] = None, run: bool = True, wait: bool = True) -> MlRecipe

Score new rows with a trained model. Writes predictions to <output_schema>.<output_table> (defaults: ml_outputs.scored_<model>).

cluster_model()​

cluster_model(project, name: str, *, input_table: str, algorithm: str, features: Optional[list] = None, hyperparams: Optional[dict] = None, output_table: Optional[str] = None, output_schema: Optional[str] = None, max_rows: Optional[int] = None, model_name: Optional[str] = None, run: bool = True, wait: bool = True) -> MlRecipe

Fit a clustering model (e.g. algorithm='kmeans', cluster count via hyperparams={'n_clusters': 5}) and optionally write cluster labels.

evaluate_model()​

evaluate_model(project, name: str, *, input_table: str, target_column: str, model_id: int, max_rows: Optional[int] = None, run: bool = True, wait: bool = True) -> MlRecipe

Evaluate a trained model on a labelled holdout table.


Verified against honeyframeapi 0.1.8.