§
    qŠtjt  ã                   óÌ   — d dl Z d dlZd dlmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZ d„ Zd„ Z G d„ d¦  «        ZdS )é    N)Úis_classifierÚis_clustererÚis_outlier_detectorÚis_regressor)ÚLabelEncoder)Ú_safe_indexing)Úis_pandas_dfÚis_polars_df)Úcheck_matplotlib_support)Ú_get_response_values)Ú_get_adapter_from_container)ÚPETROFF_COLORS)Útype_of_target)Ú_is_arraylike_not_scalarÚ_num_featuresÚcheck_is_fittedc                 ó¾   — t          | d¦  «        }|r+t          | j        d         ¦  «        rd}t          |¦  «        ‚|dk    rt	          | ¦  «        rd}ng d¢}n|}|S )aQ  Validate the response methods to be used with the fitted estimator.

    Parameters
    ----------
    estimator : object
        Fitted estimator to check.

    response_method : {'auto', 'decision_function', 'predict_proba', 'predict'}
        Specifies whether to use :term:`decision_function`, :term:`predict_proba`,
        :term:`predict` as the target response. If set to 'auto', the response method is
        tried in the before mentioned order.

    Returns
    -------
    prediction_method : list of str or str
        The name or list of names of the response methods to use.
    Úclasses_r   zFMulti-label and multi-output multi-class classifiers are not supportedÚautoÚpredict)Údecision_functionÚpredict_probar   )Úhasattrr   r   Ú
ValueErrorr   )Ú	estimatorÚresponse_methodÚhas_classesÚmsgÚprediction_methods        úh/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/inspection/_plot/decision_boundary.pyÚ_check_boundary_response_methodr!      s„   € õ$ ˜) ZÑ0Ô0€KØð Õ/°	Ô0BÀ1Ô0EÑFÔFð ØVˆÝ˜‰oŒoÐà˜&Ò Ð Ý˜	Ñ"Ô"ð 	RØ )ÐÐà QÐ QÐ QÐÐà+ÐàÐó    c           	      óÂ  ‡ — |€|dk    rt           d|…         }nd}t          |t          ¦  «        r�|‰ j                             ¦   «         vrt          d|› �¦  «        ‚‰ j                             |¦  «        }|j        |k     rt          d|› d|j        › d|› d�¦  «        ‚ |t          j	        d	d
|¦  «        ¦  «        S t          |t          ¦  «        r}t          |¦  «        |k    r#t          d|› dt          |¦  «        › d�¦  «        ‚t          ˆ fd„|D ¦   «         ¦  «        rt          d|› �¦  «        ‚‰ j                             |¦  «        S t          d¦  «        ‚)av  Select colors for multiclass decision boundary display.

    Parameters
    ----------
    mpl : module
        Imported `matplotlib` module.

    multiclass_colors : str or list of matplotlib colors, default=None
        The colormap or colors to select.

        Possible inputs are:

        * None: defaults to list of accessible `Petroff colors
          <https://github.com/matplotlib/matplotlib/issues/9460#issuecomment-875185352>`_
          if `n_classes <= 10`, otherwise 'gist_rainbow' colormap
        * str: name of :class:`matplotlib.colors.Colormap`
        * list: list of length `n_classes` of `matplotlib colors
          <https://matplotlib.org/stable/users/explain/colors/colors.html#colors-def>`_

    n_classes : int
        Number of colors to select.

    Returns
    -------
    colors : ndarray of shape (n_classes, 4)
        RGBA colors, one per class.

    Né
   Úgist_rainbowzSWhen 'multiclass_colors' is a string, it must be a valid Matplotlib colormap. Got: z
