Skip to content

Inferencer

mllabs._inferencer.Inferencer

Applies trained processors to new data for inference.

Created by :meth:~mllabs._trainer.Trainer.to_inferencer. Self-contained — no dependency on Experimenter or Trainer at serve time.

Attributes:

Name Type Description
pipeline Pipeline

Minimal pipeline (selected nodes only).

selected_stages list[str]

Stage node names.

selected_heads list[str]

Head node names.

n_splits int

Number of cross-validation splits.

node_objs dict

{node_name: [processor_split0, ...]}.

v

Output column filter applied to Head outputs.

process(data, agg='mean')

Run inference on new data and aggregate across splits.

Parameters:

Name Type Description Default
data

Input dataset (pandas/polars DataFrame or numpy array).

required
agg str | callable | None

Aggregation strategy across splits. 'mean' (default), 'mode', a callable receiving a list of per-split DataFrames, or None (returns list). Ignored when n_splits == 1.

'mean'

Returns:

Type Description

DataFrame | list: Aggregated predictions, or a list of per-split

predictions when agg=None.

save(path)

Serialize the Inferencer to a single file.

Parameters:

Name Type Description Default
path str | Path

Directory to save into. Creates {path}/__inferencer.pkl.

required

load(path) classmethod

Load a saved Inferencer from disk.

Parameters:

Name Type Description Default
path str | Path

Directory containing __inferencer.pkl.

required

Returns:

Name Type Description
Inferencer

Restored inferencer.