
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/feature_selection/plot_feature_selection_pipeline.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_feature_selection_plot_feature_selection_pipeline.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_feature_selection_plot_feature_selection_pipeline.py:


==================
Pipeline ANOVA SVM
==================

This example shows how a feature selection can be easily integrated within
a machine learning pipeline.

We also show that you can easily inspect part of the pipeline.

.. GENERATED FROM PYTHON SOURCE LINES 12-16

.. code-block:: Python


    # Authors: The scikit-learn developers
    # SPDX-License-Identifier: BSD-3-Clause








.. GENERATED FROM PYTHON SOURCE LINES 17-19

We will start by generating a binary classification dataset. Subsequently, we
will divide the dataset into two subsets.

.. GENERATED FROM PYTHON SOURCE LINES 19-33

.. code-block:: Python


    from sklearn.datasets import make_classification
    from sklearn.model_selection import train_test_split

    X, y = make_classification(
        n_features=20,
        n_informative=3,
        n_redundant=0,
        n_classes=2,
        n_clusters_per_class=2,
        random_state=42,
    )
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)








.. GENERATED FROM PYTHON SOURCE LINES 34-46

A common mistake done with feature selection is to search a subset of
discriminative features on the full dataset, instead of only using the
training set. The usage of scikit-learn :func:`~sklearn.pipeline.Pipeline`
prevents to make such mistake.

Here, we will demonstrate how to build a pipeline where the first step will
be the feature selection.

When calling `fit` on the training data, a subset of feature will be selected
and the index of these selected features will be stored. The feature selector
will subsequently reduce the number of features, and pass this subset to the
classifier which will be trained.

.. GENERATED FROM PYTHON SOURCE LINES 46-56