Colormap 'z' only has z colors, but zv classes are to be displayed. Please specify a different colormap or provide a list of colors via 'multiclass_colors'.r   é   zdWhen 'multiclass_colors' is a list, it must be of the same length as the classes or labels to plot (z), got: ú.c              3   óN   •K  — | ]}‰j                              |¦  «         V — Œ d S ©N)ÚcolorsÚis_color_like)Ú.0ÚcolÚmpls     €r    ú	<genexpr>z!_select_colors.<locals>.<genexpr>x   s6   øè è € ÐPÐP°s�S”Z×-Ò-¨cÑ2Ô2Ð2ÐPÐPÐPÐPÐPÐPr"   z[When 'multiclass_colors' is a list, it can only contain valid Matplotlib color names. Got: z,'multiclass_colors' must be a list or a str.)r   Ú
isinstanceÚstrÚpyplotÚ	colormapsr   Úget_cmapÚNÚnpÚlinspaceÚlistÚlenÚanyr*   Úto_rgba_arrayÚ	TypeError)r.   Úmulticlass_colorsÚ	n_classesÚcmaps   `   r    Ú_select_colorsr@   :   së  ø€ ð< Ð ð ˜Š?ˆ?Ý .¨z°	¨zÔ :ÐÐà .ÐåÐ#¥SÑ)Ô)ð HØ C¤J×$8Ò$8Ñ$:Ô$:Ð:Ð:ÝðAØ->ðAð Añô ð ð Œz×"Ò"Ð#4Ñ5Ô5ˆØŒ6�IÒÐÝð'Ð.ð 'ð '¸4¼6ð 'ð 'Øð'ð 'ð 'ñô ð ð ˆt•B”K  1 iÑ0Ô0Ñ1Ô1Ð1å	Ð%¥tÑ	,Ô	,ð HÝÐ Ñ!Ô! YÒ.Ð.Ýð-Ø<Eð-ð -åÐ(Ñ)Ô)ð-ð -ð -ñô ð õ
 ÐPÐPÐPÐPÐ>OÐPÑPÔPÑPÔPð 	ÝðEØ1BðEð Eñô ð ð Œz×'Ò'Ð(9Ñ:Ô:Ð:õ ÐFÑGÔGÐGr"   c                   óV   — e Zd ZdZddddœd„Zdd„Zedddd	dddddd
œ	d„¦   «         ZdS )ÚDecisionBoundaryDisplaya  Decisions boundary visualization.

    It is recommended to use
    :func:`~sklearn.inspection.DecisionBoundaryDisplay.from_estimator`
    to create a :class:`DecisionBoundaryDisplay`. All parameters are stored as
    attributes.

    Read more in the :ref:`User Guide <visualizations>`.

    For a detailed example comparing the decision boundaries of multinomial and
    one-vs-rest logistic regression, please see
    :ref:`sphx_glr_auto_examples_linear_model_plot_logistic_multinomial.py`.

    .. versionadded:: 1.1

    Parameters
    ----------
    xx0 : ndarray of shape (grid_resolution, grid_resolution)
        First output of :func:`meshgrid <numpy.meshgrid>`.

    xx1 : ndarray of shape (grid_resolution, grid_resolution)
        Second output of :func:`meshgrid <numpy.meshgrid>`.

    n_classes : int
        Expected number of unique classes or labels if `response` was generated by a
        :term:`classifier` or a :term:`clusterer`.

        For :term:`outlier detectors`, `n_classes` should be set to 2 by definition
        (inlier or outlier).

        For :term:`regressors`, `n_classes` should also be set to 2 by convention
        (continuous responses are displayed the same way as unthresholded binary
        responses).

        .. versionadded:: 1.9

    response : ndarray of shape (grid_resolution, grid_resolution) or             (grid_resolution, grid_resolution, n_classes)
        Values of the response function.

    multiclass_colors : str or list of matplotlib colors, default=None
        Specifies how to color each class when plotting all classes of
        :term:`multiclass` problems.

        Possible inputs are:

        * None: defaults to list of accessible `Petroff colors
          <https://github.com/matplotlib/matplotlib/issues/9460#issuecomment-875185352>`_
          if `n_classes <= 10`, otherwise 'gist_rainbow' colormap
        * str: name of :class:`matplotlib.colors.Colormap`
        * list: list of length `n_classes` of `matplotlib colors
          <https://matplotlib.org/stable/users/explain/colors/colors.html#colors-def>`_

        Single color (fading to white) colormaps will be generated from the colors in
        the list or colors taken from the colormap, and passed to the `cmap` parameter
        of the `plot_method`.

        When `response_method='predict'` and `plot_method='contour'`,
        `multiclass_colors` is ignored and the class boundaries are plotted in black
        instead as the boundary lines may overlap and the colors don't necessarily
        correspond to the classes.

        For :term:`binary` problems, `multiclass_colors` is also ignored and `cmap` or
        `colors` can be passed as kwargs instead, otherwise, the default colormap
        ('viridis') is used.

        .. versionadded:: 1.7
        .. versionchanged:: 1.9
            `multiclass_colors` is now also used when `response_method="predict"`,
            except for when `plot_method='contour'`, where it is ignored and "black" is
            used instead.
            The default colors changed from 'tab10' to the more accessible `Petroff
            colors <https://github.com/matplotlib/matplotlib/issues/9460#issuecomment-875185352>`_.

    xlabel : str, default=None
        Default label to place on x axis.

    ylabel : str, default=None
        Default label to place on y axis.

    Attributes
    ----------
    surface_ : matplotlib `QuadContourSet` or `QuadMesh` or list of such objects
        If `plot_method` is 'contour' or 'contourf', `surface_` is
        :class:`QuadContourSet <matplotlib.contour.QuadContourSet>`. If
        `plot_method` is 'pcolormesh', `surface_` is
        :class:`QuadMesh <matplotlib.collections.QuadMesh>`.

    multiclass_colors_ : array of shape (n_classes, 4)
        Colors used to plot each class in multiclass problems.
        Only defined when `n_classes` > 2.

        .. versionadded:: 1.7

    ax_ : matplotlib Axes
        Axes with decision boundary.

    figure_ : matplotlib Figure
        Figure containing the decision boundary.

    See Also
    --------
    DecisionBoundaryDisplay.from_estimator : Plot decision boundary given an estimator.

    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> import matplotlib as mpl
    >>> import numpy as np
    >>> from sklearn.linear_model import LogisticRegression
    >>> from sklearn.inspection import DecisionBoundaryDisplay
    >>> data = np.array([[0, 0], [1, 1], [2, 1], [2, 2], [3, 2], [3, 3]])
    >>> target = np.arange(data.shape[0])
    >>> clf = LogisticRegression().fit(data, target)
    >>> plot_methods = ["contourf", "contour", "pcolormesh"]
    >>> response_methods = ["predict_proba", "decision_function", "predict"]
    >>> _, axes = plt.subplots(
    ...     nrows=3,
    ...     ncols=3,
    ...     figsize=(12, 12),
    ...     constrained_layout=True
    ... )
    >>> for plot_method_idx, plot_method in enumerate(plot_methods):
    ...     for response_method_idx, response_method in enumerate(response_methods):
    ...         ax = axes[plot_method_idx, response_method_idx]
    ...         display = DecisionBoundaryDisplay.from_estimator(
    ...             clf,
    ...             data,
    ...             grid_resolution=300,
    ...             response_method=response_method,
    ...             plot_method=plot_method,
    ...             ax=ax,
    ...             alpha=0.5,
    ...         )
    ...         cmap = mpl.colors.ListedColormap(display.multiclass_colors_)
    ...         ax.scatter(
    ...             data[:, 0],
    ...             data[:, 1],
    ...             c=target.astype(int),
    ...             edgecolors="black",
    ...             cmap=cmap,
    ...         )
    ...         ax.set_title(
    ...             f"plot_method={plot_method}\nresponse_method={response_method}"
    ...         )
    >>> plt.show()
    N)r=   ÚxlabelÚylabelc                óh   — || _         || _        || _        || _        || _        || _        || _        d S r)   ©Úxx0Úxx1r>   Úresponser=   rC   rD   )ÚselfrG   rH   r>   rI   r=   rC   rD   s           r    Ú__init__z DecisionBoundaryDisplay.__init__  s:   € ð ˆŒØˆŒØ"ˆŒØ ˆŒØ!2ˆÔØˆŒØˆŒˆˆr"   Úcontourfc                 ó¤  ‡— t          d¦  «         ddlŠddlm} |dvrt	          d|› d�¦  «        ‚|€|                     ¦   «         \  }}t          ||¦  «        }| j        dk    r! || j        | j	        | j
        fi |¤Ž| _        �nJdD ]!}	|	|v rt          j        d	|	› d
