## StepOrderNorm


Normalize numeric columns onto a standard normal distribution by rank.


Usage

``` python
StepOrderNorm(
    columns,
    *,
    id=None,
)
```


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](StepNormalize.md#mlfeatures.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](Step.transform.md#mlfeatures.Step.transform) untouched. Missing values pass through as missing.

See [Percentile Scaling](https://feaz-book.com/numeric-percentile) 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](../user-guide/common-step-arguments.md) for the arguments this step shares with the others.


## Parameters


`columns: Selector`  
Columns to normalize. Accepts a single column name, a list of names, a mlfeatures selector such as [Selectors.numeric_features()](Selectors.md#mlfeatures.Selectors.numeric_features) (see [Selectors](Selectors.md#mlfeatures.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`  
Stable step identifier. Defaults to `"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.


## Examples

Each selected column is replaced in place by its normal-quantile score:


``` python
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 |


Specifying the step touches no data:


``` python
recipe = Recipe().add(StepOrderNorm(s.numeric_features()))
recipe
```


    Recipe (untrained)
      Inputs: no roles assigned
      Steps:
        step_order_norm(select(role='feature', type=NumericType))  [untrained]


[fit()](Step.fit.md#mlfeatures.Step.fit) learns each column's rank-to-normal-quantile lookup table:


``` python
fitted = recipe.fit(df)
fitted
```


    Recipe (trained)
      Inputs: 1 columns (1 feature)
      Steps:
        step_order_norm(x)  [trained]


[transform()](Step.transform.md#mlfeatures.Step.transform) applies it in place, turning the right-skewed input into a symmetric, standard-normal-shaped output:


``` python
fitted.transform(df)
```


|     | x         |
|-----|-----------|
| 0   | -1.281552 |
| 1   | -0.524401 |
| 2   | 0.000000  |
| 3   | 0.524401  |
| 4   | 1.281552  |
