Skip to content

Inference pipeline

fyt.core.inference_pipeline

Persistable inference pipeline: raw features in, predictions out.

Bundles the fitted preprocessing, feature-selection, target-encoding, and model objects from a training run into a single artifact that can be saved to disk, reloaded, and used for batch prediction without any training infrastructure (no MLflow, no dataset config).

InferenceMetadata

Bases: BaseModel

Provenance and interface metadata stored with a saved pipeline.

InferencePipeline

A fitted end-to-end pipeline for predicting on new, raw data.

The prediction flow mirrors training exactly: zero-imputation -> preprocessing transform -> feature selection transform -> model prediction -> inverse target encoding (classification).

Parameters:

Name Type Description Default
pre_processor Any

Fitted PreProcessor (or compatible transformer).

required
feature_selector Any

Fitted FeatureSelector (or compatible transformer).

required
target_processor Any

Fitted TargetProcessor (or compatible encoder).

required
model Any

Fitted model exposing predict (and optionally predict_proba).

required
task TaskType

Learning task type.

required
model_type str

Model type identifier for provenance.

required

load(path) classmethod

Load a pipeline previously written by :meth:save.

Parameters:

Name Type Description Default
path str | Path

Path to the .joblib artifact.

required

Returns:

Type Description
'InferencePipeline'

The deserialized InferencePipeline.

Raises:

Type Description
FileNotFoundError

If the artifact does not exist.

TypeError

If the artifact is not an InferencePipeline.

predict(X)

Predict on raw feature data.

Parameters:

Name Type Description Default
X DataFrame

Raw features with the same columns used at training time (extra columns are tolerated if the preprocessor selects by name).

required

Returns:

Type Description
Series

Predictions as a polars Series. For classification, labels are

Series

returned in the original (pre-encoding) space.

predict_proba(X)

Predict class probabilities on raw feature data.

Parameters:

Name Type Description Default
X DataFrame

Raw features with the training-time columns.

required

Returns:

Type Description
DataFrame

One column per class, named by the original class labels when a

DataFrame

class mapping is available.

Raises:

Type Description
ValueError

For regression tasks or models without predict_proba.

save(path)

Serialize the pipeline to disk with joblib.

Parameters:

Name Type Description Default
path str | Path

Destination file; a .joblib suffix is added if missing.

required

Returns:

Type Description
Path

The final artifact path.