�¦  «         ||	= Œ"t          ‰| j        | j        ¦  «        | _        d|vrd|d<   | j
        j        dk    �r%ˆfd„t%          | j        ¦  «        D ¦   «         }
g | _        t%          |
¦  «        D ]„\  }}t&          j                             | j
        dd…dd…|f         | j
                             d¬¦  «        |k    ¬¦  «        }| j                              || j        | j	        |fd|i|¤Ž¦  «         Œ…|dk    rc| j                              || j        | j	        | j
                             d¬¦  «        ddt'          j        | j        ¦  «        ¬¦  «        ¦  «         nÇ| j
        j        dk    r·d|vrK|dk    rt'          j        | j        ¦  «        |d<   n(|dk    r"t'          j        | j        dz   ¦  «        dz
  |d<   |dk    r" || j        | j	        | j
        fddi|¤Ž| _        n@‰j                             | j        ¦  «        } || j        | j	        | j
        fd|i|¤Ž| _        |€|                     ¦   «         s |€| j        n|}|                     |¦  «         |€|                     ¦   «         s |€| j        n|}|                      |¦  «         || _!        |j"        | _#        | S )a  Plot visualization.

        Parameters
        ----------
        plot_method : {'contourf', 'contour', 'pcolormesh'}, default='contourf'
            Plotting method to call when plotting the response. Please refer
            to the following matplotlib documentation for details:
            :func:`contourf <matplotlib.pyplot.contourf>`,
            :func:`contour <matplotlib.pyplot.contour>`,
            :func:`pcolormesh <matplotlib.pyplot.pcolormesh>`.

        ax : Matplotlib axes, default=None
            Axes object to plot on. If `None`, a new figure and axes is
            created.

        xlabel : str, default=None
            Overwrite the x-axis label.

        ylabel : str, default=None
            Overwrite the y-axis label.

        **kwargs : dict
            Additional keyword arguments to be passed to the `plot_method`. For
            :term:`binary` problems, `cmap` or `colors` can be set here to specify the
            colormap or colors, otherwise the default colormap ('viridis') is used. If
            not specified by the user, `zorder` is set to -1 to ensure that the decision
            boundary is plotted in the background (in case a scatter plot is added on
            top).

        Returns
        -------
        display: :class:`~sklearn.inspection.DecisionBoundaryDisplay`
            Object that stores computed values.

        See Also
        --------
        DecisionBoundaryDisplay.from_estimator : Plot decision boundary given an
            estimator.

        Examples
        --------
        >>> import matplotlib as mpl
        >>> import matplotlib.pyplot as plt
        >>> import numpy as np
        >>> from sklearn.datasets import load_iris
        >>> from sklearn.inspection import DecisionBoundaryDisplay
        >>> from sklearn.tree import DecisionTreeClassifier
        >>> iris = load_iris()
        >>> feature_1, feature_2 = np.meshgrid(
        ...     np.linspace(iris.data[:, 0].min(), iris.data[:, 0].max()),
        ...     np.linspace(iris.data[:, 1].min(), iris.data[:, 1].max())
        ... )
        >>> grid = np.vstack([feature_1.ravel(), feature_2.ravel()]).T
        >>> tree = DecisionTreeClassifier().fit(iris.data[:, :2], iris.target)
        >>> y_pred = np.reshape(tree.predict(grid), feature_1.shape)
        >>> display = DecisionBoundaryDisplay(
        ...     xx0=feature_1,
        ...     xx1=feature_2,
        ...     n_classes=len(tree.classes_),
        ...     response=y_pred
        ... )
        >>> display.plot()
        <...>
        >>> display.ax_.scatter(
        ...     iris.data[:, 0],
        ...     iris.data[:, 1],
        ...     c=iris.target,
        ...     cmap=mpl.colors.ListedColormap(display.multiclass_colors_),
        ...     edgecolor="black"
        ... )
        <...>
        >>> plt.show()
        zDecisionBoundaryDisplay.plotr   N©rL   ÚcontourÚ
