df = pd.DataFrame({"x": [1.0, 2.0, 4.0, 8.0, 16.0]})
df| x | |
|---|---|
| 0 | 1.0 |
| 1 | 2.0 |
| 2 | 4.0 |
| 3 | 8.0 |
| 4 | 16.0 |
Normalize numeric columns onto a standard normal distribution by rank.
Usage
Each selected numeric column’s training values are ranked (ties averaged) and mapped to normal quantiles, producing a lookup table between the original values and their normal-quantile scores. Every selected column is replaced in place by its score using that table. New values falling outside the training range are extrapolated using the slope of the nearest boundary segment rather than clamped.
Unlike StepNormalize, which only recenters and rescales, this reshapes the column’s whole distribution.
A column with fewer than 2 distinct training values cannot be mapped onto a spread of normal quantiles; it is dropped from the normalization (with a warning) and passes through transform untouched. Missing values pass through as missing.
See Percentile Scaling in Feature Engineering A to Z for the closely related rank-based scaling; it is not a perfect match, since it maps ranks onto [0, 1] rather than onto normal quantiles.
See Arguments shared across steps for the arguments this step shares with the others.
columns: SelectorColumns to normalize. Accepts a single column name, a list of names, a mlfeatures selector such as Selectors.numeric_features() (see Selectors for the full set), or a narwhals or polars selector (narwhals.selectors.numeric(), polars.selectors.numeric()). Selectors are resolved against the data frame’s schema when the recipe is fitted, so the same selector works on any backend. Only numeric columns are meaningful here.
id: str | None = None"order_norm"; a second step of this type in the same recipe becomes "order_norm_2", and passing an id already used in the recipe is an error.
Each selected column is replaced in place by its normal-quantile score:
Specifying the step touches no data:
Recipe (untrained)
Inputs: no roles assigned
Steps:
step_order_norm(select(role='feature', type=NumericType)) [untrained]
fit() learns each column’s rank-to-normal-quantile lookup table:
Recipe (trained)
Inputs: 1 columns (1 feature)
Steps:
step_order_norm(x) [trained]
transform() applies it in place, turning the right-skewed input into a symmetric, standard-normal-shaped output: