# API Reference


## Recipes


Build a recipe, then fit and apply it. The Recipe class and its methods are flattened into this section so each method appears on the reference index.


[Recipe](Recipe.md#mlfeatures.Recipe)  
A declarative, untrained pipeline of feature-engineering steps.

[Recipe.add()](Recipe.add.md#mlfeatures.Recipe.add)  
Return a new recipe with `steps` added after the existing ones.

[Recipe.fit()](Recipe.fit.md#mlfeatures.Recipe.fit)  
Fit each step in order on the training data.

[Recipe.set_roles()](Recipe.set_roles.md#mlfeatures.Recipe.set_roles)  
Return a new recipe with the given role assignments added.

[Recipe.add_role()](Recipe.add_role.md#mlfeatures.Recipe.add_role)  
Return a new recipe with a role added at this point in the chain.

[Recipe.update_role()](Recipe.update_role.md#mlfeatures.Recipe.update_role)  
Return a new recipe with a role changed at this point in the chain.

[Recipe.remove_role()](Recipe.remove_role.md#mlfeatures.Recipe.remove_role)  
Return a new recipe with a role removed at this point in the chain.

[Recipe.update_role_requirements()](Recipe.update_role_requirements.md#mlfeatures.Recipe.update_role_requirements)  
Return a new recipe overriding whether columns are required at transform.

[Recipe.summary()](Recipe.summary.md#mlfeatures.Recipe.summary)  
The input columns, before any step runs, as a tidy data frame.


## Steps: numeric features


Rescale, expand, or derive new numeric columns.


[StepNormalize](StepNormalize.md#mlfeatures.StepNormalize)  
Center and scale numeric columns to zero mean and unit variance.

[StepOrderNorm](StepOrderNorm.md#mlfeatures.StepOrderNorm)  
Normalize numeric columns onto a standard normal distribution by rank.

[StepRange](StepRange.md#mlfeatures.StepRange)  
Scale numeric columns to a fixed range.

[StepLog](StepLog.md#mlfeatures.StepLog)  
Take the logarithm of numeric columns.

[StepPolynomial](StepPolynomial.md#mlfeatures.StepPolynomial)  
Replace numeric columns with their orthogonal polynomial expansion.

[StepSplineNatural](StepSplineNatural.md#mlfeatures.StepSplineNatural)  
Replace numeric columns with a natural cubic spline basis expansion.

[StepSplineMonotone](StepSplineMonotone.md#mlfeatures.StepSplineMonotone)  
Replace numeric columns with a monotone (I-spline) basis expansion.

[StepClassDistance](StepClassDistance.md#mlfeatures.StepClassDistance)  
Replace numeric columns with per-row distances to each class centroid.

[StepGeoDistance](StepGeoDistance.md#mlfeatures.StepGeoDistance)  
Add the distance from each row to a fixed reference point.

[StepIntercept](StepIntercept.md#mlfeatures.StepIntercept)  
Add a constant column with a fixed value.

[StepInteract](StepInteract.md#mlfeatures.StepInteract)  
Add the pairwise product of every pair of selected columns.


## Steps: categorical features


Encode nominal columns as numeric ones.


[StepDummy](StepDummy.md#mlfeatures.StepDummy)  
Expand categorical columns into *k-1* binary indicator columns.

[StepOneHot](StepOneHot.md#mlfeatures.StepOneHot)  
Expand discrete columns into *k* binary indicator columns.

[StepOther](StepOther.md#mlfeatures.StepOther)  
Collapse infrequent categorical levels into a single `"other"` level.


## Steps: date and datetime features


Expand Date and Datetime columns into calendar-part feature columns.


[StepDateFeatures](StepDateFeatures.md#mlfeatures.StepDateFeatures)  
Expand Date columns into calendar-part feature columns.

[StepDatetimeFeatures](StepDatetimeFeatures.md#mlfeatures.StepDatetimeFeatures)  
Expand Datetime columns into calendar-part feature columns.

[StepHoliday](StepHoliday.md#mlfeatures.StepHoliday)  
Add binary indicator columns flagging named holidays and custom recurrences.


## Steps: missing data


Impute missing values, or give them an explicit level.


[StepImputeMean](StepImputeMean.md#mlfeatures.StepImputeMean)  
Impute missing numeric values with the column mean.

[StepImputeMedian](StepImputeMedian.md#mlfeatures.StepImputeMedian)  
Impute missing numeric values with the column median.

[StepImputeMode](StepImputeMode.md#mlfeatures.StepImputeMode)  
Impute missing values with the column mode (most frequent value).

[StepUnknown](StepUnknown.md#mlfeatures.StepUnknown)  
Recode missing categorical levels to an explicit `"unknown"` level.

[StepIndicateNa](StepIndicateNa.md#mlfeatures.StepIndicateNa)  
Add a binary indicator column flagging missing values.


## Steps: dimensionality reduction


Reduce dimensionality, or filter columns that carry no signal.


[StepDropZeroVariance](StepDropZeroVariance.md#mlfeatures.StepDropZeroVariance)  
Remove columns that have a single unique value (zero variance).

[StepDropNearZeroVariance](StepDropNearZeroVariance.md#mlfeatures.StepDropNearZeroVariance)  
Remove columns that are sparse and unbalanced (near-zero variance).

[StepPca](StepPca.md#mlfeatures.StepPca)  
Project numeric columns onto their principal components.

[StepPls](StepPls.md#mlfeatures.StepPls)  
Project numeric columns onto partial-least-squares components.

[StepDropCorr](StepDropCorr.md#mlfeatures.StepDropCorr)  
Remove numeric columns whose pairwise absolute correlation is too high.

[StepDrop](StepDrop.md#mlfeatures.StepDrop)  
Remove the selected columns.


## Steps: general expressions


Arbitrary row filters and column computations; escape hatches rather than a named feature-engineering method.


[StepFilter](StepFilter.md#mlfeatures.StepFilter)  
Remove rows that do not match a predicate.

[StepMutate](StepMutate.md#mlfeatures.StepMutate)  
Apply arbitrary column expressions: the escape hatch.


## Fitted recipes


What Recipe.fit() returns: an immutable, fitted pipeline you can apply to new data. Serialization methods are listed under Serialization below.


[FittedRecipe](FittedRecipe.md#mlfeatures.FittedRecipe)  
A trained pipeline: applies statistics learned at fit time to new data.

[FittedRecipe.transform()](FittedRecipe.transform.md#mlfeatures.FittedRecipe.transform)  
Apply each trained step, in order, to new data.

[FittedRecipe.summary()](FittedRecipe.summary.md#mlfeatures.FittedRecipe.summary)  
The columns the recipe produces, as a tidy data frame.


## Lineage


The column-lineage DAG a fitted recipe maintains: per-column provenance and dtype history, plus the queries that back has_source.


[Lineage](Lineage.md#mlfeatures.Lineage)  
The record of where every column came from, and what happened to it.

[Lineage.removed](Lineage.removed.md#mlfeatures.Lineage.removed)  
Archived nodes of the columns that steps have removed.

[Lineage.summary()](Lineage.summary.md#mlfeatures.Lineage.summary)  
The lineage as a tidy data frame.

[Lineage.columns_from_source()](Lineage.columns_from_source.md#mlfeatures.Lineage.columns_from_source)  
Live columns produced by the step with `id == step_id`.

[Lineage.parents()](Lineage.parents.md#mlfeatures.Lineage.parents)  
Immediate parent columns of `name` (live or archived).

[Lineage.ancestors()](Lineage.ancestors.md#mlfeatures.Lineage.ancestors)  
All columns `name` descends from, transitively.

[ColumnNode](ColumnNode.md#mlfeatures.ColumnNode)  
One column's lineage record.


## Serialization


Save a fitted recipe to a diffable JSON or YAML format and reload it, or strip fit-only artifacts with minimize().


[to_dict()](to_dict.md#mlfeatures.to_dict)  
Serialize a `FittedRecipe` to a diffable, JSON-safe `dict`.

[from_dict()](from_dict.md#mlfeatures.from_dict)  
Reconstruct a `FittedRecipe` from the `dict` produced by `to_dict`.

[to_json()](to_json.md#mlfeatures.to_json)  
Serialize a `FittedRecipe` to a diffable JSON string.

[from_json()](from_json.md#mlfeatures.from_json)  
Reconstruct a `FittedRecipe` from the JSON produced by `to_json`.

[to_yaml()](to_yaml.md#mlfeatures.to_yaml)  
Serialize a `FittedRecipe` to a diffable YAML string.

[from_yaml()](from_yaml.md#mlfeatures.from_yaml)  
Reconstruct a `FittedRecipe` from the YAML produced by `to_yaml`.

[minimize()](minimize.md#mlfeatures.minimize)  
Return a `FittedRecipe` that keeps only what `transform()` needs.

[FittedRecipe.to_dict()](FittedRecipe.to_dict.md#mlfeatures.FittedRecipe.to_dict)  
Serialize to a diffable, JSON-safe `dict`. See `mlfeatures.to_dict` for the layout.

[FittedRecipe.from_dict()](FittedRecipe.from_dict.md#mlfeatures.FittedRecipe.from_dict)  
Reconstruct a fitted recipe from `FittedRecipe.to_dict` output. See `mlfeatures.from_dict`.

[FittedRecipe.to_json()](FittedRecipe.to_json.md#mlfeatures.FittedRecipe.to_json)  
Serialize to a diffable JSON string. See `mlfeatures.to_json`.

[FittedRecipe.from_json()](FittedRecipe.from_json.md#mlfeatures.FittedRecipe.from_json)  
Reconstruct a fitted recipe from `FittedRecipe.to_json` output. See `mlfeatures.from_json`.

[FittedRecipe.to_yaml()](FittedRecipe.to_yaml.md#mlfeatures.FittedRecipe.to_yaml)  
Serialize to a diffable YAML string. See `mlfeatures.to_yaml`.

[FittedRecipe.from_yaml()](FittedRecipe.from_yaml.md#mlfeatures.FittedRecipe.from_yaml)  
Reconstruct a fitted recipe from `FittedRecipe.to_yaml` output. See `mlfeatures.from_yaml`.

[FittedRecipe.minimize()](FittedRecipe.minimize.md#mlfeatures.FittedRecipe.minimize)  
Return a recipe that keeps only what `transform()` needs. See `mlfeatures.minimize`.


## Interop


Adapters for using recipes inside other ecosystems.


[RecipeTransformer](RecipeTransformer.md#mlfeatures.RecipeTransformer)  
Wrap a `Recipe` as a scikit-learn transformer.


## Types & selectors


Selector DSL and the schema/type vocabulary that steps are written against.


[Selectors](Selectors.md#mlfeatures.Selectors)  
Namespace of factory methods for built-in mlfeatures column selectors.

[FeaturesSelector](FeaturesSelector.md#mlfeatures.FeaturesSelector)  
Base class for all mlfeatures-native column selectors.

[Selector](Selector.md#mlfeatures.Selector)  

[ColSchema](ColSchema.md#mlfeatures.ColSchema)  
Column schema: the names and dtypes a step reports for a column set.

[SchemaInfo](SchemaInfo.md#mlfeatures.SchemaInfo)  
Schema-derived context handed to `Step.fit()`.

[Roles](Roles.md#mlfeatures.Roles)  
Column → set of role names.

[Mode](Mode.md#mlfeatures.Mode)  
Shape of a step's input/output relationship.

[KeepOriginals](KeepOriginals.md#mlfeatures.KeepOriginals)  
Whether a step's `keep_original_cols` is fixed or up to the caller.

[KeepOriginals.for_mode()](KeepOriginals.for_mode.md#mlfeatures.KeepOriginals.for_mode)  
The policy that a step of `mode` must follow.

[KeepOriginals.fixed_value()](KeepOriginals.fixed_value.md#mlfeatures.KeepOriginals.fixed_value)  
The mandated `keep_original_cols`, or `None` if configurable.

[Schema](Schema.md#mlfeatures.Schema)  
A structural snapshot of the training data used for boundary checks.

[Schema.check()](Schema.check.md#mlfeatures.Schema.check)  
Validate `frame` against this snapshot.

[DataFrame](DataFrame.md#mlfeatures.DataFrame)  

[Frame](Frame.md#mlfeatures.Frame)  

[ANY_DTYPE](ANY_DTYPE.md#mlfeatures.ANY_DTYPE)  

[NUMERIC_DTYPES](NUMERIC_DTYPES.md#mlfeatures.NUMERIC_DTYPES)  

[AcceptedDtypes](AcceptedDtypes.md#mlfeatures.AcceptedDtypes)  


## Datasets


Example datasets bundled with the package, loaded on access as polars frames (`from mlfeatures.data import credit`). Used throughout the user guide and the examples.


[data](data.md#mlfeatures.data)  
Example datasets bundled with mlfeatures.


## Developing


The abstract Step base class and its lifecycle methods, for authoring new steps. Flattened so each method appears on the reference index.


[Step](Step.md#mlfeatures.Step)  
Abstract base class for a feature-engineering step.

[Step.fit()](Step.fit.md#mlfeatures.Step.fit)  
Resolve selectors, estimate and store statistics, return the fitted step.

[Step.transform()](Step.transform.md#mlfeatures.Step.transform)  
Apply stored statistics to `new_data`. Never re-estimates.

[Step.resolve_selection()](Step.resolve_selection.md#mlfeatures.Step.resolve_selection)  
Resolve this step's `columns` selector to concrete column names.

[Step.update_roles()](Step.update_roles.md#mlfeatures.Step.update_roles)  
Update `roles` to reflect the column changes made by this step.

[Step.schema_in()](Step.schema_in.md#mlfeatures.Step.schema_in)  
Schema of the columns this step consumed. Known after `fit()`.

[Step.schema_out()](Step.schema_out.md#mlfeatures.Step.schema_out)  
Schema of the columns this step produced. Known after `fit()`.

[Step.output_parents()](Step.output_parents.md#mlfeatures.Step.output_parents)  
Map each column this step *produces* to its parent input column(s).

[Step.accepts_dtypes()](Step.accepts_dtypes.md#mlfeatures.Step.accepts_dtypes)  
Dtypes this step is valid to apply to.

[Step.produces_sparse](Step.produces_sparse.md#mlfeatures.Step.produces_sparse)  
Whether this step produces sparse output.

[Step.produced_columns()](Step.produced_columns.md#mlfeatures.Step.produced_columns)  
Ordered names of the columns this step *adds* to the data frame.

[Step.keep_original_cols](Step.keep_original_cols.md#mlfeatures.Step.keep_original_cols)  
Whether to retain the source columns alongside any produced columns.

[Step.required_pkgs()](Step.required_pkgs.md#mlfeatures.Step.required_pkgs)  
Third-party packages required to run this step. Defaults to none.

[Step.check_required_pkgs()](Step.check_required_pkgs.md#mlfeatures.Step.check_required_pkgs)  
Raise if any package this step declares in `required_pkgs` is missing.

[Step.get_params()](Step.get_params.md#mlfeatures.Step.get_params)  
The step's tunable hyperparameters, keyed by constructor argument name.

[Step.set_params()](Step.set_params.md#mlfeatures.Step.set_params)  
Return a new untrained step with `params` replaced.

[Step.to_state()](Step.to_state.md#mlfeatures.Step.to_state)  
Serialize this step's fields to a diffable, JSON-safe `dict`.

[Step.from_state()](Step.from_state.md#mlfeatures.Step.from_state)  
Reconstruct a step from the `dict` produced by `to_state`.

[Step.minimize()](Step.minimize.md#mlfeatures.Step.minimize)  
Return a copy of this step with fit-only artifacts stripped.

[RowOp](RowOp.md#mlfeatures.RowOp)  
Row-altering steps.

[StepError](StepError.md#mlfeatures.StepError)  
A failure raised while fitting or transforming a step.