pcolormeshz@plot_method must be 'contourf', 'contour', or 'pcolormesh'. Got ú	 instead.é   )r?   r*   ú'zD' is ignored in favor of 'multiclass_colors' in the multiclass case.Úzorderéÿÿÿÿé   c           
      ór   •— g | ]3\  }\  }}}}‰j         j                             d |› �d|||dfg¦  «        ‘Œ4S )Ú	colormap_)ç      ð?rY   rY   rY   rY   )r*   ÚLinearSegmentedColormapÚ	from_list)r,   Ú	class_idxÚrÚgÚbÚ_r.   s         €r    ú
<listcomp>z0DecisionBoundaryDisplay.plot.<locals>.<listcomp>™  sg   ø€ ð $ð $ð $ñ
 0˜	¡< A q¨!¨Qð	 ”JÔ6×@Ò@Ø/ IÐ/Ð/Ø-°°1°a¸¨~Ð>ñô ð$ð $ð $r"   ©Úaxis)Úmaskr?   rO   Úblack)r*   rT   Úlevelsrf   rL   r&   g      à?r*   )$r   Ú
matplotlibÚmatplotlib.pyplotr2   r   ÚsubplotsÚgetattrr>   rG   rH   rI   Úsurface_ÚwarningsÚwarnr@   r=   Úmulticlass_colors_ÚndimÚ	enumerater6   ÚmaÚarrayÚargmaxÚappendÚaranger*   ÚListedColormapÚ
get_xlabelrC   Ú
set_xlabelÚ
get_ylabelrD   Ú
set_ylabelÚax_ÚfigureÚfigure_)rJ   Úplot_methodÚaxrC   rD   ÚkwargsÚpltr`   Ú	plot_funcÚkwargÚmulticlass_cmapsr\   r?   rI   r.   s                 @r    ÚplotzDecisionBoundaryDisplay.plot+  s*  ø€ õT 	!Ð!?Ñ@Ô@Ð@Ø Ð Ð Ð Ø'Ð'Ð'Ð'Ð'Ð'àÐCÐCÐCÝð.Ø"ð.ð .ð .ñô ð ð
 ˆ:Ø—L’L‘N”N‰EˆAˆrå˜B Ñ,Ô,ˆ	ØŒ>˜QÒÐØ%˜I d¤h°´¸$¼-ÐRÐRÈ6ÐRÐRˆDŒM‰Mà+ð &ð &�Ø˜F�?�?Ý”Mð2˜Eð 2ð 2ð 2ñô ð ð ˜u˜øå&4Ø�TÔ+¨T¬^ñ'ô 'ˆDÔ#ð ˜vÐ%Ð%Ø#%��xÑ àŒ}Ô! QÒ&Ñ&ð$ð $ð $ð $õ
 4=¸TÔ=TÑ3UÔ3Uð$ñ $ô $Ð ð !#�”Ý'0Ð1AÑ'BÔ'Bð ð ‘O�I˜tÝ!œuŸ{š{Øœ a a a¨¨¨¨I oÔ6Ø"œm×2Ò2¸Ð2Ñ:Ô:¸iÒGð  +ñ  ô  �Hð ”M×(Ò(Ø!˜	 $¤(¨D¬H°hÐTÐTÀTÐTÈVÐTÐTñô ð ð ð  )Ò+Ð+à”M×(Ò(Ø!˜	Ø œHØ œHØ œM×0Ò0°aÐ0Ñ8Ô8Ø#*Ø#%å#%¤9¨T¬^Ñ#<Ô#<ðñ ô ñ
ô 
ð 
øð ”Ô# qÒ(Ð(à 6Ð)Ð)Ø" iÒ/Ð/Ý+-¬9°T´^Ñ+DÔ+D˜˜xÑ(Ð(Ø$¨
Ò2Ð2Ý+-¬9°T´^ÀaÑ5GÑ+HÔ+HÈ3Ñ+N˜˜xÑ(à )Ò+Ð+Ø$- IØœ $¤(¨D¬Mð%ð %ØBIð%ØMSð%ð %�D”M�Mð
 œ:×4Ò4°TÔ5LÑMÔM�DØ$- IØœ $¤(¨D¬Mð%ð %Ø@Dð%ØHNð%ð %�D”Mð Ð R§]¢]¡_¤_ÐØ$* N�T”[�[¸ˆFØ�MŠM˜&Ñ!Ô!Ð!ØÐ R§]¢]¡_¤_ÐØ$* N�T”[�[¸ˆFØ�MŠM˜&Ñ!Ô!Ð!àˆŒØ”yˆŒØˆr"   éd   rY   r   )	Úgrid_resolutionÚepsr~   r   Úclass_of_interestr=   rC   rD   r   c       	   	      óä  — t          |¦  «         |dk    st          d|› d�¦  «        ‚|dk    st          d|› d�¦  «        ‚d}||vr+d                     |¦  «        }t          d|› d	|› d�¦  «        ‚t          |¦  «        }|d
k    rt          d|› d�¦  «        ‚t	          |dd¬¦  «        t	          |dd¬¦  «        }}|                     ¦   «         |z
  |                     ¦   «         |z   }}|                     ¦   «         |z
  |                     ¦   «         |z   }}t          j        t          j	        |||¦  «        t          j	        |||¦  «        ¦  «        \  }}t          j
        |                     ¦   «         |                     ¦   «         f         }t          |¦  «        st          |¦  «        r,t          |¦  «        }|                     |||j        ¬¦  «        }t#          ||¦  «        }|�3t%          |d¦  «        r#||j        vrt          d|› d|j        › �¦  «        ‚t)          ||||d¬¦  «        \  }}}|dk    r?t%          |d¦  «        r/t+          ¦   «         }|j        |_        |                     |¦  «        }|€t/          |¦  «        st1          |¦  «        rd
}nÕt3          |¦  «        r%t%          |d¦  «        rt5          |j        ¦  «        }n¡t7          |¦  «        r7t%          |d¦  «        r't5          t          j        |j        ¦  «        ¦  «        }n[t=          |¦  «        } | dv rd
}nE| dk    r"t5          t          j        |¦  «        ¦  «        }nt          d|j        j         › d�¦  «        ‚|j!        dk    r |j"        |j#        Ž }n|t/          |¦  «        rt          d¦  «        ‚|�=t          j$        |j        |k    ¦  «        d         }! |dd…|!f         j"        |j#        Ž }n |j"        g |j#        ¢|j#        d         ‘R Ž }|	€t%          |d¦  «        r|j        d         nd}	|
€t%          |d¦  «        r|j        d         nd}
 | ||||||	|
¬¦  «        }" |"j%        d ||dœ|¤ŽS )!a.  Plot decision boundary given an estimator.

        Read more in the :ref:`User Guide <visualizations>`.

        Parameters
        ----------
        estimator : object
            Trained estimator used to plot the decision boundary.

        X : {array-like, sparse matrix, dataframe} of shape (n_samples, 2)
            Input data that should be only 2-dimensional.

        grid_resolution : int, default=100
            Number of grid points to use for plotting decision boundary.
            Higher values will make the plot look nicer but be slower to
            render.

        eps : float, default=1.0
            Extends the minimum and maximum values of X for evaluating the
            response function.

        plot_method : {'contourf', 'contour', 'pcolormesh'}, default='contourf'
            Plotting method to call when plotting the response. Please refer
            to the following matplotlib documentation for details:
            :func:`contourf <matplotlib.pyplot.contourf>`,
            :func:`contour <matplotlib.pyplot.contour>`,
            :func:`pcolormesh <matplotlib.pyplot.pcolormesh>`.

        response_method : {'auto', 'decision_function', 'predict_proba',                 'predict'}, default='auto'
            Specifies whether to use :term:`decision_function`,
            :term:`predict_proba` or :term:`predict` as the target response.
            If set to 'auto', the response method is tried in the order as
            listed above.

            .. versionchanged:: 1.6
                For multiclass problems, 'auto' no longer defaults to 'predict'.

        class_of_interest : int, float, bool or str, default=None
            The class to be plotted. For :term:`binary` classifiers, if None,
            `estimator.classes_[1]` is considered the positive class. For
            :term:`multiclass` classifiers, if None, all classes will be represented in
            the decision boundary plot; when `response_method` is :term:`predict_proba`
            or :term:`decision_function`, the class with the highest response value
            at each point is plotted. The color of each class can be set via
            `multiclass_colors`.

            .. versionadded:: 1.4

        multiclass_colors : str or list of matplotlib colors, default=None
            Specifies how to color each class when plotting :term:`multiclass` problems
            and `class_of_interest` is None.

            Possible inputs are:

            * None: defaults to list of accessible `Petroff colors
              <https://github.com/matplotlib/matplotlib/issues/9460#issuecomment-875185352>`_
              if `n_classes <= 10`, otherwise 'gist_rainbow' colormap
            * str: name of :class:`matplotlib.colors.Colormap`
            * list: list of length `n_classes` of `matplotlib colors
              <https://matplotlib.org/stable/users/explain/colors/colors.html#colors-def>`_

            Single color (fading to white) colormaps will be generated from the colors
            in the list or colors taken from the colormap, and passed to the `cmap`
            parameter of the `plot_method`.

            When `response_method='predict'` and `plot_method='contour'`,
            `multiclass_colors` is ignored and the class boundaries are plotted in black
            instead as the boundary lines may overlap and the colors don't necessarily
            correspond to the classes.

            For :term:`binary` problems, `multiclass_colors` is also ignored and `cmap`
            or `colors` can be passed as kwargs instead, otherwise, the default colormap
            ('viridis') is used.

            .. versionadded:: 1.7
            .. versionchanged:: 1.9
                `multiclass_colors` is now also used when `response_method="predict"`,
                except for when `plot_method='contour'`, where it is ignored and "black"
                is used instead.
                The default colors changed from 'tab10' to the more accessible `Petroff
                colors <https://github.com/matplotlib/matplotlib/issues/9460#issuecomment-875185352>`_.

        xlabel : str, default=None
            The label used for the x-axis. If `None`, an attempt is made to
            extract a label from `X` if it is a dataframe, otherwise an empty
            string is used.

        ylabel : str, default=None
            The label used for the y-axis. If `None`, an attempt is made to
            extract a label from `X` if it is a dataframe, otherwise an empty
            string is used.

        ax : Matplotlib axes, default=None
            Axes object to plot on. If `None`, a new figure and axes is
            created.

        **kwargs : dict
            Additional keyword arguments to be passed to the `plot_method`.

        Returns
        -------
        display : :class:`~sklearn.inspection.DecisionBoundaryDisplay`
            Object that stores the result.

        See Also
        --------
        DecisionBoundaryDisplay : Decision boundary visualization.
        sklearn.metrics.ConfusionMatrixDisplay.from_estimator : Plot the
            confusion matrix given an estimator, the data, and the label.
        sklearn.metrics.ConfusionMatrixDisplay.from_predictions : Plot the
            confusion matrix given the true and predicted labels.

        Examples
        --------
        >>> import matplotlib as mpl
        >>> import matplotlib.pyplot as plt
        >>> from sklearn.datasets import load_iris
        >>> from sklearn.linear_model import LogisticRegression
        >>> from sklearn.inspection import DecisionBoundaryDisplay
        >>> iris = load_iris()
        >>> X = iris.data[:, :2]
        >>> classifier = LogisticRegression().fit(X, iris.target)
        >>> disp = DecisionBoundaryDisplay.from_estimator(
        ...     classifier, X, response_method="predict",
        ...     xlabel=iris.feature_names[0], ylabel=iris.feature_names[1],
        ...     alpha=0.5,
        ... )
        >>> cmap = mpl.colors.ListedColormap(disp.multiclass_colors_)
        >>> disp.ax_.scatter(X[:, 0], X[:, 1], c=iris.target, edgecolor="k", cmap=cmap)
        <...>
        >>> plt.show()
        r&   z,grid_resolution must be greater than 1. Got rQ   r   z,eps must be greater than or equal to 0. Got rN   z, zplot_method must be one of z. Got rR   z#n_features must be equal to 2. Got rb   )ÚcolumnsNr   zclass_of_interest=z+ is not a valid label: It should be one of T)r   Ú	pos_labelÚreturn_response_method_usedr   Úlabels_)ÚbinaryÚ
