# Introduction

`mlfeatures` separates feature engineering into three phases:

1.  **Specify**: declare the [Recipe](../reference/Recipe.md#mlfeatures.Recipe), a sequence of pre-processing steps.
2.  **Fit**: estimate any required statistics from a training dataset.
3.  **Transform**: apply the fitted recipe identically to new data.

It's designed to support common Python modeling workflows:

- **DataFrame-agnostic.** Works with pandas or polars (thanks to [narwhals](https://narwhals-dev.github.io/narwhals/)).
- **Column selectors.** Use mlfeatures selectors (or polars and narwhals selectors) to target columns for pre-processing.
- **Steps for all kinds of workflows.** Many built-in steps to support pre-processing data for a wide range of models. Organized into a [four stages, eight steps workflow](basics/four-stages-eight-steps.md).
- **Polars .mlf accessor**: Run steps directly on a polars DataFrame.
- **scikit-learn support**: Recipes plug into scikit-learn pipelines.


# Installing

Install mlfeatures using your package manager of choice:

``` bash
pip install mlfeatures
```

A few steps need an optional package, such as scipy for [StepOrderNorm](../reference/StepOrderNorm.md#mlfeatures.StepOrderNorm) (used below). Install the matching extra, for example `pip install "mlfeatures[scipy]"`. The [README](https://github.com/tidymodels/mlfeatures#installation) lists them all.


# Quickstart

Here is a quick snippet that normalizes numeric columns and then runs PCA on a Polars DataFrame (using the `.mlf` accessor).

``` python
import mlfeatures.polars  # registers the `df.mlf` accessor
from mlfeatures import Selectors as s

# fit each step on `df` and apply it right there: center and scale the
# numeric features, then project them onto 4 principal components
result = (
    df.mlf.step_normalize(s.numeric_features())
    .mlf.step_pca(s.numeric_features(), num_comp=4)
)
```

While the code above runs on a single DataFrame, modelling workflows often split data into test and training sets. Use a [Recipe](../reference/Recipe.md#mlfeatures.Recipe) to fit on training data, and transform test data. This is shown below.

``` python
from mlfeatures import Recipe, StepNormalize, StepPca

# a recipe fits the same steps on training data and applies them unchanged
# to any other data frame; `RecipeTransformer` drops one into a scikit-learn
# `Pipeline`
recipe = (
    Recipe()
    .add(StepNormalize(s.numeric_features()))
    .add(StepPca(s.numeric_features(), num_comp=4))
)
fitted = recipe.fit(df_train)
result = fitted.transform(df_test)
```


# Setting up examples

We'll use two examples to illustrate using mlfeatures with polars and scikit-learn. Both examples use the dry beans data packaged with mlfeatures.


``` python
from mlfeatures.data import beans

beans.head()
```


shape: (5, 17)

| area | perimeter | major_axis_length | minor_axis_length | aspect_ratio | eccentricity | convex_area | equiv_diameter | extent | solidity | roundness | compactness | shape_factor_1 | shape_factor_2 | shape_factor_3 | shape_factor_4 | class |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| i64 | f64 | f64 | f64 | f64 | f64 | i64 | f64 | f64 | f64 | f64 | f64 | f64 | f64 | f64 | f64 | str |
| 28395 | 610.291 | 208.178117 | 173.888747 | 1.197191 | 0.549812 | 28715 | 190.141097 | 0.763923 | 0.988856 | 0.958027 | 0.913358 | 0.007332 | 0.003147 | 0.834222 | 0.998724 | "seker" |
| 28734 | 638.018 | 200.524796 | 182.734419 | 1.097356 | 0.411785 | 29172 | 191.27275 | 0.783968 | 0.984986 | 0.887034 | 0.953861 | 0.006979 | 0.003564 | 0.909851 | 0.99843 | "seker" |
| 29380 | 624.11 | 212.82613 | 175.931143 | 1.209713 | 0.562727 | 29690 | 193.410904 | 0.778113 | 0.989559 | 0.947849 | 0.908774 | 0.007244 | 0.003048 | 0.825871 | 0.999066 | "seker" |
| 30008 | 645.884 | 210.557999 | 182.516516 | 1.153638 | 0.498616 | 30724 | 195.467062 | 0.782681 | 0.976696 | 0.903936 | 0.928329 | 0.007017 | 0.003215 | 0.861794 | 0.994199 | "seker" |
| 30140 | 620.134 | 201.847882 | 190.279279 | 1.060798 | 0.33368 | 30417 | 195.896503 | 0.773098 | 0.990893 | 0.984877 | 0.970516 | 0.006697 | 0.003665 | 0.9419 | 0.999166 | "seker" |


We'll also use a small helper to draw a scatterplot matrix:


``` python
import seaborn as sns

sns.set_theme(palette="colorblind")


def plot_pairs(frame):
    """Scatterplot matrix, one color per level of class column."""
    sns.pairplot(
        frame.to_pandas(),
        hue="class",
        hue_order=sorted(frame["class"].unique()),
        plot_kws={"s": 8, "alpha": 0.5, "linewidth": 0},
        diag_kws={"alpha": 0.3},
        height=1.8,
    )
```


# Example: polars beans PCA

Importing `mlfeatures.polars` registers a `mlf` namespace on polars DataFrames. Each `df.mlf.step_*()` call fits that step on the data frame, applies it, and returns a new data frame.

For example, the code below drops constant columns, rank-normalizes and then normalizes each measurement, then projects onto 4 principal components.


``` python
import mlfeatures.polars  # registers the `df.mlf` accessor
from mlfeatures import Selectors as s

bean_pcs = (
    beans.mlf.step_drop_zero_variance(s.numeric_features())
    .mlf.step_order_norm(s.numeric_features())
    .mlf.step_normalize(s.numeric_features())
    .mlf.step_pca(s.numeric_features(), num_comp=4)
)
bean_pcs.head()
```


shape: (5, 5)

| class   | PC1       | PC2       | PC3      | PC4       |
|---------|-----------|-----------|----------|-----------|
| str     | f64       | f64       | f64      | f64       |
| "seker" | -6.133307 | -0.694849 | 0.876906 | 0.075372  |
| "seker" | -6.788823 | -2.075319 | 2.889575 | -0.737496 |
| "seker" | -5.813864 | -0.866828 | 0.366874 | 0.007208  |
| "seker" | -5.113239 | -1.012677 | 3.447783 | -1.434654 |
| "seker" | -8.399019 | -3.946318 | 0.98431  | 0.470248  |


Notice that the output has reduced the data to 4 components. `class` is not numeric, so the `s.numeric_features()` selector didn't try to normalize it.


``` python
plot_pairs(bean_pcs)
```


<figure class="figure">
<p><img src="getting-started_files/figure-html/cell-5-output-1.png" class="figure-img" width="812" height="680" /></p>
</figure>


Each `mlf` call estimated its step on [beans](../reference/data.md#mlfeatures.data.beans) and applied it right there, which is useful for exploring data. However, modelling usually involves fitting pre-processing on a training set, and then using that to transform a test set. To handle this workflow, mlfeatures provides a [Recipe](../reference/Recipe.md#mlfeatures.Recipe) class for specifying steps, fitting, and transforming.


# Example: sklearn Recipe PCA

While the previous example used a single DataFrame, this example splits it into training and test frames. It uses the [Recipe](../reference/Recipe.md#mlfeatures.Recipe) class to specify the pre-processing, fit to the training data frame, and then transform the test frame. Then, it shows how the [Recipe](../reference/Recipe.md#mlfeatures.Recipe) can be used in a scikit-learn pipeline.


## Split data and specify Recipe


``` python
from sklearn.model_selection import train_test_split
from mlfeatures import Recipe, StepDropZeroVariance, StepNormalize, StepOrderNorm, StepPca

# split training and test ---------------------

bean_train, bean_validation = train_test_split(
    beans, train_size=0.75, stratify=beans["class"], random_state=1601
)


# specify recipe -----------------------------

recipe = (
    Recipe(data=bean_train, target="class")
    .add(StepDropZeroVariance(s.numeric_features()))
    .add(StepOrderNorm(s.numeric_features()))
    .add(StepNormalize(s.numeric_features()))
    .add(StepPca(s.numeric_features(), num_comp=4))
)
```


``` python
fitted = recipe.fit(bean_train)
scores = fitted.transform(bean_validation)
scores.head()
```


shape: (5, 5)

| class      | PC1       | PC2       | PC3       | PC4       |
|------------|-----------|-----------|-----------|-----------|
| str        | f64       | f64       | f64       | f64       |
| "dermason" | 2.023914  | 1.285164  | -0.103483 | -0.641545 |
| "sira"     | 0.279919  | -0.549593 | -0.829391 | -1.548377 |
| "sira"     | -0.216578 | 1.181372  | 0.598133  | -0.172482 |
| "horoz"    | -2.658112 | 1.694809  | -0.077129 | -0.7787   |
| "dermason" | 1.501591  | 1.937009  | -0.719575 | 1.138855  |


## Pass to a scikit-learn pipeline

In order to use the [Recipe](../reference/Recipe.md#mlfeatures.Recipe) object in a scikit-learn pipeline, wrap it in [RecipeTransformer](../reference/RecipeTransformer.md#mlfeatures.RecipeTransformer). For example, the code below uses our pre-processing steps as part of fitting a logistic regression.


``` python
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline

from mlfeatures import RecipeTransformer

pipe = Pipeline(
    [
        ("recipe", RecipeTransformer(recipe)),
        ("model", LogisticRegression(max_iter=1000)),
    ]
)
pipe.fit(bean_train.drop("class"), bean_train["class"])
pipe.score(bean_validation.drop("class"), bean_validation["class"])
```


    0.8939171319424037


Note two key pieces:

- `pipe.fit()` fits the recipe and the model on the training split
- `pipe.score()` only pre-processes the test split using the stored estimates before scoring.


# Available steps

The steps above are a few of the built-in ones. Each does one job, and they fall into the [four stages, eight steps workflow](basics/four-stages-eight-steps.md). Here is a representative subset of each kind of step:

| Stage | Step | What it does |
|----|----|----|
| Handle missing values | [StepImputeMedian](../reference/StepImputeMedian.md#mlfeatures.StepImputeMedian) | fill missing numeric values with the training median |
|  | [StepUnknown](../reference/StepUnknown.md#mlfeatures.StepUnknown) | recode missing categorical values to an explicit `"unknown"` level |
| Wrangle | [StepDummy](../reference/StepDummy.md#mlfeatures.StepDummy) | expand a categorical column into *k-1* indicator columns |
|  | [StepOneHot](../reference/StepOneHot.md#mlfeatures.StepOneHot) | expand into all *k* indicator columns |
| Model prep | [StepNormalize](../reference/StepNormalize.md#mlfeatures.StepNormalize) | center and scale each column to mean 0, sd 1 |
|  | [StepOrderNorm](../reference/StepOrderNorm.md#mlfeatures.StepOrderNorm) | rank-normalize each column onto a standard normal |
|  | [StepPolynomial](../reference/StepPolynomial.md#mlfeatures.StepPolynomial) | polynomial basis expansion of a numeric column |
| Multivariate transforms | [StepPca](../reference/StepPca.md#mlfeatures.StepPca) | project numeric columns onto principal components |

In addition, you'll likely drop columns throughout using [StepDropZeroVariance](../reference/StepDropZeroVariance.md#mlfeatures.StepDropZeroVariance) and [StepDropCorr](../reference/StepDropCorr.md#mlfeatures.StepDropCorr). More general transforming and dropping can be done with [StepMutate](../reference/StepMutate.md#mlfeatures.StepMutate) and [StepFilter](../reference/StepFilter.md#mlfeatures.StepFilter), respectively.


# Use with polars (`.mlf`)

Import `mlfeatures.polars` to use the `polars.DataFrame.mlf` accessor. Each method of the accessor returns a new DataFrame.


``` python
beans.mlf.step_pca(s.numeric_features(), num_comp=2).head()
```


shape: (5, 3)

| class   | PC1           | PC2         |
|---------|---------------|-------------|
| str     | f64           | f64         |
| "seker" | -35149.923738 | 22.086841   |
| "seker" | -34586.32189  | -58.586565  |
| "seker" | -33764.026291 | 38.995373   |
| "seker" | -32586.564121 | -239.179424 |
| "seker" | -32712.806082 | 71.43979    |


For more details, see [With polars extension (.mlf)](polars-extension.md).


# Use in a scikit-learn pipeline

The [RecipeTransformer](../reference/RecipeTransformer.md#mlfeatures.RecipeTransformer) class wraps a [Recipe](../reference/Recipe.md#mlfeatures.Recipe) for use in a scikit-learn `Pipeline`:


``` python
from mlfeatures import Recipe, RecipeTransformer

recipe = (
    Recipe(data=bean_train, target="class")
    .add(StepDropZeroVariance(s.numeric_features()))
)

Pipeline(
    [
        ("recipe", RecipeTransformer(recipe)),
        ("model", LogisticRegression(max_iter=1000)),
    ]
)
```


<style>.sk-global {
  /* Definition of color scheme common for light and dark mode */
  --sklearn-color-text: #000;
  --sklearn-color-text-muted: #666;
  --sklearn-color-line: gray;
  /* Definition of color scheme for unfitted estimators */
  --sklearn-color-unfitted-level-0: #fff5e6;
  --sklearn-color-unfitted-level-1: #f6e4d2;
  --sklearn-color-unfitted-level-2: #ffe0b3;
  --sklearn-color-unfitted-level-3: chocolate;
  /* Definition of color scheme for fitted estimators */
  --sklearn-color-fitted-level-0: #f0f8ff;
  --sklearn-color-fitted-level-1: #d4ebff;
  --sklearn-color-fitted-level-2: #b3dbfd;
  --sklearn-color-fitted-level-3: cornflowerblue;
}

.sk-global.light {
  /* Specific color for light theme */
  --sklearn-color-text-on-default-background: black;
  --sklearn-color-background: white;
  --sklearn-color-border-box: black;
  --sklearn-color-icon: #696969;
}

.sk-global.dark {
  --sklearn-color-text-on-default-background: white;
  --sklearn-color-background: #111;
  --sklearn-color-border-box: white;
  --sklearn-color-icon: #878787;
}

.sk-global {
  color: var(--sklearn-color-text);
}

.sk-global pre {
  padding: 0;
}

.sk-global input.sk-hidden--visually {
  border: 0;
  clip-path: inset(100%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.sk-global div.sk-dashed-wrapped {
  border: 1px dashed var(--sklearn-color-line);
  margin: 0 0.4em 0.5em 0.4em;
  box-sizing: border-box;
  padding-bottom: 0.4em;
  background-color: var(--sklearn-color-background);
}

.sk-global div.sk-container {
  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`
     but bootstrap.min.css set `[hidden] { display: none !important; }`
     so we also need the `!important` here to be able to override the
     default hidden behavior on the sphinx rendered scikit-learn.org.
     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */
  display: inline-block !important;
  position: relative;
}

.sk-global div.sk-text-repr-fallback {
  display: none;
}

div.sk-parallel-item,
div.sk-serial,
div.sk-item {
  /* draw centered vertical line to link estimators */
  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));
  background-size: 2px 100%;
  background-repeat: no-repeat;
  background-position: center center;
}

/* Parallel-specific style estimator block */

.sk-global div.sk-parallel-item::after {
  content: "";
  width: 100%;
  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);
  flex-grow: 1;
}

.sk-global div.sk-parallel {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background-color: var(--sklearn-color-background);
  position: relative;
}

.sk-global div.sk-parallel-item {
  display: flex;
  flex-direction: column;
}

.sk-global div.sk-parallel-item:first-child::after {
  align-self: flex-end;
  width: 50%;
}

.sk-global div.sk-parallel-item:last-child::after {
  align-self: flex-start;
  width: 50%;
}

.sk-global div.sk-parallel-item:only-child::after {
  width: 0;
}

/* Serial-specific style estimator block */

.sk-global div.sk-serial {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--sklearn-color-background);
  padding-right: 1em;
  padding-left: 1em;
}


/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is
clickable and can be expanded/collapsed.
- Pipeline and ColumnTransformer use this feature and define the default style
- Estimators will overwrite some part of the style using the `sk-estimator` class
*/

/* Pipeline and ColumnTransformer style (default) */

.sk-global div.sk-toggleable {
  /* Default theme specific background. It is overwritten whether we have a
  specific estimator or a Pipeline/ColumnTransformer */
  background-color: var(--sklearn-color-background);
}

/* Toggleable label */
.sk-global label.sk-toggleable__label {
  cursor: pointer;
  display: flex;
  width: 100%;
  margin-bottom: 0;
  padding: 0.5em;
  box-sizing: border-box;
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
}

.sk-global label.sk-toggleable__label .caption {
  font-size: 0.6rem;
  font-weight: lighter;
  color: var(--sklearn-color-text-muted);
}

.sk-global label.sk-toggleable__label-arrow:before {
  /* Arrow on the left of the label */
  content: "▸";
  float: left;
  margin-right: 0.25em;
  color: var(--sklearn-color-icon);
}

.sk-global label.sk-toggleable__label-arrow:hover:before {
  color: var(--sklearn-color-text);
}

/* Toggleable content - dropdown */

.sk-global div.sk-toggleable__content {
  display: none;
  text-align: left;
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

.sk-global div.sk-toggleable__content.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

.sk-global div.sk-toggleable__content pre {
  margin: 0.2em;
  border-radius: 0.25em;
  color: var(--sklearn-color-text);
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

.sk-global div.sk-toggleable__content.fitted pre {
  /* unfitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

.sk-global input.sk-toggleable__control:checked~div.sk-toggleable__content {
  /* Expand drop-down */
  display: block;
  width: 100%;
  overflow: visible;
}

.sk-global input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {
  content: "▾";
}

/* Pipeline/ColumnTransformer-specific style */

.sk-global div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-unfitted-level-2);
}

.sk-global div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Estimator-specific style */

/* Colorize estimator box */
.sk-global div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-2);
}

.sk-global div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-2);
}

.sk-global div.sk-label label.sk-toggleable__label,
.sk-global div.sk-label label {
  /* The background is the default theme color */
  color: var(--sklearn-color-text-on-default-background);
}

/* On hover, darken the color of the background */
.sk-global div.sk-label:hover label.sk-toggleable__label {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-unfitted-level-2);
}

/* Label box, darken color on hover, fitted */
.sk-global div.sk-label.fitted:hover label.sk-toggleable__label.fitted {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Estimator label */

.sk-global div.sk-label label {
  font-family: monospace;
  font-weight: bold;
  line-height: 1.2em;
}

.sk-global div.sk-label-container {
  text-align: center;
}

/* Estimator-specific */
.sk-global div.sk-estimator {
  font-family: monospace;
  border: 1px dotted var(--sklearn-color-border-box);
  border-radius: 0.25em;
  box-sizing: border-box;
  margin-bottom: 0.5em;
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

.sk-global div.sk-estimator.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

/* on hover */
.sk-global div.sk-estimator:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-2);
}

.sk-global div.sk-estimator.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Specification for estimator info (e.g. "i" and "?") */

/* Common style for "i" and "?" */

.sk-estimator-doc-link,
a:link.sk-estimator-doc-link,
a:visited.sk-estimator-doc-link {
  float: right;
  font-size: smaller;
  line-height: 1em;
  font-family: monospace;
  background-color: var(--sklearn-color-unfitted-level-0);
  border-radius: 1em;
  height: 1em;
  width: 1em;
  text-decoration: none !important;
  margin-left: 0.5em;
  text-align: center;
  /* unfitted */
  border: var(--sklearn-color-unfitted-level-3) 1pt solid;
  color: var(--sklearn-color-unfitted-level-3);
}

.sk-estimator-doc-link.fitted,
a:link.sk-estimator-doc-link.fitted,
a:visited.sk-estimator-doc-link.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
  border: var(--sklearn-color-fitted-level-3) 1pt solid;
  color: var(--sklearn-color-fitted-level-3);
}

/* On hover */
div.sk-estimator:hover .sk-estimator-doc-link:hover,
.sk-estimator-doc-link:hover,
div.sk-label-container:hover .sk-estimator-doc-link:hover,
.sk-estimator-doc-link:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-3);
  border: var(--sklearn-color-fitted-level-0) 1pt solid;
  color: var(--sklearn-color-unfitted-level-0);
  text-decoration: none;
}

div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,
.sk-estimator-doc-link.fitted:hover,
div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,
.sk-estimator-doc-link.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-3);
  border: var(--sklearn-color-fitted-level-0) 1pt solid;
  color: var(--sklearn-color-fitted-level-0);
  text-decoration: none;
}

/* Span, style for the box shown on hovering the info icon */
.sk-estimator-doc-link span {
  display: none;
  z-index: 9999;
  position: relative;
  font-weight: normal;
  right: .2ex;
  padding: .5ex;
  margin: .5ex;
  width: min-content;
  min-width: 20ex;
  max-width: 50ex;
  color: var(--sklearn-color-text);
  box-shadow: 2pt 2pt 4pt #999;
  /* unfitted */
  background: var(--sklearn-color-unfitted-level-0);
  border: .5pt solid var(--sklearn-color-unfitted-level-3);
}

.sk-estimator-doc-link.fitted span {
  /* fitted */
  background: var(--sklearn-color-fitted-level-0);
  border: var(--sklearn-color-fitted-level-3);
}

.sk-estimator-doc-link:hover span {
  display: block;
}

/* "?"-specific style due to the `<a>` HTML tag */

.sk-global a.estimator_doc_link {
  float: right;
  font-size: 1rem;
  line-height: 1em;
  font-family: monospace;
  background-color: var(--sklearn-color-unfitted-level-0);
  border-radius: 1rem;
  height: 1rem;
  width: 1rem;
  text-decoration: none;
  /* unfitted */
  color: var(--sklearn-color-unfitted-level-1);
  border: var(--sklearn-color-unfitted-level-1) 1pt solid;
}

.sk-global a.estimator_doc_link.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
  border: var(--sklearn-color-fitted-level-1) 1pt solid;
  color: var(--sklearn-color-fitted-level-1);
}

/* On hover */
.sk-global a.estimator_doc_link:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-3);
  color: var(--sklearn-color-background);
  text-decoration: none;
}

.sk-global a.estimator_doc_link.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-3);
}

.sk-top-container.sk-global {
  /* pydata-sphinx-theme hides overflow, so scrolling is disabled.
   We need to set it to !important and add tabindex="0" in the HTML
   to allow keyboard-only users to navigate the display. */
  overflow-x: scroll !important;
  max-width: 100%;
}

.estimator-table {
    font-family: monospace;
}

.estimator-table summary {
    padding: .5rem;
    cursor: pointer;
}

.estimator-table summary::marker {
    font-size: 0.7rem;
}

.estimator-table details[open] {
    padding-left: 0.1rem;
    padding-right: 0.1rem;
    padding-bottom: 0.3rem;
}

.estimator-table .parameters-table {
    margin-left: auto !important;
    margin-right: auto !important;
    margin-top: 0;
}

.estimator-table .parameters-table tr:nth-child(odd) {
    background-color: #fff;
}

.estimator-table .parameters-table tr:nth-child(even) {
    background-color: #f6f6f6;
}

.estimator-table .parameters-table tr:hover td {
    background-color: #e0e0e0;
}

.estimator-table table :is(td, th) {
    border: 1px solid rgba(106, 105, 104, 0.232);
}

/*
    `table td`is set in notebook with right text-align.
    We need to overwrite it.
*/
.estimator-table table td.param {
    text-align: left;
    position: relative;
    padding: 0;
}

.user-set td {
    color:rgb(255, 94, 0);
    text-align: left !important;
}

.user-set td.value {
    color:rgb(255, 94, 0);
    background-color: transparent;
}

.default td, .estimator-table th {
    color: black;
    text-align: left !important;
}

.user-set td i,
.default td i {
    color: black;
}

td.fitted-att-type {
    white-space: preserve nowrap;
}

/*
    Styles for parameter documentation links
    We need styling for visited so jupyter doesn't overwrite it
*/
a.param-doc-link,
a.param-doc-link:link,
a.param-doc-link:visited {
    text-decoration: underline dashed;
    text-underline-offset: .3em;
    color: inherit;
    display: block;
    padding: .5em;
}

@supports(anchor-name: --doc-link) {
    a.param-doc-link,
    a.param-doc-link:link,
    a.param-doc-link:visited {
    anchor-name: --doc-link;
    }
}

/* "hack" to make the entire area of the cell containing the link clickable */
a.param-doc-link::before {
    position: absolute;
    content: "";
    inset: 0;
}

.param-doc-description {
    display: none;
    position: absolute;
    z-index: 9999;
    left: 0;
    padding: .5ex;
    margin-left: 1.5em;
    color: var(--sklearn-color-text);
    box-shadow: .3em .3em .4em #999;
    width: max-content;
    text-align: left;
    max-height: 10em;
    overflow-y: auto;

    /* unfitted */
    background: var(--sklearn-color-unfitted-level-0);
    border: thin solid var(--sklearn-color-unfitted-level-3);
}

@supports(position-area: center right) {
    .param-doc-description {
    position-area: center right;
    position: fixed;
    margin-left: 0;
    }
}

/* Fitted state for parameter tooltips */
.fitted .param-doc-description {
    /* fitted */
    background: var(--sklearn-color-fitted-level-0);
    border: thin solid var(--sklearn-color-fitted-level-3);
}

.param-doc-link:hover .param-doc-description {
    display: block;
}

.copy-paste-icon {
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTIwOCAwTDMzMi4xIDBjMTIuNyAwIDI0LjkgNS4xIDMzLjkgMTQuMWw2Ny45IDY3LjljOSA5IDE0LjEgMjEuMiAxNC4xIDMzLjlMNDQ4IDMzNmMwIDI2LjUtMjEuNSA0OC00OCA0OGwtMTkyIDBjLTI2LjUgMC00OC0yMS41LTQ4LTQ4bDAtMjg4YzAtMjYuNSAyMS41LTQ4IDQ4LTQ4ek00OCAxMjhsODAgMCAwIDY0LTY0IDAgMCAyNTYgMTkyIDAgMC0zMiA2NCAwIDAgNDhjMCAyNi41LTIxLjUgNDgtNDggNDhMNDggNTEyYy0yNi41IDAtNDgtMjEuNS00OC00OEwwIDE3NmMwLTI2LjUgMjEuNS00OCA0OC00OHoiLz48L3N2Zz4=);
    background-repeat: no-repeat;
    background-size: 14px 14px;
    background-position: 0;
    display: inline-block;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.features {
  font-family: monospace;
  cursor: pointer;
  background-color: var(--sklearn-color-unfitted-level-0);
  border: 1px dotted var(--sklearn-color-border-box);
  border-radius: .20em;
  margin-bottom: 0.5em;
  font-size: inherit; /* Needed for jupyter */
}

.features.fitted {
  background-color: var(--sklearn-color-fitted-level-0);
}

.features summary {
  cursor: pointer;
  display: flex;
  margin-bottom: 0;
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: .25em;
}

.features details[open] > summary {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-unfitted-level-2);
  border-radius: .20em 0 0 0;
}

.features.fitted details[open] > summary {
  background-color: var(--sklearn-color-fitted-level-2);
  border-radius: .20em 0 0 0;
}

.features details > summary .arrow::before {
  content: "▸";
  color: grey;
}

.features details[open] > summary .arrow::before {
  content: "▾";
}

.features details:hover > summary {
  margin: 0;
  background-color: var(--sklearn-color-unfitted-level-2);
}

.features.fitted details:hover > summary {
  margin: 0;
  background-color: var(--sklearn-color-fitted-level-2);
}

.features .features-container {
  max-width: 15em;
  max-height: 10em;
  overflow: auto;
  scrollbar-width: thin;
  padding: .25em 0.1rem;
  background-color: var(--sklearn-color-unfitted-level-0);
  border-radius: 0 0 .5em .5em;
}

.features.fitted .features-container {
  background-color: var(--sklearn-color-fitted-level-0);
}

.features .image-container {
  block-size: 1em;
  inline-size: 1em;
  padding: 0;
  margin: 0%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.features .copy-paste-icon {
  background-size: 1em 1em;
  width: 1em;
  height: 1em;
  filter: grayscale(100%) opacity(60%);
}

.features .features-container table {
  width: 100%;
  margin: 0.01em;
}

.features .features-container table tr:nth-child(odd) {
  background-color: #fff;
}

.features .features-container table tr:nth-child(even) {
  background-color: #f6f6f6;
}

.features .features-container table tr:hover {
  background-color: #e0e0e0;
}

.features .features-container table {
  table-layout: inherit;
}

.features .features-container table td {
  text-align: left;
  padding: 0 0.5em;
  border: 1px solid rgba(106, 105, 104, 0.232);
  white-space: nowrap;
  color: var(--sklearn-color-text);
}

.total_features {
  display: flex;
  justify-content: center;
  margin-top: 0.5em;
}
</style>


    Pipeline(steps=[('recipe',
                     RecipeTransformer(recipe=Recipe (untrained)
      Inputs: 17 columns (1 target)
      Steps:
        step_drop_zero_variance(select(role='feature', type=NumericType))  [untrained])),
                    ('model', LogisticRegression(max_iter=1000))])

**In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.\
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.**


Pipeline


<a href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html" class="sk-estimator-doc-link" rel="noreferrer" target="_blank">?<span>Documentation for Pipeline</span></a>iNot fitted


Parameters

<table class="parameters-table">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<tbody>
<tr class="user-set">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=steps,-list%20of%20tuples" class="param-doc-link" style="anchor-name: --doc-link-steps;" rel="noreferrer" target="_blank">steps <span class="param-doc-description" style="position-anchor: --doc-link-steps;"> steps: list of tuples<br />
<br />
List of (name of step, estimator) tuples that are to be chained in<br />
sequential order. To be compatible with the scikit-learn API, all steps<br />
must define `fit`. All non-last steps must also define `transform`. See<br />
:ref:`Combining Estimators <combining_estimators>` for more details.</span></a></td>
<td class="value">[('recipe', ...), ('model', ...)]</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=transform_input,-list%20of%20str%2C%20default%3DNone" class="param-doc-link" style="anchor-name: --doc-link-transform_input;" rel="noreferrer" target="_blank">transform_input <span class="param-doc-description" style="position-anchor: --doc-link-transform_input;"> transform_input: list of str, default=None<br />
<br />
The names of the :term:`metadata` parameters that should be transformed by the<br />
pipeline before passing it to the step consuming it.<br />
<br />
This enables transforming some input arguments to ``fit`` (other than ``X``)<br />
to be transformed by the steps of the pipeline up to the step which requires<br />
them. Requirement is defined via :ref:`metadata routing <metadata_routing>`.<br />
For instance, this can be used to pass a validation set through the pipeline.<br />
<br />
You can only set this if metadata routing is enabled, which you<br />
can enable using ``sklearn.set_config(enable_metadata_routing=True)``.<br />
<br />
.. versionadded:: 1.6</span></a></td>
<td class="value">None</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=memory,-str%20or%20object%20with%20the%20joblib.Memory%20interface%2C%20default%3DNone" class="param-doc-link" style="anchor-name: --doc-link-memory;" rel="noreferrer" target="_blank">memory <span class="param-doc-description" style="position-anchor: --doc-link-memory;"> memory: str or object with the joblib.Memory interface, default=None<br />
<br />
Used to cache the fitted transformers of the pipeline. The last step<br />
will never be cached, even if it is a transformer. By default, no<br />
caching is performed. If a string is given, it is the path to the<br />
caching directory. Enabling caching triggers a clone of the transformers<br />
before fitting. Therefore, the transformer instance given to the<br />
pipeline cannot be inspected directly. Use the attribute ``named_steps``<br />
or ``steps`` to inspect estimators within the pipeline. Caching the<br />
transformers is advantageous when fitting is time consuming. See<br />
:ref:`sphx_glr_auto_examples_neighbors_plot_caching_nearest_neighbors.py`<br />
for an example on how to enable caching.</span></a></td>
<td class="value">None</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=verbose,-bool%2C%20default%3DFalse" class="param-doc-link" style="anchor-name: --doc-link-verbose;" rel="noreferrer" target="_blank">verbose <span class="param-doc-description" style="position-anchor: --doc-link-verbose;"> verbose: bool, default=False<br />
<br />
If True, the time elapsed while fitting each step will be printed as it<br />
is completed.</span></a></td>
<td class="value">False</td>
</tr>
</tbody>
</table>


RecipeTransformer (untrained)


Parameters

|     |        |                                 |
|-----|--------|---------------------------------|
|     | recipe | Recipe (untra...) \[untrained\] |


LogisticRegression


<a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html" class="sk-estimator-doc-link" rel="noreferrer" target="_blank">?<span>Documentation for LogisticRegression</span></a>


Parameters

<table class="parameters-table">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<tbody>
<tr class="user-set">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=max_iter,-int%2C%20default%3D100" class="param-doc-link" style="anchor-name: --doc-link-max_iter;" rel="noreferrer" target="_blank">max_iter <span class="param-doc-description" style="position-anchor: --doc-link-max_iter;"> max_iter: int, default=100<br />
<br />
Maximum number of iterations taken for the solvers to converge.</span></a></td>
<td class="value">1000</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=penalty,-%7B%27l1%27%2C%20%27l2%27%2C%20%27elasticnet%27%2C%20None%7D%2C%20default%3D%27l2%27" class="param-doc-link" style="anchor-name: --doc-link-penalty;" rel="noreferrer" target="_blank">penalty <span class="param-doc-description" style="position-anchor: --doc-link-penalty;"> penalty: {'l1', 'l2', 'elasticnet', None}, default='l2'<br />
<br />
Specify the norm of the penalty:<br />
<br />
- `None`: no penalty is added;<br />
- `'l2'`: add an L2 penalty term and it is the default choice;<br />
- `'l1'`: add an L1 penalty term;<br />
- `'elasticnet'`: both L1 and L2 penalty terms are added.<br />
<br />
.. warning::<br />
Some penalties may not work with some solvers. See the parameter<br />
`solver` below, to know the compatibility between the penalty and<br />
solver.<br />
<br />
.. versionadded:: 0.19<br />
l1 penalty with SAGA solver (allowing 'multinomial' + L1)<br />
<br />
.. deprecated:: 1.8<br />
`penalty` was deprecated in version 1.8 and will be removed in 1.10.<br />
Use `l1_ratio` and `C` instead. `l1_ratio=0` for `penalty='l2'`,<br />
`l1_ratio=1` for `penalty='l1'`, `l1_ratio` set to any float between 0 and 1<br />
for `penalty='elasticnet'`, and `C=np.inf` for `penalty=None`.</span></a></td>
<td class="value">'deprecated'</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=C,-float%2C%20default%3D1.0" class="param-doc-link" style="anchor-name: --doc-link-C;" rel="noreferrer" target="_blank">C <span class="param-doc-description" style="position-anchor: --doc-link-C;"> C: float, default=1.0<br />
<br />
Inverse of regularization strength; must be a positive float.<br />
Like in support vector machines, smaller values specify stronger<br />
regularization. `C=np.inf` results in unpenalized logistic regression.<br />
For a visual example on the effect of tuning the `C` parameter<br />
with an L1 penalty, see:<br />
:ref:`sphx_glr_auto_examples_linear_model_plot_logistic_path.py`.</span></a></td>
<td class="value">1.0</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=l1_ratio,-float%2C%20default%3D0.0" class="param-doc-link" style="anchor-name: --doc-link-l1_ratio;" rel="noreferrer" target="_blank">l1_ratio <span class="param-doc-description" style="position-anchor: --doc-link-l1_ratio;"> l1_ratio: float, default=0.0<br />
<br />
The Elastic-Net mixing parameter, with `0 <= l1_ratio <= 1`. Setting<br />
`l1_ratio=1` gives a pure L1-penalty, setting `l1_ratio=0` a pure L2-penalty.<br />
Any value between 0 and 1 gives an Elastic-Net penalty of the form<br />
`l1_ratio * L1 + (1 - l1_ratio) * L2`.<br />
<br />
.. warning::<br />
Certain values of `l1_ratio`, i.e. some penalties, may not work with some<br />
solvers. See the parameter `solver` below, to know the compatibility between<br />
the penalty and solver.<br />
<br />
.. versionchanged:: 1.8<br />
Default value changed from None to 0.0.<br />
<br />
.. deprecated:: 1.8<br />
`None` is deprecated and will be removed in version 1.10. Always use<br />
`l1_ratio` to specify the penalty type.</span></a></td>
<td class="value">0.0</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=dual,-bool%2C%20default%3DFalse" class="param-doc-link" style="anchor-name: --doc-link-dual;" rel="noreferrer" target="_blank">dual <span class="param-doc-description" style="position-anchor: --doc-link-dual;"> dual: bool, default=False<br />
<br />
Dual (constrained) or primal (regularized, see also<br />
:ref:`this equation <regularized-logistic-loss>`) formulation. Dual formulation<br />
is only implemented for l2 penalty with liblinear solver. Prefer `dual=False`<br />
when n_samples > n_features.</span></a></td>
<td class="value">False</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=tol,-float%2C%20default%3D1e-4" class="param-doc-link" style="anchor-name: --doc-link-tol;" rel="noreferrer" target="_blank">tol <span class="param-doc-description" style="position-anchor: --doc-link-tol;"> tol: float, default=1e-4<br />
<br />
Tolerance for stopping criteria.</span></a></td>
<td class="value">0.0001</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=fit_intercept,-bool%2C%20default%3DTrue" class="param-doc-link" style="anchor-name: --doc-link-fit_intercept;" rel="noreferrer" target="_blank">fit_intercept <span class="param-doc-description" style="position-anchor: --doc-link-fit_intercept;"> fit_intercept: bool, default=True<br />
<br />
Specifies if a constant (a.k.a. bias or intercept) should be<br />
added to the decision function.</span></a></td>
<td class="value">True</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=intercept_scaling,-float%2C%20default%3D1" class="param-doc-link" style="anchor-name: --doc-link-intercept_scaling;" rel="noreferrer" target="_blank">intercept_scaling <span class="param-doc-description" style="position-anchor: --doc-link-intercept_scaling;"> intercept_scaling: float, default=1<br />
<br />
Useful only when the solver `liblinear` is used<br />
and `self.fit_intercept` is set to `True`. In this case, `x` becomes<br />
`[x, self.intercept_scaling]`,<br />
i.e. a "synthetic" feature with constant value equal to<br />
`intercept_scaling` is appended to the instance vector.<br />
The intercept becomes<br />
``intercept_scaling * synthetic_feature_weight``.<br />
<br />
.. note::<br />
The synthetic feature weight is subject to L1 or L2<br />
regularization as all other features.<br />
To lessen the effect of regularization on synthetic feature weight<br />
(and therefore on the intercept) `intercept_scaling` has to be increased.</span></a></td>
<td class="value">1</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=class_weight,-dict%20or%20%27balanced%27%2C%20default%3DNone" class="param-doc-link" style="anchor-name: --doc-link-class_weight;" rel="noreferrer" target="_blank">class_weight <span class="param-doc-description" style="position-anchor: --doc-link-class_weight;"> class_weight: dict or 'balanced', default=None<br />
<br />
Weights associated with classes in the form ``{class_label: weight}``.<br />
If not given, all classes are supposed to have weight one.<br />
<br />
The "balanced" mode uses the values of y to automatically adjust<br />
weights inversely proportional to class frequencies in the input data<br />
as ``n_samples / (n_classes * np.bincount(y))``.<br />
<br />
Note that these weights will be multiplied with sample_weight (passed<br />
through the fit method) if sample_weight is specified.<br />
<br />
.. versionadded:: 0.17<br />
*class_weight='balanced'*</span></a></td>
<td class="value">None</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=random_state,-int%2C%20RandomState%20instance%2C%20default%3DNone" class="param-doc-link" style="anchor-name: --doc-link-random_state;" rel="noreferrer" target="_blank">random_state <span class="param-doc-description" style="position-anchor: --doc-link-random_state;"> random_state: int, RandomState instance, default=None<br />
<br />
Used when ``solver`` == 'sag', 'saga' or 'liblinear' to shuffle the<br />
data. See :term:`Glossary <random_state>` for details.</span></a></td>
<td class="value">None</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=solver,-%7B%27lbfgs%27%2C%20%27liblinear%27%2C%20%27newton-cg%27%2C%20%27newton-cholesky%27%2C%20%27sag%27%2C%20%27saga%27%7D%2C%20%20%20%20%20%20%20%20%20%20%20%20%20default%3D%27lbfgs%27" class="param-doc-link" style="anchor-name: --doc-link-solver;" rel="noreferrer" target="_blank">solver <span class="param-doc-description" style="position-anchor: --doc-link-solver;"> solver: {'lbfgs', 'liblinear', 'newton-cg', 'newton-cholesky', 'sag', 'saga'}, default='lbfgs'<br />
<br />
Algorithm to use in the optimization problem. Default is 'lbfgs'.<br />
To choose a solver, you might want to consider the following aspects:<br />
<br />
- 'lbfgs' is a good default solver because it works reasonably well for a wide<br />
class of problems.<br />
- For :term:`multiclass` problems (`n_classes >= 3`), all solvers except<br />
'liblinear' minimize the full multinomial loss, 'liblinear' will raise an<br />
error.<br />
- 'newton-cholesky' is a good choice for<br />
`n_samples` >> `n_features * n_classes`, especially with one-hot encoded<br />
categorical features with rare categories. Be aware that the memory usage<br />
of this solver has a quadratic dependency on `n_features * n_classes`<br />
because it explicitly computes the full Hessian matrix.<br />
- For small datasets, 'liblinear' is a good choice, whereas 'sag'<br />
and 'saga' are faster for large ones;<br />
- 'liblinear' can only handle binary classification by default. To apply a<br />
one-versus-rest scheme for the multiclass setting one can wrap it with the<br />
:class:`~sklearn.multiclass.OneVsRestClassifier`.<br />
<br />
.. warning::<br />
The choice of the algorithm depends on the penalty chosen (`l1_ratio=0`<br />
for L2-penalty, `l1_ratio=1` for L1-penalty and `0 < l1_ratio < 1` for<br />
Elastic-Net) and on (multinomial) multiclass support:<br />
<br />
================= ======================== ======================<br />
solver l1_ratio multinomial multiclass<br />
================= ======================== ======================<br />
'lbfgs' l1_ratio=0 yes<br />
'liblinear' l1_ratio=1 or l1_ratio=0 no<br />
'newton-cg' l1_ratio=0 yes<br />
'newton-cholesky' l1_ratio=0 yes<br />
'sag' l1_ratio=0 yes<br />
'saga' 0<=l1_ratio<=1 yes<br />
================= ======================== ======================<br />
<br />
.. note::<br />
'sag' and 'saga' fast convergence is only guaranteed on features<br />
with approximately the same scale. You can preprocess the data with<br />
a scaler from :mod:`sklearn.preprocessing`.<br />
<br />
.. seealso::<br />
Refer to the :ref:`User Guide <Logistic_regression>` for more<br />
information regarding :class:`LogisticRegression` and more specifically the<br />
:ref:`Table <logistic_regression_solvers>`<br />
summarizing solver/penalty supports.<br />
<br />
.. versionadded:: 0.17<br />
Stochastic Average Gradient (SAG) descent solver. Multinomial support in<br />
version 0.18.<br />
.. versionadded:: 0.19<br />
SAGA solver.<br />
.. versionchanged:: 0.22<br />
The default solver changed from 'liblinear' to 'lbfgs' in 0.22.<br />
.. versionadded:: 1.2<br />
newton-cholesky solver. Multinomial support in version 1.6.</span></a></td>
<td class="value">'lbfgs'</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=verbose,-int%2C%20default%3D0" class="param-doc-link" style="anchor-name: --doc-link-verbose;" rel="noreferrer" target="_blank">verbose <span class="param-doc-description" style="position-anchor: --doc-link-verbose;"> verbose: int, default=0<br />
<br />
For the liblinear and lbfgs solvers set verbose to any positive<br />
number for verbosity.</span></a></td>
<td class="value">0</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=warm_start,-bool%2C%20default%3DFalse" class="param-doc-link" style="anchor-name: --doc-link-warm_start;" rel="noreferrer" target="_blank">warm_start <span class="param-doc-description" style="position-anchor: --doc-link-warm_start;"> warm_start: bool, default=False<br />
<br />
When set to True, reuse the solution of the previous call to fit as<br />
initialization, otherwise, just erase the previous solution.<br />
Useless for liblinear solver. See :term:`the Glossary <warm_start>`.<br />
<br />
.. versionadded:: 0.17<br />
*warm_start* to support *lbfgs*, *newton-cg*, *sag*, *saga* solvers.</span></a></td>
<td class="value">False</td>
</tr>
<tr class="default">
<td><em></em></td>
<td class="param"><a href="https://scikit-learn.org/1.9/modules/generated/sklearn.linear_model.LogisticRegression.html#:~:text=n_jobs,-int%2C%20default%3DNone" class="param-doc-link" style="anchor-name: --doc-link-n_jobs;" rel="noreferrer" target="_blank">n_jobs <span class="param-doc-description" style="position-anchor: --doc-link-n_jobs;"> n_jobs: int, default=None<br />
<br />
Does not have any effect.<br />
<br />
.. deprecated:: 1.8<br />
`n_jobs` is deprecated in version 1.8 and will be removed in 1.10.</span></a></td>
<td class="value">None</td>
</tr>
</tbody>
</table>


Note that the output above is how scikit-learn represents a `Pipeline`, with the top box being the Recipe pre-processing, and the bottom box (LogisticRegression) being the scikit model fitting piece.

For more details on using with cross-validation, tuning, and more, see [With scikit-learn pipelines](sklearn-pipelines.md).


# Next steps

- Jump to the basics: [Fit, specify, transform](basics/recipe-specify-fit-transform.md)
- Learn more about [the Polars accessor](polars-extension.md) or using [in scikit-learn pipelines](sklearn-pipelines.md)
- [Browse the API reference](../reference)
