
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/compose/plot_compare_reduction.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_compose_plot_compare_reduction.py>`
        to download the full example code.

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

.. _sphx_glr_auto_examples_compose_plot_compare_reduction.py:


=================================================================
Selecting dimensionality reduction with Pipeline and GridSearchCV
=================================================================

This example constructs a pipeline that does dimensionality
reduction followed by prediction with a support vector
classifier. It demonstrates the use of ``GridSearchCV`` and
``Pipeline`` to optimize over different classes of estimators in a
single CV run -- unsupervised ``PCA`` and ``NMF`` dimensionality
reductions are compared to univariate feature selection during
the grid search.

Additionally, ``Pipeline`` can be instantiated with the ``memory``
argument to memoize the transformers within the pipeline, avoiding to fit
again the same transformers over and over.

Note that the use of ``memory`` to enable caching becomes interesting when the
fitting of a transformer is costly.

.. GENERATED FROM PYTHON SOURCE LINES 22-26

.. code-block:: Python


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








.. GENERATED FROM PYTHON SOURCE LINES 27-29

Illustration of ``Pipeline`` and ``GridSearchCV``
##############################################################################

.. GENERATED FROM PYTHON SOURCE LINES 29-71

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    from sklearn.datasets import load_digits
    from sklearn.decomposition import NMF, PCA
    from sklearn.feature_selection import SelectKBest, mutual_info_classif
    from sklearn.model_selection import GridSearchCV
    from sklearn.pipeline import Pipeline
    from sklearn.preprocessing import MinMaxScaler
    from sklearn.svm import LinearSVC

    X, y = load_digits(return_X_y=True)

    pipe = Pipeline(
        [
            ("scaling", MinMaxScaler()),
            # the reduce_dim stage is populated by the param_grid
            ("reduce_dim", "passthrough"),
            ("classify", LinearSVC(dual=False, max_iter=10000)),
        ]
    )

    N_FEATURES_OPTIONS = [2, 4, 8]
    C_OPTIONS = [1, 10, 100, 1000]
    param_grid = [
        {
            "reduce_dim": [PCA(iterated_power=7), NMF(max_iter=1_000)],
            "reduce_dim__n_components": N_FEATURES_OPTIONS,
            "classify__C": C_OPTIONS,
        },
        {
            "reduce_dim": [SelectKBest(mutual_info_classif)],
            "reduce_dim__k": N_FEATURES_OPTIONS,
            "classify__C": C_OPTIONS,
        },
    ]
    reducer_labels = ["PCA", "NMF", "KBest(mutual_info_classif)"]

    grid = GridSearchCV(pipe, n_jobs=1, param_grid=param_grid)
    grid.fit(X, y)






.. 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-44" tabindex="0" class="sk-top-container sk-global"><div class="sk-text-repr-fallback"><pre>GridSearchCV(estimator=Pipeline(steps=[(&#x27;scaling&#x27;, MinMaxScaler()),
                                           (&#x27;reduce_dim&#x27;, &#x27;passthrough&#x27;),
                                           (&#x27;classify&#x27;,
                                            LinearSVC(dual=False,
                                                      max_iter=10000))]),
                 n_jobs=1,
                 param_grid=[{&#x27;classify__C&#x27;: [1, 10, 100, 1000],
                              &#x27;reduce_dim&#x27;: [PCA(iterated_power=7),
                                             NMF(max_iter=1000)],
                              &#x27;reduce_dim__n_components&#x27;: [2, 4, 8]},
                             {&#x27;classify__C&#x27;: [1, 10, 100, 1000],
                              &#x27;reduce_dim&#x27;: [SelectKBest(score_func=&lt;function mutual_info_classif at 0x718b4bd3f8a0&gt;)],
                              &#x27;reduce_dim__k&#x27;: [2, 4, 8]}])</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-147" type="checkbox" ><label for="sk-estimator-id-147" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>GridSearchCV</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html">?<span>Documentation for GridSearchCV</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('estimator',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-estimator;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=estimator,-estimator%20object">
                estimator
                <span class="param-doc-description"
                style="position-anchor: --doc-link-estimator;">
                estimator: estimator object<br><br>This is assumed to implement the scikit-learn estimator interface.<br>Either estimator needs to provide a ``score`` function,<br>or ``scoring`` must be passed.</span>
            </a>
        </td>
                <td class="value">Pipeline(step...iter=10000))])</td>
            </tr>
    

            <tr class="user-set">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('param_grid',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-param_grid;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=param_grid,-dict%20or%20list%20of%20dictionaries">
                param_grid
                <span class="param-doc-description"
                style="position-anchor: --doc-link-param_grid;">
                param_grid: dict or list of dictionaries<br><br>Dictionary with parameters names (`str`) as keys and lists of<br>parameter settings to try as values, or a list of such<br>dictionaries, in which case the grids spanned by each dictionary<br>in the list are explored. This enables searching over any sequence<br>of parameter settings.</span>
            </a>
        </td>
                <td class="value">[{&#x27;classify__C&#x27;: [1, 10, ...], &#x27;reduce_dim&#x27;: [PCA(iterated_power=7), NMF(max_iter=1000)], &#x27;reduce_dim__n_components&#x27;: [2, 4, ...]}, {&#x27;classify__C&#x27;: [1, 10, ...], &#x27;reduce_dim&#x27;: [SelectKBest(s...718b4bd3f8a0&gt;)], &#x27;reduce_dim__k&#x27;: [2, 4, ...]}]</td>
            </tr>
    

            <tr class="user-set">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('n_jobs',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_jobs;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=n_jobs,-int%2C%20default%3DNone">
                n_jobs
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_jobs;">
                n_jobs: int, default=None<br><br>Number of jobs to run in parallel.<br>``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.<br>``-1`` means using all processors. See :term:`Glossary &lt;n_jobs&gt;`<br>for more details.<br><br>.. versionchanged:: v0.20<br>   `n_jobs` default changed from 1 to None</span>
            </a>
        </td>
                <td class="value">1</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('scoring',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-scoring;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=scoring,-str%2C%20callable%2C%20list%2C%20tuple%20or%20dict%2C%20default%3DNone">
                scoring
                <span class="param-doc-description"
                style="position-anchor: --doc-link-scoring;">
                scoring: str, callable, list, tuple or dict, default=None<br><br>Strategy to evaluate the performance of the cross-validated model on<br>the test set.<br><br>If `scoring` represents a single score, one can use:<br><br>- a single string (see :ref:`scoring_string_names`);<br>- a callable (see :ref:`scoring_callable`) that returns a single value;<br>- `None`, the `estimator`&#x27;s<br>  :ref:`default evaluation criterion &lt;scoring_api_overview&gt;` is used.<br><br>If `scoring` represents multiple scores, one can use:<br><br>- a list or tuple of unique strings;<br>- a callable returning a dictionary where the keys are the metric<br>  names and the values are the metric scores;<br>- a dictionary with metric names as keys and callables as values.<br><br>See :ref:`multimetric_grid_search` for an example.</span>
            </a>
        </td>
                <td class="value">None</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('refit',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-refit;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=refit,-bool%2C%20str%2C%20or%20callable%2C%20default%3DTrue">
                refit
                <span class="param-doc-description"
                style="position-anchor: --doc-link-refit;">
                refit: bool, str, or callable, default=True<br><br>Refit an estimator using the best found parameters on the whole<br>dataset.<br><br>For multiple metric evaluation, this needs to be a `str` denoting the<br>scorer that would be used to find the best parameters for refitting<br>the estimator at the end.<br><br>Where there are considerations other than maximum score in<br>choosing a best estimator, ``refit`` can be set to a function which<br>returns the selected ``best_index_`` given ``cv_results_``. In that<br>case, the ``best_estimator_`` and ``best_params_`` will be set<br>according to the returned ``best_index_`` while the ``best_score_``<br>attribute will not be available.<br><br>The refitted estimator is made available at the ``best_estimator_``<br>attribute and permits using ``predict`` directly on this<br>``GridSearchCV`` instance.<br><br>Also for multiple metric evaluation, the attributes ``best_index_``,<br>``best_score_`` and ``best_params_`` will only be available if<br>``refit`` is set and all of them will be determined w.r.t this specific<br>scorer.<br><br>See ``scoring`` parameter to know more about multiple metric<br>evaluation.<br><br>See :ref:`sphx_glr_auto_examples_model_selection_plot_grid_search_digits.py`<br>to see how to design a custom selection strategy using a callable<br>via `refit`.<br><br>See :ref:`this example<br>&lt;sphx_glr_auto_examples_model_selection_plot_grid_search_refit_callable.py&gt;`<br>for an example of how to use ``refit=callable`` to balance model<br>complexity and cross-validated score.<br><br>.. versionchanged:: 0.20<br>    Support for callable added.</span>
            </a>
        </td>
                <td class="value">True</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('cv',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-cv;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=cv,-int%2C%20cross-validation%20generator%20or%20an%20iterable%2C%20default%3DNone">
                cv
                <span class="param-doc-description"
                style="position-anchor: --doc-link-cv;">
                cv: int, cross-validation generator or an iterable, default=None<br><br>Determines the cross-validation splitting strategy.<br>Possible inputs for cv are:<br><br>- None, to use the default 5-fold cross validation,<br>- integer, to specify the number of folds in a `(Stratified)KFold`,<br>- :term:`CV splitter`,<br>- an iterable yielding (train, test) splits as arrays of indices.<br><br>For integer/None inputs, if the estimator is a classifier and ``y`` is<br>either binary or multiclass, :class:`StratifiedKFold` is used. In all<br>other cases, :class:`KFold` is used. These splitters are instantiated<br>with `shuffle=False` so the splits will be the same across calls.<br><br>Refer :ref:`User Guide &lt;cross_validation&gt;` for the various<br>cross-validation strategies that can be used here.<br><br>.. versionchanged:: 0.22<br>    ``cv`` default value if None changed from 3-fold to 5-fold.</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.model_selection.GridSearchCV.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>Controls the verbosity of information printed during fitting, with higher<br>values yielding more detailed logging.<br><br>- 0 : no messages are printed;<br>- &gt;=1 : summary of the total number of fits;<br>- &gt;=2 : computation time for each fold and parameter candidate;<br>- &gt;=3 : fold indices and scores;<br>- &gt;=10 : parameter candidate indices and START messages before each fit.</span>
            </a>
        </td>
                <td class="value">0</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('pre_dispatch',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-pre_dispatch;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=pre_dispatch,-int%2C%20or%20str%2C%20default%3D%272%2An_jobs%27">
                pre_dispatch
                <span class="param-doc-description"
                style="position-anchor: --doc-link-pre_dispatch;">
                pre_dispatch: int, or str, default=&#x27;2*n_jobs&#x27;<br><br>Controls the number of jobs that get dispatched during parallel<br>execution. Reducing this number can be useful to avoid an<br>explosion of memory consumption when more jobs get dispatched<br>than CPUs can process. This parameter can be:<br><br>- None, in which case all the jobs are immediately created and spawned. Use<br>  this for lightweight and fast-running jobs, to avoid delays due to on-demand<br>  spawning of the jobs<br>- An int, giving the exact number of total jobs that are spawned<br>- A str, giving an expression as a function of n_jobs, as in &#x27;2*n_jobs&#x27;</span>
            </a>
        </td>
                <td class="value">&#x27;2*n_jobs&#x27;</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('error_score',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-error_score;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=error_score,-%27raise%27%20or%20numeric%2C%20default%3Dnp.nan">
                error_score
                <span class="param-doc-description"
                style="position-anchor: --doc-link-error_score;">
                error_score: &#x27;raise&#x27; or numeric, default=np.nan<br><br>Value to assign to the score if an error occurs in estimator fitting.<br>If set to &#x27;raise&#x27;, the error is raised. If a numeric value is given,<br>FitFailedWarning is raised. This parameter does not affect the refit<br>step, which will always raise the error.</span>
            </a>
        </td>
                <td class="value">nan</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('return_train_score',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-return_train_score;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=return_train_score,-bool%2C%20default%3DFalse">
                return_train_score
                <span class="param-doc-description"
                style="position-anchor: --doc-link-return_train_score;">
                return_train_score: bool, default=False<br><br>If ``False``, the ``cv_results_`` attribute will not include training<br>scores.<br>Computing training scores is used to get insights on how different<br>parameter settings impact the overfitting/underfitting trade-off.<br>However computing the scores on the training set can be computationally<br>expensive and is not strictly required to select the parameters that<br>yield the best generalization performance.<br><br>.. versionadded:: 0.19<br><br>.. versionchanged:: 0.21<br>    Default value was changed from ``True`` to ``False``</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-best_estimator_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=best_estimator_,-estimator">
                best_estimator_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-best_estimator_;">
                best_estimator_: estimator<br><br>Estimator that was chosen by the search, i.e. estimator<br>which gave highest score (or smallest loss if specified)<br>on the left out data. Not available if ``refit=False``.<br><br>See ``refit`` parameter for more information on allowed values.</span>
            </a>
        </td>
               <td class="fitted-att-type">Pipeline</td>
               <td>Pipeline(step...iter=10000))])</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-best_index_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=best_index_,-int">
                best_index_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-best_index_;">
                best_index_: int<br><br>The index (of the ``cv_results_`` arrays) which corresponds to the best<br>candidate parameter setting.<br><br>The dict at ``search.cv_results_[&#x27;params&#x27;][search.best_index_]`` gives<br>the parameter setting for the best model, that gives the highest<br>mean score (``search.best_score_``).<br><br>For multi-metric evaluation, this is present only if ``refit`` is<br>specified.</span>
            </a>
        </td>
               <td class="fitted-att-type">int64</td>
               <td>np.int64(2)</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-best_params_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=best_params_,-dict">
                best_params_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-best_params_;">
                best_params_: dict<br><br>Parameter setting that gave the best results on the hold out data.<br><br>For multi-metric evaluation, this is present only if ``refit`` is<br>specified.</span>
            </a>
        </td>
               <td class="fitted-att-type">dict</td>
               <td>{&#x27;cl..._C&#x27;: 1, &#x27;re...im&#x27;: PCA(iterated_power=7), &#x27;re...ts&#x27;: 8}</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-best_score_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=best_score_,-float">
                best_score_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-best_score_;">
                best_score_: float<br><br>Mean cross-validated score of the best_estimator<br><br>For multi-metric evaluation, this is present only if ``refit`` is<br>specified.<br><br>This attribute is not available if ``refit`` is a function.</span>
            </a>
        </td>
               <td class="fitted-att-type">float64</td>
               <td>0.8576</td>


           </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.model_selection.GridSearchCV.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. This is present only if ``refit`` is specified and<br>the underlying estimator is a classifier.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[int64](10,)</td>
               <td>[0,1,2,...,7,8,9]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-cv_results_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=cv_results_,-dict%20of%20numpy%20%28masked%29%20ndarrays">
                cv_results_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-cv_results_;">
                cv_results_: dict of numpy (masked) ndarrays<br><br>A dict with keys as column headers and values as columns, that can be<br>imported into a pandas ``DataFrame``.<br><br>For instance the below given table<br><br>+------------+-----------+------------+-----------------+---+---------+<br>|param_kernel|param_gamma|param_degree|split0_test_score|...|rank_t...|<br>+============+===========+============+=================+===+=========+<br>|  &#x27;poly&#x27;    |     --    |      2     |       0.80      |...|    2    |<br>+------------+-----------+------------+-----------------+---+---------+<br>|  &#x27;poly&#x27;    |     --    |      3     |       0.70      |...|    4    |<br>+------------+-----------+------------+-----------------+---+---------+<br>|  &#x27;rbf&#x27;     |     0.1   |     --     |       0.80      |...|    3    |<br>+------------+-----------+------------+-----------------+---+---------+<br>|  &#x27;rbf&#x27;     |     0.2   |     --     |       0.93      |...|    1    |<br>+------------+-----------+------------+-----------------+---+---------+<br><br>will be represented by a ``cv_results_`` dict of::<br><br>    {<br>    &#x27;param_kernel&#x27;: masked_array(data = [&#x27;poly&#x27;, &#x27;poly&#x27;, &#x27;rbf&#x27;, &#x27;rbf&#x27;],<br>                                 mask = [False False False False]...)<br>    &#x27;param_gamma&#x27;: masked_array(data = [-- -- 0.1 0.2],<br>                                mask = [ True  True False False]...),<br>    &#x27;param_degree&#x27;: masked_array(data = [2.0 3.0 -- --],<br>                                 mask = [False False  True  True]...),<br>    &#x27;split0_test_score&#x27;  : [0.80, 0.70, 0.80, 0.93],<br>    &#x27;split1_test_score&#x27;  : [0.82, 0.50, 0.70, 0.78],<br>    &#x27;mean_test_score&#x27;    : [0.81, 0.60, 0.75, 0.85],<br>    &#x27;std_test_score&#x27;     : [0.01, 0.10, 0.05, 0.08],<br>    &#x27;rank_test_score&#x27;    : [2, 4, 3, 1],<br>    &#x27;split0_train_score&#x27; : [0.80, 0.92, 0.70, 0.93],<br>    &#x27;split1_train_score&#x27; : [0.82, 0.55, 0.70, 0.87],<br>    &#x27;mean_train_score&#x27;   : [0.81, 0.74, 0.70, 0.90],<br>    &#x27;std_train_score&#x27;    : [0.01, 0.19, 0.00, 0.03],<br>    &#x27;mean_fit_time&#x27;      : [0.73, 0.63, 0.43, 0.49],<br>    &#x27;std_fit_time&#x27;       : [0.01, 0.02, 0.01, 0.01],<br>    &#x27;mean_score_time&#x27;    : [0.01, 0.06, 0.04, 0.04],<br>    &#x27;std_score_time&#x27;     : [0.00, 0.00, 0.00, 0.01],<br>    &#x27;params&#x27;             : [{&#x27;kernel&#x27;: &#x27;poly&#x27;, &#x27;degree&#x27;: 2}, ...],<br>    }<br><br>For an example of visualization and interpretation of GridSearch results,<br>see :ref:`sphx_glr_auto_examples_model_selection_plot_grid_search_stats.py`.<br><br>NOTE<br><br>The key ``&#x27;params&#x27;`` is used to store a list of parameter<br>settings dicts for all the parameter candidates.<br><br>The ``mean_fit_time``, ``std_fit_time``, ``mean_score_time`` and<br>``std_score_time`` are all in seconds.<br><br>For multi-metric evaluation, the scores for all the scorers are<br>available in the ``cv_results_`` dict at the keys ending with that<br>scorer&#x27;s name (``&#x27;_&lt;scorer_name&gt;&#x27;``) instead of ``&#x27;_score&#x27;`` shown<br>above. (&#x27;split0_test_precision&#x27;, &#x27;mean_train_precision&#x27; etc.)</span>
            </a>
        </td>
               <td class="fitted-att-type">dict</td>
               <td>{&#x27;me...me&#x27;: array([0.01, ..., 0.91, 1.19]), &#x27;me...me&#x27;: array([0.  , ..., 0.  , 0.  ]), &#x27;me...re&#x27;: array([0.52, ..., 0.5 , 0.72]), &#x27;pa..._C&#x27;: masked_array(..._value=999999), ...}</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-multimetric_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=multimetric_,-bool">
                multimetric_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-multimetric_;">
                multimetric_: bool<br><br>Whether or not the scorers compute several metrics.</span>
            </a>
        </td>
               <td class="fitted-att-type">bool</td>
               <td>False</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.model_selection.GridSearchCV.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<br>`best_estimator_` is defined (see the documentation for the `refit`<br>parameter for more details) and that `best_estimator_` exposes<br>`n_features_in_` when fit.<br><br>.. versionadded:: 0.24</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>64</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_splits_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=n_splits_,-int">
                n_splits_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_splits_;">
                n_splits_: int<br><br>The number of cross-validation splits (folds/iterations).</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>5</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-refit_time_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=refit_time_,-float">
                refit_time_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-refit_time_;">
                refit_time_: float<br><br>Seconds used for refitting the best model on the whole dataset.<br><br>This is present only if ``refit`` is not False.<br><br>.. versionadded:: 0.20</span>
            </a>
        </td>
               <td class="fitted-att-type">float</td>
               <td>0.0445</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-scorer_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.model_selection.GridSearchCV.html#:~:text=scorer_,-function%20or%20a%20dict">
                scorer_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-scorer_;">
                scorer_: function or a dict<br><br>Scorer function used on the held out data to choose the best<br>parameters for the model.<br><br>For multi-metric evaluation, this attribute holds the validated<br>``scoring`` dict which maps the scorer key to the scorer callable.</span>
            </a>
        </td>
               <td class="fitted-att-type">_PassthroughScorer</td>
               <td>Pipeline.score</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div><div class="sk-parallel"><div class="sk-parallel-item"><div class="sk-item"><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-148" type="checkbox" ><label for="sk-estimator-id-148" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>best_estimator_: Pipeline</div></div></label><div class="sk-toggleable__content fitted" data-param-prefix="best_estimator___"></div></div></div><div class="sk-serial"><div class="sk-item"><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-149" type="checkbox" ><label for="sk-estimator-id-149" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>MinMaxScaler</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html">?<span>Documentation for MinMaxScaler</span></a></div></label><div class="sk-toggleable__content fitted" data-param-prefix="best_estimator___scaling__">
            <div class="estimator-table">
                <details>
                    <summary>Parameters</summary>
                    <table class="parameters-table">
                      <tbody>
                    
            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('feature_range',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-feature_range;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=feature_range,-tuple%20%28min%2C%20max%29%2C%20default%3D%280%2C%201%29">
                feature_range
                <span class="param-doc-description"
                style="position-anchor: --doc-link-feature_range;">
                feature_range: tuple (min, max), default=(0, 1)<br><br>Desired range of transformed data.</span>
            </a>
        </td>
                <td class="value">(0, ...)</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('copy',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-copy;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=copy,-bool%2C%20default%3DTrue">
                copy
                <span class="param-doc-description"
                style="position-anchor: --doc-link-copy;">
                copy: bool, default=True<br><br>Set to False to perform inplace row normalization and avoid a<br>copy (if the input is already a numpy array).</span>
            </a>
        </td>
                <td class="value">True</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('clip',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-clip;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=clip,-bool%2C%20default%3DFalse">
                clip
                <span class="param-doc-description"
                style="position-anchor: --doc-link-clip;">
                clip: bool, default=False<br><br>Set to True to clip transformed values of held-out data to<br>provided `feature_range`.<br>Since this parameter will clip values, `inverse_transform` may not<br>be able to restore the original data.<br><br>.. note::<br>    Setting `clip=True` does not prevent feature drift (a distribution<br>    shift between training and test data). The transformed values are clipped<br>    to the `feature_range`, which helps avoid unintended behavior in models<br>    sensitive to out-of-range inputs (e.g. linear models). Use with care,<br>    as clipping can distort the distribution of test data.<br><br>.. versionadded:: 0.24</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-data_max_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=data_max_,-ndarray%20of%20shape%20%28n_features%2C%29">
                data_max_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-data_max_;">
                data_max_: ndarray of shape (n_features,)<br><br>Per feature maximum seen in the data<br><br>.. versionadded:: 0.17<br>   *data_max_*</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[ 0., 8.,16.,...,16.,16.,16.]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-data_min_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=data_min_,-ndarray%20of%20shape%20%28n_features%2C%29">
                data_min_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-data_min_;">
                data_min_: ndarray of shape (n_features,)<br><br>Per feature minimum seen in the data<br><br>.. versionadded:: 0.17<br>   *data_min_*</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[0.,0.,0.,...,0.,0.,0.]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-data_range_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=data_range_,-ndarray%20of%20shape%20%28n_features%2C%29">
                data_range_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-data_range_;">
                data_range_: ndarray of shape (n_features,)<br><br>Per feature range ``(data_max_ - data_min_)`` seen in the data<br><br>.. versionadded:: 0.17<br>   *data_range_*</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[ 0., 8.,16.,...,16.,16.,16.]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-min_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=min_,-ndarray%20of%20shape%20%28n_features%2C%29">
                min_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-min_;">
                min_: ndarray of shape (n_features,)<br><br>Per feature adjustment for minimum. Equivalent to<br>``min - X.min(axis=0) * self.scale_``</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[0.,0.,0.,...,0.,0.,0.]</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.preprocessing.MinMaxScaler.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>64</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_samples_seen_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=n_samples_seen_,-int">
                n_samples_seen_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_samples_seen_;">
                n_samples_seen_: int<br><br>The number of samples processed by the estimator.<br>It will be reset on new calls to fit, but increments across<br>``partial_fit`` calls.</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>1797</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-scale_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.preprocessing.MinMaxScaler.html#:~:text=scale_,-ndarray%20of%20shape%20%28n_features%2C%29">
                scale_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-scale_;">
                scale_: ndarray of shape (n_features,)<br><br>Per feature relative scaling of the data. Equivalent to<br>``(max - min) / (X.max(axis=0) - X.min(axis=0))``<br><br>.. versionadded:: 0.17<br>   *scale_* attribute.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[1.  ,0.12,0.06,...,0.06,0.06,0.06]</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div>
            <div class="features fitted">
              <details>
                <summary>
                  <div class="arrow"></div>
                  <div>64 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>x0</td>
            </tr>

    
            <tr>
              <td>x1</td>
            </tr>

    
            <tr>
              <td>x2</td>
            </tr>

    
            <tr>
              <td>x3</td>
            </tr>

    
            <tr>
              <td>x4</td>
            </tr>

    
            <tr>
              <td>x5</td>
            </tr>

    
            <tr>
              <td>x6</td>
            </tr>

    
            <tr>
              <td>x7</td>
            </tr>

    
            <tr>
              <td>x8</td>
            </tr>

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

    
            <tr>
              <td>x10</td>
            </tr>

    
            <tr>
              <td>x11</td>
            </tr>

    
            <tr>
              <td>x12</td>
            </tr>

    
            <tr>
              <td>x13</td>
            </tr>

    
            <tr>
              <td>x14</td>
            </tr>

    
            <tr>
              <td>x15</td>
            </tr>

    
            <tr>
              <td>x16</td>
            </tr>

    
            <tr>
              <td>x17</td>
            </tr>

    
            <tr>
              <td>x18</td>
            </tr>

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

    
            <tr>
              <td>x20</td>
            </tr>

    
            <tr>
              <td>x21</td>
            </tr>

    
            <tr>
              <td>x22</td>
            </tr>

    
            <tr>
              <td>x23</td>
            </tr>

    
            <tr>
              <td>x24</td>
            </tr>

    
            <tr>
              <td>x25</td>
            </tr>

    
            <tr>
              <td>x26</td>
            </tr>

    
            <tr>
              <td>x27</td>
            </tr>

    
            <tr>
              <td>x28</td>
            </tr>

    
            <tr>
              <td>x29</td>
            </tr>

    
            <tr>
              <td>x30</td>
            </tr>

    
            <tr>
              <td>x31</td>
            </tr>

    
            <tr>
              <td>x32</td>
            </tr>

    
            <tr>
              <td>x33</td>
            </tr>

    
            <tr>
              <td>x34</td>
            </tr>

    
            <tr>
              <td>x35</td>
            </tr>

    
            <tr>
              <td>x36</td>
            </tr>

    
            <tr>
              <td>x37</td>
            </tr>

    
            <tr>
              <td>x38</td>
            </tr>

    
            <tr>
              <td>x39</td>
            </tr>

    
            <tr>
              <td>x40</td>
            </tr>

    
            <tr>
              <td>x41</td>
            </tr>

    
            <tr>
              <td>x42</td>
            </tr>

    
            <tr>
              <td>x43</td>
            </tr>

    
            <tr>
              <td>x44</td>
            </tr>

    
            <tr>
              <td>x45</td>
            </tr>

    
            <tr>
              <td>x46</td>
            </tr>

    
            <tr>
              <td>x47</td>
            </tr>

    
            <tr>
              <td>x48</td>
            </tr>

    
            <tr>
              <td>x49</td>
            </tr>

    
            <tr>
              <td>x50</td>
            </tr>

    
            <tr>
              <td>x51</td>
            </tr>

    
            <tr>
              <td>x52</td>
            </tr>

    
            <tr>
              <td>x53</td>
            </tr>

    
            <tr>
              <td>x54</td>
            </tr>

    
            <tr>
              <td>x55</td>
            </tr>

    
            <tr>
              <td>x56</td>
            </tr>

    
            <tr>
              <td>x57</td>
            </tr>

    
            <tr>
              <td>x58</td>
            </tr>

    
            <tr>
              <td>x59</td>
            </tr>

    
            <tr>
              <td>x60</td>
            </tr>

    
            <tr>
              <td>x61</td>
            </tr>

    
            <tr>
              <td>x62</td>
            </tr>

    
            <tr>
              <td>x63</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-150" type="checkbox" ><label for="sk-estimator-id-150" class="sk-toggleable__label fitted sk-toggleable__label-arrow"><div><div>PCA</div></div><div><a class="sk-estimator-doc-link fitted" rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html">?<span>Documentation for PCA</span></a></div></label><div class="sk-toggleable__content fitted" data-param-prefix="best_estimator___reduce_dim__">
            <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('n_components',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_components;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=n_components,-int%2C%20float%20or%20%27mle%27%2C%20default%3DNone">
                n_components
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_components;">
                n_components: int, float or &#x27;mle&#x27;, default=None<br><br>Number of components to keep.<br>if n_components is not set all components are kept::<br><br>    n_components == min(n_samples, n_features)<br><br>If ``n_components == &#x27;mle&#x27;`` and ``svd_solver == &#x27;full&#x27;``, Minka&#x27;s<br>MLE is used to guess the dimension. Use of ``n_components == &#x27;mle&#x27;``<br>will interpret ``svd_solver == &#x27;auto&#x27;`` as ``svd_solver == &#x27;full&#x27;``.<br><br>If ``0 &lt; n_components &lt; 1`` and ``svd_solver == &#x27;full&#x27;``, select the<br>number of components such that the amount of variance that needs to be<br>explained is greater than the percentage specified by n_components.<br><br>If ``svd_solver == &#x27;arpack&#x27;``, the number of components must be<br>strictly less than the minimum of n_features and n_samples.<br><br>Hence, the None case results in::<br><br>    n_components == min(n_samples, n_features) - 1</span>
            </a>
        </td>
                <td class="value">8</td>
            </tr>
    

            <tr class="user-set">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('iterated_power',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-iterated_power;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=iterated_power,-int%20or%20%27auto%27%2C%20default%3D%27auto%27">
                iterated_power
                <span class="param-doc-description"
                style="position-anchor: --doc-link-iterated_power;">
                iterated_power: int or &#x27;auto&#x27;, default=&#x27;auto&#x27;<br><br>Number of iterations for the power method computed by<br>svd_solver == &#x27;randomized&#x27;.<br>Must be of range [0, infinity).<br><br>.. versionadded:: 0.18.0</span>
            </a>
        </td>
                <td class="value">7</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('copy',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-copy;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=copy,-bool%2C%20default%3DTrue">
                copy
                <span class="param-doc-description"
                style="position-anchor: --doc-link-copy;">
                copy: bool, default=True<br><br>If False, data passed to fit are overwritten and running<br>fit(X).transform(X) will not yield the expected results,<br>use fit_transform(X) instead.</span>
            </a>
        </td>
                <td class="value">True</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('whiten',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-whiten;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=whiten,-bool%2C%20default%3DFalse">
                whiten
                <span class="param-doc-description"
                style="position-anchor: --doc-link-whiten;">
                whiten: bool, default=False<br><br>When True (False by default) the `components_` vectors are multiplied<br>by the square root of n_samples and then divided by the singular values<br>to ensure uncorrelated outputs with unit component-wise variances.<br><br>Whitening will remove some information from the transformed signal<br>(the relative variance scales of the components) but can sometime<br>improve the predictive accuracy of the downstream estimators by<br>making their data respect some hard-wired assumptions.</span>
            </a>
        </td>
                <td class="value">False</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('svd_solver',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-svd_solver;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=svd_solver,-%7B%27auto%27%2C%20%27full%27%2C%20%27covariance_eigh%27%2C%20%27arpack%27%2C%20%27randomized%27%7D%2C%20%20%20%20%20%20%20%20%20%20%20%20default%3D%27auto%27">
                svd_solver
                <span class="param-doc-description"
                style="position-anchor: --doc-link-svd_solver;">
                svd_solver: {&#x27;auto&#x27;, &#x27;full&#x27;, &#x27;covariance_eigh&#x27;, &#x27;arpack&#x27;, &#x27;randomized&#x27;},            default=&#x27;auto&#x27;<br><br>&quot;auto&quot; :<br>    The solver is selected by a default &#x27;auto&#x27; policy is based on `X.shape` and<br>    `n_components`: if the input data has fewer than 1000 features and<br>    more than 10 times as many samples, then the &quot;covariance_eigh&quot;<br>    solver is used. Otherwise, if the input data is larger than 500x500<br>    and the number of components to extract is lower than 80% of the<br>    smallest dimension of the data, then the more efficient<br>    &quot;randomized&quot; method is selected. Otherwise the exact &quot;full&quot; SVD is<br>    computed and optionally truncated afterwards.<br>&quot;full&quot; :<br>    Run exact full SVD calling the standard LAPACK solver via<br>    `scipy.linalg.svd` and select the components by postprocessing<br>&quot;covariance_eigh&quot; :<br>    Precompute the covariance matrix (on centered data), run a<br>    classical eigenvalue decomposition on the covariance matrix<br>    typically using LAPACK and select the components by postprocessing.<br>    This solver is very efficient for n_samples &gt;&gt; n_features and small<br>    n_features. It is, however, not tractable otherwise for large<br>    n_features (large memory footprint required to materialize the<br>    covariance matrix). Also note that compared to the &quot;full&quot; solver,<br>    this solver effectively doubles the condition number and is<br>    therefore less numerical stable (e.g. on input data with a large<br>    range of singular values).<br>&quot;arpack&quot; :<br>    Run SVD truncated to `n_components` calling ARPACK solver via<br>    `scipy.sparse.linalg.svds`. It requires strictly<br>    `0 &lt; n_components &lt; min(X.shape)`<br>&quot;randomized&quot; :<br>    Run randomized SVD by the method of Halko et al.<br><br>.. versionadded:: 0.18.0<br><br>.. versionchanged:: 1.5<br>    Added the &#x27;covariance_eigh&#x27; solver.</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.decomposition.PCA.html#:~:text=tol,-float%2C%20default%3D0.0">
                tol
                <span class="param-doc-description"
                style="position-anchor: --doc-link-tol;">
                tol: float, default=0.0<br><br>Tolerance for singular values computed by svd_solver == &#x27;arpack&#x27;.<br>Must be of range [0.0, infinity).<br><br>.. versionadded:: 0.18.0</span>
            </a>
        </td>
                <td class="value">0.0</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('n_oversamples',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_oversamples;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=n_oversamples,-int%2C%20default%3D10">
                n_oversamples
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_oversamples;">
                n_oversamples: int, default=10<br><br>This parameter is only relevant when `svd_solver=&quot;randomized&quot;`.<br>It corresponds to the additional number of random vectors to sample the<br>range of `X` so as to ensure proper conditioning. See<br>:func:`~sklearn.utils.extmath.randomized_svd` for more details.<br><br>.. versionadded:: 1.1</span>
            </a>
        </td>
                <td class="value">10</td>
            </tr>
    

            <tr class="default">
                <td><i class="copy-paste-icon"
                     onclick="copyToClipboard('power_iteration_normalizer',
                              this.parentElement.nextElementSibling)"
                ></i></td>
                <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-power_iteration_normalizer;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=power_iteration_normalizer,-%7B%27auto%27%2C%20%27QR%27%2C%20%27LU%27%2C%20%27none%27%7D%2C%20default%3D%27auto%27">
                power_iteration_normalizer
                <span class="param-doc-description"
                style="position-anchor: --doc-link-power_iteration_normalizer;">
                power_iteration_normalizer: {&#x27;auto&#x27;, &#x27;QR&#x27;, &#x27;LU&#x27;, &#x27;none&#x27;}, default=&#x27;auto&#x27;<br><br>Power iteration normalizer for randomized SVD solver.<br>Not used by ARPACK. See :func:`~sklearn.utils.extmath.randomized_svd`<br>for more details.<br><br>.. versionadded:: 1.1</span>
            </a>
        </td>
                <td class="value">&#x27;auto&#x27;</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.decomposition.PCA.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>Used when the &#x27;arpack&#x27; or &#x27;randomized&#x27; solvers are used. Pass an int<br>for reproducible results across multiple function calls.<br>See :term:`Glossary &lt;random_state&gt;`.<br><br>.. versionadded:: 0.18.0</span>
            </a>
        </td>
                <td class="value">None</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-components_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=components_,-ndarray%20of%20shape%20%28n_components%2C%20n_features%29">
                components_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-components_;">
                components_: ndarray of shape (n_components, n_features)<br><br>Principal axes in feature space, representing the directions of<br>maximum variance in the data. Equivalently, the right singular<br>vectors of the centered input data, parallel to its eigenvectors.<br>The components are sorted by decreasing ``explained_variance_``.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](8, 64)</td>
               <td>[[ 0.  ,-0.04,-0.23,...,-0.08,-0.04,-0.01],
     [ 0.  , 0.02, 0.03,...,-0.17,-0.01, 0.01],
     [ 0.  ,-0.04,-0.12,...,-0.24,-0.17,-0.03],
     ...,
     [ 0.  , 0.02, 0.08,...,-0.16,-0.14,-0.02],
     [ 0.  , 0.01, 0.04,...,-0.08,-0.22,-0.11],
     [ 0.  ,-0.05,-0.21,..., 0.3 , 0.13, 0.01]]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-explained_variance_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=explained_variance_,-ndarray%20of%20shape%20%28n_components%2C%29">
                explained_variance_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-explained_variance_;">
                explained_variance_: ndarray of shape (n_components,)<br><br>The amount of variance explained by each of the selected components.<br>The variance estimation uses `n_samples - 1` degrees of freedom.<br><br>Equal to n_components largest eigenvalues<br>of the covariance matrix of X.<br><br>.. versionadded:: 0.18</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](8,)</td>
               <td>[0.71,0.65,0.56,...,0.23,0.2 ,0.18]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-explained_variance_ratio_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=explained_variance_ratio_,-ndarray%20of%20shape%20%28n_components%2C%29">
                explained_variance_ratio_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-explained_variance_ratio_;">
                explained_variance_ratio_: ndarray of shape (n_components,)<br><br>Percentage of variance explained by each of the selected components.<br><br>If ``n_components`` is not set then all components are stored and the<br>sum of the ratios is equal to 1.0.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](8,)</td>
               <td>[0.15,0.14,0.12,...,0.05,0.04,0.04]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-mean_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=mean_,-ndarray%20of%20shape%20%28n_features%2C%29">
                mean_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-mean_;">
                mean_: ndarray of shape (n_features,)<br><br>Per-feature empirical mean, estimated from the training set.<br><br>Equal to `X.mean(axis=0)`.</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](64,)</td>
               <td>[0.  ,0.04,0.33,...,0.42,0.13,0.02]</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_components_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=n_components_,-int">
                n_components_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_components_;">
                n_components_: int<br><br>The estimated number of components. When n_components is set<br>to &#x27;mle&#x27; or a number between 0 and 1 (with svd_solver == &#x27;full&#x27;) this<br>number is estimated from input data. Otherwise it equals the parameter<br>n_components, or the lesser value of n_features and n_samples<br>if n_components is None.</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>8</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.decomposition.PCA.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>64</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-n_samples_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=n_samples_,-int">
                n_samples_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-n_samples_;">
                n_samples_: int<br><br>Number of samples in the training data.</span>
            </a>
        </td>
               <td class="fitted-att-type">int</td>
               <td>1797</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-noise_variance_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=noise_variance_,-float">
                noise_variance_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-noise_variance_;">
                noise_variance_: float<br><br>The estimated noise covariance following the Probabilistic PCA model<br>from Tipping and Bishop 1999. See &quot;Pattern Recognition and<br>Machine Learning&quot; by C. Bishop, 12.2.1 p. 574 or<br>http://www.miketipping.com/papers/met-mppca.pdf. It is required to<br>compute the estimated data covariance and score samples.<br><br>Equal to the average of (min(n_features, n_samples) - n_components)<br>smallest eigenvalues of the covariance matrix of X.</span>
            </a>
        </td>
               <td class="fitted-att-type">float64</td>
               <td>0.02823</td>


           </tr>
    

           <tr class="default">
               <td class="param">
            <a class="param-doc-link"
                style="anchor-name: --doc-link-singular_values_;"
                rel="noreferrer" target="_blank" href="https://scikit-learn.org/1.9/modules/generated/sklearn.decomposition.PCA.html#:~:text=singular_values_,-ndarray%20of%20shape%20%28n_components%2C%29">
                singular_values_
                <span class="param-doc-description"
                style="position-anchor: --doc-link-singular_values_;">
                singular_values_: ndarray of shape (n_components,)<br><br>The singular values corresponding to each of the selected components.<br>The singular values are equal to the 2-norms of the ``n_components``<br>variables in the lower-dimensional space.<br><br>.. versionadded:: 0.19</span>
            </a>
        </td>
               <td class="fitted-att-type">ndarray[float64](8,)</td>
               <td>[35.64,34.05,31.68,...,20.39,19.09,17.75]</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div>
            <div class="features fitted">
              <details>
                <summary>
                  <div class="arrow"></div>
                  <div>8 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>pca0</td>
            </tr>

    
            <tr>
              <td>pca1</td>
            </tr>

    
            <tr>
              <td>pca2</td>
            </tr>

    
            <tr>
              <td>pca3</td>
            </tr>

    
            <tr>
              <td>pca4</td>
            </tr>

    
            <tr>
              <td>pca5</td>
            </tr>

    
            <tr>
              <td>pca6</td>
            </tr>

    
            <tr>
              <td>pca7</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-151" type="checkbox" ><label for="sk-estimator-id-151" 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="best_estimator___classify__">
            <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('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">False</td>
            </tr>
    

            <tr class="user-set">
                <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">10000</td>
            </tr>
    

            <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('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</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>
    
                      </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](10,)</td>
               <td>[0,1,2,...,7,8,9]</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](10, 8)</td>
               <td>[[ 0.41,-1.87, 0.37,..., 1.09, 0.04, 0.56],
     [ 0.09, 1.02,-0.23,..., 0.78,-0.2 , 0.49],
     [-1.19, 0.56,-1.81,..., 0.5 ,-2.05, 0.98],
     ...,
     [-0.21, 1.09, 1.37,...,-0.65, 0.19,-0.74],
     [-0.22, 0.13,-0.11,..., 0.31, 0.98, 1.17],
     [-0.58,-0.48, 0.7 ,...,-0.05, 0.61, 0.14]]</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](10,)</td>
               <td>[-2.84,-1.82,-3.04,...,-2.35,-1.19,-1.38]</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>8</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>9</td>


           </tr>
    
                        </tbody>
                    </table>
                </details>
            </div>
        </div></div></div></div></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-44');</script></body>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 72-93

.. code-block:: Python

    import pandas as pd

    mean_scores = np.array(grid.cv_results_["mean_test_score"])
    # scores are in the order of param_grid iteration, which is alphabetical
    mean_scores = mean_scores.reshape(len(C_OPTIONS), -1, len(N_FEATURES_OPTIONS))
    # select score for best C
    mean_scores = mean_scores.max(axis=0)
    # create a dataframe to ease plotting
    mean_scores = pd.DataFrame(
        mean_scores.T, index=N_FEATURES_OPTIONS, columns=reducer_labels
    )

    ax = mean_scores.plot.bar()
    ax.set_title("Comparing feature reduction techniques")
    ax.set_xlabel("Reduced number of features")
    ax.set_ylabel("Digit classification accuracy")
    ax.set_ylim((0, 1))
    ax.legend(loc="upper left")

    plt.show()




.. image-sg:: /auto_examples/compose/images/sphx_glr_plot_compare_reduction_001.png
   :alt: Comparing feature reduction techniques
   :srcset: /auto_examples/compose/images/sphx_glr_plot_compare_reduction_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 94-106

Caching transformers within a ``Pipeline``
##########################################

It is sometimes worthwhile storing the state of a specific transformer
since it could be used again. Using a pipeline in ``GridSearchCV`` triggers
such situations. Therefore, we use the argument ``memory`` to enable caching.

.. warning::
    Note that this example is, however, only an illustration since for this
    specific case fitting PCA is not necessarily slower than loading the
    cache. Hence, use the ``memory`` constructor parameter when the fitting
    of a transformer is costly.

.. GENERATED FROM PYTHON SOURCE LINES 106-126

.. code-block:: Python


    from shutil import rmtree

    from joblib import Memory

    # Create a temporary folder to store the transformers of the pipeline
    location = "cachedir"
    memory = Memory(location=location, verbose=10)
    cached_pipe = Pipeline(
        [("reduce_dim", PCA()), ("classify", LinearSVC(dual=False, max_iter=10000))],
        memory=memory,
    )

    # This time, a cached pipeline will be used within the grid search


    # Delete the temporary cache before exiting
    memory.clear(warn=False)
    rmtree(location)








.. GENERATED FROM PYTHON SOURCE LINES 127-133

The ``PCA`` fitting is only computed at the evaluation of the first
configuration of the ``C`` parameter of the ``LinearSVC`` classifier. The
other configurations of ``C`` will trigger the loading of the cached ``PCA``
estimator data, leading to save processing time. Therefore, the use of
caching the pipeline using ``memory`` is highly beneficial when fitting
a transformer is costly.


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

   **Total running time of the script:** (1 minutes 25.797 seconds)


.. _sphx_glr_download_auto_examples_compose_plot_compare_reduction.py:

.. only:: html

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

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

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

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

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

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

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


.. include:: plot_compare_reduction.recommendations


.. only:: html

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

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