continuousÚ
multiclassz4Number of classes or labels cannot be inferred from z¬. Please make sure your estimator follows scikit-learn's estimator API as described here: https://scikit-learn.org/stable/developers/develop.html#rolling-your-own-estimatorz)Multi-output regressors are not supportedrU   r‹   Ú rF   )r   r~   © )&r   r   Újoinr   r   ÚminÚmaxr6   Úmeshgridr7   Úc_Úravelr	   r
   r   Úcreate_containerr‹   r!   r   r   r   r   Ú	transformr   r   r   r9   r   ÚuniquerŽ   r   Ú	__class__Ú__name__ro   ÚreshapeÚshapeÚflatnonzeror…   )#Úclsr   ÚXr‡   rˆ   r~   r   r‰   r=   rC   rD   r   r€   Úpossible_plot_methodsÚavailable_methodsÚnum_featuresÚx0Úx1Úx0_minÚx0_maxÚx1_minÚx1_maxrG   rH   ÚX_gridÚadapterr   rI   r`   Úresponse_method_usedÚencoderr>   Útarget_typeÚcol_idxÚdisplays#                                      r    Úfrom_estimatorz&DecisionBoundaryDisplay.from_estimatorÖ  sN  € õl 	˜	Ñ"Ô"Ð"à Ò"Ð"Ýð/Ø#ð/ð /ð /ñô ð ð
 �aŠxˆxÝØM¸sÐMÐMÐMñô ð ð !FÐØÐ3Ð3Ð3Ø $§	¢	Ð*?Ñ @Ô @ÐÝð.Ð.?ð .ð .Ø"ð.ð .ð .ñô ð õ
 % QÑ'Ô'ˆØ˜1ÒÐÝØM°lÐMÐMÐMñô ð õ    1¨1Ð-Ñ-Ô-­~¸aÀÈÐ/KÑ/KÔ/KˆBˆàŸš™œ C™¨¯ª©¬°C©�ˆØŸš™œ C™¨¯ª©¬°C©�ˆå”;ÝŒK˜ ¨Ñ8Ô8ÝŒK˜ ¨Ñ8Ô8ñ