.. code-block:: Python


    from sklearn.feature_selection import SelectKBest, f_classif
    from sklearn.pipeline import make_pipeline
    from sklearn.svm import LinearSVC

    anova_filter = SelectKBest(f_classif, k=3)
    clf = LinearSVC()
    anova_svm = make_pipeline(anova_filter, clf)
    anova_svm.fit(X_train, y_train)






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <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><body><div id="sk-container-id-22" tabindex="0" class="sk-top-container sk-global"><div class="sk-text-repr-fallback"><pre>Pipeline(steps=[(&#x27;selectkbest&#x27;, SelectKBest(k=3)), (&#x27;linearsvc&#x27;, LinearSVC())])</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class="sk-container" hidden><div class="sk-item sk-dashed-wrapped"><div class="sk-label-container"><div class="sk-label fitted sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually sk-global" id="sk-estimator-id-68" type="checkbox" ><label for="sk-estimator-id-68" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>Pipeline</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html">?<span>Documentation for Pipeline</span></a><span class="sk-estimator-doc-link fitted">i<span>Fitted</span></span></div></label><div class="sk-toggleable__content fitted" data-param-prefix="">
            <div class="estimator-table">
                <details>
                    <summary>Parameters</summary>
                    <table class="parameters-table">
                      <tbody>
                    
            <tr class="user-set">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('steps',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-steps;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=steps,-list%20of%20tuples">
                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 &lt;combining_estimators&gt;` for more details.</span>
            </a>
        </td>
                <td class="value">[(&#x27;selectkbest&#x27;, ...), (&#x27;linearsvc&#x27;, ...)]</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('transform_input',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-transform_input;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=transform_input,-list%20of%20str%2C%20default%3DNone">
                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 &lt;metadata_routing&gt;`.<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><i class="copy-paste-icon"
                     onclick="copyToClipboard('memory',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-memory;"
                rel="noreferrer" target="_blank" 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">
                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><i class="copy-paste-icon"
                     onclick="copyToClipboard('verbose',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-verbose;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=verbose,-bool%2C%20default%3DFalse">
                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>
                </details>
            </div>
    
            <div class="estimator-table">
                <details>
                    <summary>Fitted attributes</summary>
                    <table class="parameters-table">
                        <tbody>
                            <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Value</th>
                            </tr>
                        
           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-classes_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=classes_,-ndarray%20of%20shape%20%28n_classes%2C%29">
                classes_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-classes_;">
                classes_: ndarray of shape (n_classes,)<br><br>The classes labels. Only exist if the last step of the pipeline is a<br>classifier.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[int64](2,)</td>
               <td>[0,1]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_features_in_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.pipeline.Pipeline.html#:~:text=n_features_in_,-int">
                n_features_in_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_features_in_;">
                n_features_in_: int<br><br>Number of features seen during :term:`fit`. Only defined if the<br>underlying first estimator in `steps` exposes such an attribute<br>when fit.<br><br>.. versionadded:: 0.24</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>20</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div><div class="sk-serial"><div class="sk-item"><div class="sk-estimator fitted sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually sk-global" id="sk-estimator-id-69" type="checkbox" ><label for="sk-estimator-id-69" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>SelectKBest</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html">?<span>Documentation for SelectKBest</span></a></div></label><div class="sk-toggleable__content fitted" data-param-prefix="selectkbest__">
            <div class="estimator-table">
                <details>
                    <summary>Parameters</summary>
                    <table class="parameters-table">
                      <tbody>
                    
            <tr class="user-set">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('k',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-k;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html#:~:text=k,-int%20or%20%22all%22%2C%20default%3D10">
                k
                <span class="param-doc-description"
                style="position-anchor: --doc-link-k;">
                k: int or &quot;all&quot;, default=10<br><br>Number of top features to select.<br>The &quot;all&quot; option bypasses selection, for use in a parameter search.</span>
            </a>
        </td>
                <td class="value">3</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('score_func',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-score_func;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html#:~:text=score_func,-callable%2C%20default%3Df_classif">
                score_func
                <span class="param-doc-description"
                style="position-anchor: --doc-link-score_func;">
                score_func: callable, default=f_classif<br><br>Function taking two arrays X and y, and returning a pair of arrays<br>(scores, pvalues) or a single array with scores.<br>Default is f_classif (see below &quot;See Also&quot;). The default function only<br>works with classification tasks.<br><br>.. versionadded:: 0.18</span>
            </a>
        </td>
                <td class="value">&lt;function f_c...x718b4bd55d20&gt;</td>
            </tr>
    
                      </tbody>
                    </table>
                </details>
            </div>
    
            <div class="estimator-table">
                <details>
                    <summary>Fitted attributes</summary>
                    <table class="parameters-table">
                        <tbody>
                            <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Value</th>
                            </tr>
                        
           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_features_in_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html#:~:text=n_features_in_,-int">
                n_features_in_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_features_in_;">
                n_features_in_: int<br><br>Number of features seen during :term:`fit`.<br><br>.. versionadded:: 0.24</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>20</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-pvalues_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html#:~:text=pvalues_,-array-like%20of%20shape%20%28n_features%2C%29">
                pvalues_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-pvalues_;">
                pvalues_: array-like of shape (n_features,)<br><br>p-values of feature scores, None if `score_func` returned only scores.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](20,)</td>
               <td>[0.71,0.36,0.  ,...,0.64,0.4 ,0.02]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-scores_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.feature_selection.SelectKBest.html#:~:text=scores_,-array-like%20of%20shape%20%28n_features%2C%29">
                scores_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-scores_;">
                scores_: array-like of shape (n_features,)<br><br>Scores of features.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](20,)</td>
               <td>[  0.14,  0.86,104.06,...,  0.22,  0.73,  6.08]</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div>
            <div class="features fitted">
              <details>
                <summary>
                  <div class="arrow"></div>
                  <div>3 features</div>
                  <div class="image-container" title="Copy all output features">
                    <i class="copy-paste-icon"
                      onclick="
                      event.stopPropagation();
                      event.preventDefault();
                      copyFeatureNamesToClipboard(this);
                      "
                    >
                    </i>
                  </div>
                </summary>
                <div class="features-container">
                    <table class="features-table">
                      <tbody>
                    
            <tr>
              <td>x2</td>
            </tr>

    
            <tr>
              <td>x9</td>
            </tr>

    
            <tr>
              <td>x19</td>
            </tr>

    
                      </tbody>
                    </table>
                </div>
              </details>
            </div>
        <div class="sk-item"><div class="sk-estimator fitted sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually sk-global" id="sk-estimator-id-70" type="checkbox" ><label for="sk-estimator-id-70" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>LinearSVC</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html">?<span>Documentation for LinearSVC</span></a></div></label><div class="sk-toggleable__content fitted" data-param-prefix="linearsvc__">
            <div class="estimator-table">
                <details>
                    <summary>Parameters</summary>
                    <table class="parameters-table">
                      <tbody>
                    
            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('penalty',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-penalty;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=penalty,-%7B%27l1%27%2C%20%27l2%27%7D%2C%20default%3D%27l2%27">
                penalty
                <span class="param-doc-description"
                style="position-anchor: --doc-link-penalty;">
                penalty: {&#x27;l1&#x27;, &#x27;l2&#x27;}, default=&#x27;l2&#x27;<br><br>Specifies the norm used in the penalization. The &#x27;l2&#x27;<br>penalty is the standard used in SVC. The &#x27;l1&#x27; leads to ``coef_``<br>vectors that are sparse.</span>
            </a>
        </td>
                <td class="value">&#x27;l2&#x27;</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('loss',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-loss;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=loss,-%7B%27hinge%27%2C%20%27squared_hinge%27%7D%2C%20default%3D%27squared_hinge%27">
                loss
                <span class="param-doc-description"
                style="position-anchor: --doc-link-loss;">
                loss: {&#x27;hinge&#x27;, &#x27;squared_hinge&#x27;}, default=&#x27;squared_hinge&#x27;<br><br>Specifies the loss function. &#x27;hinge&#x27; is the standard SVM loss<br>(used e.g. by the SVC class) while &#x27;squared_hinge&#x27; is the<br>square of the hinge loss. The combination of ``penalty=&#x27;l1&#x27;``<br>and ``loss=&#x27;hinge&#x27;`` is not supported.</span>
            </a>
        </td>
                <td class="value">&#x27;squared_hinge&#x27;</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('dual',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-dual;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=dual,-%22auto%22%20or%20bool%2C%20default%3D%22auto%22">
                dual
                <span class="param-doc-description"
                style="position-anchor: --doc-link-dual;">
                dual: &quot;auto&quot; or bool, default=&quot;auto&quot;<br><br>Select the algorithm to either solve the dual or primal<br>optimization problem. Prefer dual=False when n_samples &gt; n_features.<br>`dual=&quot;auto&quot;` will choose the value of the parameter automatically,<br>based on the values of `n_samples`, `n_features`, `loss`, `multi_class`<br>and `penalty`. If `n_samples` &lt; `n_features` and optimizer supports<br>chosen `loss`, `multi_class` and `penalty`, then dual will be set to True,<br>otherwise it will be set to False.<br><br>.. versionchanged:: 1.3<br>   The `&quot;auto&quot;` option is added in version 1.3 and will be the default<br>   in version 1.5.</span>
            </a>
        </td>
                <td class="value">&#x27;auto&#x27;</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('tol',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-tol;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=tol,-float%2C%20default%3D1e-4">
                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><i class="copy-paste-icon"
                     onclick="copyToClipboard('C',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-C;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=C,-float%2C%20default%3D1.0">
                C
                <span class="param-doc-description"
                style="position-anchor: --doc-link-C;">
                C: float, default=1.0<br><br>Regularization parameter. The strength of the regularization is<br>inversely proportional to C. Must be strictly positive.<br>For an intuitive visualization of the effects of scaling<br>the regularization parameter C, see<br>:ref:`sphx_glr_auto_examples_svm_plot_svm_scale_c.py`.</span>
            </a>
        </td>
                <td class="value">1.0</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('multi_class',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-multi_class;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=multi_class,-%7B%27ovr%27%2C%20%27crammer_singer%27%7D%2C%20default%3D%27ovr%27">
                multi_class
                <span class="param-doc-description"
                style="position-anchor: --doc-link-multi_class;">
                multi_class: {&#x27;ovr&#x27;, &#x27;crammer_singer&#x27;}, default=&#x27;ovr&#x27;<br><br>Determines the multi-class strategy if `y` contains more than<br>two classes.<br>``&quot;ovr&quot;`` trains n_classes one-vs-rest classifiers, while<br>``&quot;crammer_singer&quot;`` optimizes a joint objective over all classes.<br>While `crammer_singer` is interesting from a theoretical perspective<br>as it is consistent, it is seldom used in practice as it rarely leads<br>to better accuracy and is more expensive to compute.<br>If ``&quot;crammer_singer&quot;`` is chosen, the options loss, penalty and dual<br>will be ignored.</span>
            </a>
        </td>
                <td class="value">&#x27;ovr&#x27;</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('fit_intercept',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-fit_intercept;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=fit_intercept,-bool%2C%20default%3DTrue">
                fit_intercept
                <span class="param-doc-description"
                style="position-anchor: --doc-link-fit_intercept;">
                fit_intercept: bool, default=True<br><br>Whether or not to fit an intercept. If set to True, the feature vector<br>is extended to include an intercept term: `[x_1, ..., x_n, 1]`, where<br>1 corresponds to the intercept. If set to False, no intercept will be<br>used in calculations (i.e. data is expected to be already centered).</span>
            </a>
        </td>
                <td class="value">True</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('intercept_scaling',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-intercept_scaling;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=intercept_scaling,-float%2C%20default%3D1.0">
                intercept_scaling
                <span class="param-doc-description"
                style="position-anchor: --doc-link-intercept_scaling;">
                intercept_scaling: float, default=1.0<br><br>When `fit_intercept` is True, the instance vector x becomes ``[x_1,<br>..., x_n, intercept_scaling]``, i.e. a &quot;synthetic&quot; feature with a<br>constant value equal to `intercept_scaling` is appended to the instance<br>vector. The intercept becomes intercept_scaling * synthetic feature<br>weight. Note that liblinear internally penalizes the intercept,<br>treating it like any other term in the feature vector. To reduce the<br>impact of the regularization on the intercept, the `intercept_scaling`<br>parameter can be set to a value greater than 1; the higher the value of<br>`intercept_scaling`, the lower the impact of regularization on it.<br>Then, the weights become `[w_x_1, ..., w_x_n,<br>w_intercept*intercept_scaling]`, where `w_x_1, ..., w_x_n` represent<br>the feature weights and the intercept weight is scaled by<br>`intercept_scaling`. This scaling allows the intercept term to have a<br>different regularization behavior compared to the other features.</span>
            </a>
        </td>
                <td class="value">1</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('class_weight',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-class_weight;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=class_weight,-dict%20or%20%27balanced%27%2C%20default%3DNone">
                class_weight
                <span class="param-doc-description"
                style="position-anchor: --doc-link-class_weight;">
                class_weight: dict or &#x27;balanced&#x27;, default=None<br><br>Set the parameter C of class i to ``class_weight[i]*C`` for<br>SVC. If not given, all classes are supposed to have<br>weight one.<br>The &quot;balanced&quot; 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))``.</span>
            </a>
        </td>
                <td class="value">None</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('verbose',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-verbose;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=verbose,-int%2C%20default%3D0">
                verbose
                <span class="param-doc-description"
                style="position-anchor: --doc-link-verbose;">
                verbose: int, default=0<br><br>Enable verbose output. Note that this setting takes advantage of a<br>per-process runtime setting in liblinear that, if enabled, may not work<br>properly in a multithreaded context.</span>
            </a>
        </td>
                <td class="value">0</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('random_state',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-random_state;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=random_state,-int%2C%20RandomState%20instance%20or%20None%2C%20default%3DNone">
                random_state
                <span class="param-doc-description"
                style="position-anchor: --doc-link-random_state;">
                random_state: int, RandomState instance or None, default=None<br><br>Controls the pseudo random number generation for shuffling the data for<br>the dual coordinate descent (if ``dual=True``). When ``dual=False`` the<br>underlying implementation of :class:`LinearSVC` is not random and<br>``random_state`` has no effect on the results.<br>Pass an int for reproducible output across multiple function calls.<br>See :term:`Glossary &lt;random_state&gt;`.</span>
            </a>
        </td>
                <td class="value">None</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('max_iter',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-max_iter;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=max_iter,-int%2C%20default%3D1000">
                max_iter
                <span class="param-doc-description"
                style="position-anchor: --doc-link-max_iter;">
                max_iter: int, default=1000<br><br>The maximum number of iterations to be run.</span>
            </a>
        </td>
                <td class="value">1000</td>
            </tr>
    
                      </tbody>
                    </table>
                </details>
            </div>
    
            <div class="estimator-table">
                <details>
                    <summary>Fitted attributes</summary>
                    <table class="parameters-table">
                        <tbody>
                            <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Value</th>
                            </tr>
                        
           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-classes_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=classes_,-ndarray%20of%20shape%20%28n_classes%2C%29">
                classes_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-classes_;">
                classes_: ndarray of shape (n_classes,)<br><br>The unique classes labels.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[int64](2,)</td>
               <td>[0,1]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-coef_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=coef_,-ndarray%20of%20shape%20%281%2C%20n_features%29%20if%20n_classes%20%3D%3D%202%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%28n_classes%2C%20n_features%29">
                coef_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-coef_;">
                coef_: ndarray of shape (1, n_features) if n_classes == 2             else (n_classes, n_features)<br><br>Weights assigned to the features (coefficients in the primal<br>problem).<br><br>``coef_`` is a readonly property derived from ``raw_coef_`` that<br>follows the internal memory layout of liblinear.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](1, 3)</td>
               <td>[[0.76,0.27,0.26]]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-intercept_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=intercept_,-ndarray%20of%20shape%20%281%2C%29%20if%20n_classes%20%3D%3D%202%20else%20%28n_classes%2C%29">
                intercept_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-intercept_;">
                intercept_: ndarray of shape (1,) if n_classes == 2 else (n_classes,)<br><br>Constants in decision function.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](1,)</td>
               <td>[-0.06]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_features_in_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=n_features_in_,-int">
                n_features_in_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_features_in_;">
                n_features_in_: int<br><br>Number of features seen during :term:`fit`.<br><br>.. versionadded:: 0.24</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>3</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_iter_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=n_iter_,-int">
                n_iter_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_iter_;">
                n_iter_: int<br><br>Maximum number of iterations run across all classes.</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>5</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div></div></div></div></div><script>/*  Authors: The scikit-learn developers
     SPDX-License-Identifier: BSD-3-Clause
    */

    function copyToClipboard(text, element) {
        // Get the parameter prefix from the closest toggleable content
        const toggleableContent = element.closest('.sk-toggleable__content');
        const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';
        const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text;

        const originalStyle = element.style;
        const computedStyle = window.getComputedStyle(element);
        const originalWidth = computedStyle.width;
        const originalHTML = element.innerHTML.replace('Copied!', '');

        navigator.clipboard.writeText(fullParamName)
            .then(() => {
                element.style.width = originalWidth;
                element.style.color = 'green';
                element.innerHTML = "Copied!";

                setTimeout(() => {
                    element.innerHTML = originalHTML;
                    element.style = originalStyle;
                }, 2000);
            })
            .catch(err => {
                console.error('Failed to copy:', err);
                element.style.color = 'red';
                element.innerHTML = "Failed!";
                setTimeout(() => {
                    element.innerHTML = originalHTML;
                    element.style = originalStyle;
                }, 2000);
            });
        return false;
    }

    document.querySelectorAll('.copy-paste-icon').forEach(function(element) {
        const toggleableContent = element.closest('.sk-toggleable__content');
        const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';

        const parent = element.parentElement;
        if (!parent || !parent.nextElementSibling) {
            console.warn('Expected copy-paste icon is missing from the DOM structure');
            return;
        }

        const paramName = element.parentElement.nextElementSibling
            .textContent.trim().split(' ')[0];
        const fullParamName = paramPrefix ? `${paramPrefix}${paramName}` : paramName;

        element.setAttribute('title', fullParamName);
    });

    /**
     * Copy the list of feature names formatted as a Python list.
     *
     * @param {HTMLElement} element - The copy button inside a `.features` block; its siblings
     *   contain a `details` element and a table containing feature named.
     * @returns {boolean} Always returns `false` so callers can prevent the default click behavior.
     */
    function copyFeatureNamesToClipboard(element) {
        var detailsElem = element.closest('.features').querySelector('details');
        var wasOpen = detailsElem.open;
        detailsElem.open = true;
        var content = element.closest('.features').querySelector('tbody')
                      .innerText.trim();
        if (!wasOpen) detailsElem.open = false;
        const rows = content.split('\n').map(row => `    "${row}"`);
        const formattedText = `[\n${rows.join(',\n')},\n]`;
        const originalHTML = element.innerHTML.replace('✔', '');
        const originalStyle = element.style;
        const copyMark = document.createElement('span');
        copyMark.innerHTML = '✔';
        copyMark.style.color = 'blue';
        copyMark.style.fontSize = '1em';

        navigator.clipboard.writeText(formattedText)
            .then(() => {
                element.style.display = 'none';
                element.parentElement.appendChild(copyMark);

                setTimeout(() => {
                    copyMark.remove();
                    element.innerHTML = originalHTML;
                    element.style = originalStyle;
                }, 1000);
            })
            .catch(err => {
                console.error('Failed to copy:', err);
                element.style.color = 'orange';
                element.innerHTML = "Failed!";
                setTimeout(() => {
                    element.innerHTML = originalHTML;
                    element.style = originalStyle;
                }, 1000);
            });
        return false;
    }
    /**
     * Adapted from Skrub
     * https://github.com/skrub-data/skrub/blob/403466d1d5d4dc76a7ef569b3f8228db59a31dc3/skrub/_reporting/_data/templates/report.js#L789
     * @returns "light" or "dark"
     */
    function detectTheme(element) {
        const body = document.querySelector('body');

        // Check VSCode theme
        const themeKindAttr = body.getAttribute('data-vscode-theme-kind');
        const themeNameAttr = body.getAttribute('data-vscode-theme-name');

        if (themeKindAttr && themeNameAttr) {
            const themeKind = themeKindAttr.toLowerCase();
            const themeName = themeNameAttr.toLowerCase();

            if (themeKind.includes("dark") || themeName.includes("dark")) {
                return "dark";
            }
            if (themeKind.includes("light") || themeName.includes("light")) {
                return "light";
            }
        }

        // Check Jupyter theme
        if (body.getAttribute('data-jp-theme-light') === 'false') {
            return 'dark';
        } else if (body.getAttribute('data-jp-theme-light') === 'true') {
            return 'light';
        }

        // Guess based on a parent element's color
        const color = window.getComputedStyle(element.parentNode, null).getPropertyValue('color');
        const match = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i);
        if (match) {
            const [r, g, b] = [
                parseFloat(match[1]),
                parseFloat(match[2]),
                parseFloat(match[3])
            ];

            // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
            const luma = 0.299 * r + 0.587 * g + 0.114 * b;

            if (luma > 180) {
                // If the text is very bright we have a dark theme
                return 'dark';
            }
            if (luma < 75) {
                // If the text is very dark we have a light theme
                return 'light';
            }
            // Otherwise fall back to the next heuristic.
        }

        // Fallback to system preference
        return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    }


    function forceTheme(elementId) {
        const estimatorElement = document.querySelector(`#${elementId}`);
        if (estimatorElement === null) {
            console.error(`Element with id ${elementId} not found.`);
        } else {
            const theme = detectTheme(estimatorElement);
            estimatorElement.classList.add(theme);
        }
    }

    forceTheme('sk-container-id-22');</script></body>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 57-63

Once the training is complete, we can predict on new unseen samples. In this
case, the feature selector will only select the most discriminative features
based on the information stored during training. Then, the data will be
passed to the classifier which will make the prediction.

Here, we show the final metrics via a classification report.

.. GENERATED FROM PYTHON SOURCE LINES 63-69

.. code-block:: Python


    from sklearn.metrics import classification_report

    y_pred = anova_svm.predict(X_test)
    print(classification_report(y_test, y_pred))





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

                  precision    recall  f1-score   support

               0       0.92      0.80      0.86        15
               1       0.75      0.90      0.82        10

        accuracy                           0.84        25
       macro avg       0.84      0.85      0.84        25
    weighted avg       0.85      0.84      0.84        25





.. GENERATED FROM PYTHON SOURCE LINES 70-73

Be aware that you can inspect a step in the pipeline. For instance, we might
be interested about the parameters of the classifier. Since we selected
three features, we expect to have three coefficients.

.. GENERATED FROM PYTHON SOURCE LINES 73-76

.. code-block:: Python


    anova_svm[-1].coef_





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    array([[0.75788833, 0.27161955, 0.26113448]])



.. GENERATED FROM PYTHON SOURCE LINES 77-81

However, we do not know which features were selected from the original
dataset. We could proceed by several manners. Here, we will invert the
transformation of these coefficients to get information about the original
space.

.. GENERATED FROM PYTHON SOURCE LINES 81-84

.. code-block:: Python


    anova_svm[:-1].inverse_transform(anova_svm[-1].coef_)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    array([[0.        , 0.        , 0.75788833, 0.        , 0.        ,
            0.        , 0.        , 0.        , 0.        , 0.27161955,
            0.        , 0.        , 0.        , 0.        , 0.        ,
            0.        , 0.        , 0.        , 0.        , 0.26113448]])



.. GENERATED FROM PYTHON SOURCE LINES 85-87

We can see that the features with non-zero coefficients are the selected
features by the first step.


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.026 seconds)


.. _sphx_glr_download_auto_examples_feature_selection_plot_feature_selection_pipeline.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_feature_selection_pipeline.ipynb <plot_feature_selection_pipeline.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_feature_selection_pipeline.py <plot_feature_selection_pipeline.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_feature_selection_pipeline.zip <plot_feature_selection_pipeline.zip>`


.. include:: plot_feature_selection_pipeline.recommendations


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