ô 
‰ˆˆSõ
 ”�s—y’y‘{”{ C§I¢I¡K¤KÐ/Ô0ˆÝ˜‰?Œ?ð 	�l¨1™oœoð 	Ý1°!Ñ4Ô4ˆGØ×-Ò-ØØØœ	ð .ñ ô ˆFõ <¸IÀÑWÔWÐØÐ)­g°iÀÑ.LÔ.LÐ)Ø YÔ%7Ð7Ð7åð9Ð%6ð 9ð 9Ø$-Ô$6ð9ð 9ñô ð õ
 -AØØØ-Ø'Ø(,ð-
ñ -
ô -
Ñ)ˆ�!Ð)ð   9Ò,Ð,µ¸ÀJÑ1OÔ1OÐ,Ý"‘n”nˆGØ(Ô1ˆGÔØ×(Ò(¨Ñ2Ô2ˆHð Ð)Ý˜IÑ&Ô&ð *å" 9Ñ-Ô-ð *ð ˆIˆIÝ˜9Ñ%Ô%ð 	­'°)¸ZÑ*HÔ*Hð 	Ý˜IÔ.Ñ/Ô/ˆIˆIÝ˜)Ñ$Ô$ð 	­°¸IÑ)FÔ)Fð 	Ý�BœI iÔ&7Ñ8Ô8Ñ9Ô9ˆIˆIå(¨Ñ2Ô2ˆKØÐ6Ð6Ð6Ø�	�	Ø Ò,Ð,Ý¥¤	¨(Ñ 3Ô 3Ñ4Ô4�	�	å ðiØ Ô*Ô3ðið ið iñô ð ð Œ=˜AÒÐØ'�xÔ'¨¬Ð3ˆHˆHå˜IÑ&Ô&ð NÝ Ð!LÑMÔMÐMà Ð,õ œ.¨Ô);Ð?PÒ)PÑQÔQÐRSÔT�Ø7˜8 A A A w JÔ/Ô7¸¼ÐC��à+˜8Ô+ÐK¨S¬YÐK¸¼ÀrÔ8JÐKÐKÐK�àˆ>Ý%,¨Q°	Ñ%:Ô%:ÐB�Q”Y˜q”\�\ÀˆFàˆ>Ý%,¨Q°	Ñ%:Ô%:ÐB�Q”Y˜q”\�\ÀˆFà�#ØØØØØ/ØØð
ñ 
ô 
ˆð ˆwŒ|ÐE˜r¨{ÐEÐE¸fÐEÐEÐEr"   )rL   NNN)rž   Ú
__module__Ú__qualname__Ú__doc__rK   r…   Úclassmethodr´   r“   r"   r    rB   rB   ƒ   s®   € € € € € ðRð Rðv ØØðð ð ð ð ð&ið ið ið iðV ð ØØØØØØØØðQFð QFð QFð QFñ „[ðQFð QFð QFr"   rB   ) rl   Únumpyr6   Úsklearn.baser   r   r   r   Úsklearn.preprocessingr   Úsklearn.utilsr   Úsklearn.utils._dataframer	   r
   Ú$sklearn.utils._optional_dependenciesr   Úsklearn.utils._responser   Úsklearn.utils._set_outputr   Úsklearn.utils.fixesr   Úsklearn.utils.multiclassr   Úsklearn.utils.validationr   r   r   r!   r@   rB   r“   r"   r    ú<module>rÄ      st  ðð €€€à Ð Ð Ð à WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WØ .Ð .Ð .Ð .Ð .Ð .Ø (Ð (Ð (Ð (Ð (Ð (Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø IÐ IÐ IÐ IÐ IÐ IØ 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø AÐ AÐ AÐ AÐ AÐ AØ .Ð .Ð .Ð .Ð .Ð .Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ðð ð ðDFHð FHð FHðRe	Fð e	Fð e	Fð e	Fð e	Fñ e	Fô e	Fð e	Fð e	Fð e	Fr"   