Ë
    8Ò^j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y)é    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}|S g d¢}|S |}|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        úu/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/sklearn/inspection/_plot/decision_boundary.pyÚ_check_boundary_response_methodr!      sr   € ô$ ˜) ZÓ0€KÙÔ/°	×0BÑ0BÀ1Ñ0EÔFØVˆÜ˜‹oÐà˜&Ò Ü˜	Ô"Ø )Ðð Ðò	 !RÐð Ðð ,ÐàÐó    c           	      ól  ‡ — |€|dk  r
t         d| }nd}t        |t        «      r�|‰ j                  j	                  «       vrt        d|› �«      ‚‰ j                  j                  |«      }|j                  |k  rt        d|› d|j                  › d|› d�«      ‚ |t        j                  d	d
|«      «      S t        |t        «      rft        |«      |k7  rt        d|› dt        |«      › d�«      ‚t        ˆ fd„|D «       «      rt        d|› �«      ‚‰ j                  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   óV   •K  — | ]   }‰j                   j                  |«       –— Œ" y ­w©N)ÚcolorsÚis_color_like)Ú.0ÚcolÚmpls     €r    ú	<genexpr>z!_select_colors.<locals>.<genexpr>x   s#   øè ø€ ÒP°s�S—Z‘Z×-Ñ-¨cÓ2Ô2ÑPùs   ƒ&)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@   :   sm  ø€ ð< Ð ð ˜Š?Ü .¨z°	Ð :Ñà .ÐäÐ#¤SÔ)Ø C§J¡J×$8Ñ$8Ó$:Ñ:Üð-Ø->Ð,?ðAóð ð �z‰z×"Ñ"Ð#4Ó5ˆØ�6‰6�IÒÜØÐ.Ð/¨{¸4¿6¹6¸(À-Ø�+ð 'ð'óð ñ ”B—K‘K  1 iÓ0Ó1Ð1ä	Ð%¤tÔ	,ÜÐ Ó! YÒ.Üð<Ø<E¸;ÀhÜÐ(Ó)Ð*¨!ð-óð ô
 ÓPÐ>OÔPÔPÜð1Ø1BÐ0CðEóð ð �z‰z×'Ñ'Ð(9Ó:Ð:ô ÐFÓGÐGr"   c                   óN   — 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y)Ú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                óf   — || _         || _        || _        || _        || _        || _        || _        y r)   ©Úxx0Úxx1r>   Úresponser=   rC   rD   )ÚselfrG   rH   r>   rI   r=   rC   rD   s           r    Ú__init__z DecisionBoundaryDisplay.__init__  s6   € ð ˆŒØˆŒØ"ˆŒØ ˆŒØ!2ˆÔØˆŒØˆ�r"   Úcontourfc                 óü  — t        d«       ddl}ddlm} |dvrt	        d|› d�«      ‚|€|j                  «       \  }}t        ||«      }	| j                  dk(  r0 |	| j                  | j                  | j                  fi |¤Ž| _        �nìdD ]#  }
|
|v sŒt        j                  d	|
› d
�«       ||
= Œ% t        || j                  | j                  «      | _        d|vrd|d<   | j                  j"                  dk(  �r~t%        | j                   «      D �����cg c]9  \  }\  }}}}|j&                  j(                  j+                  d|› �d|||dfg«      ‘Œ; }}}}}}g | _        t%        |«      D ]‘  \  }}t,        j.                  j1                  | j                  dd…dd…|f   | j                  j3                  d¬«      |k7  ¬«      }| j                  j5                   |	| j                  | j                  |fd|i|¤Ž«       Œ“ |dk(  �rp| j                  j5                   |	| j                  | j                  | j                  j3                  d¬«      ddt-        j6                  | j                  «      ¬«      «       ný| j                  j"                  dk(  räd|vrU|dk(  r#t-        j6                  | j                  «      |d<   n-|dk(  r(t-        j6                  | j                  dz   «      dz
  |d<   |dk(  r1 |	| j                  | j                  | j                  fddi|¤Ž| _        nU|j&                  j9                  | j                   «      } |	| j                  | j                  | j                  fd|i|¤Ž| _        |€|j;                  «       s!|€| j<                  n|}|j?                  |«       |€|jA                  «       s!|€| jB                  n|}|jE                  |«       || _#        |jH                  | _%        | S c c}}}}}w )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éÿÿÿÿé   Ú	colormap_)ç      ð?rX   rX   rX   rX   ©Úaxis)Úmaskr?   rO   Úblack)r*   rT   Úlevelsr]   rL   r&   g      à?r*   )&r   Ú
matplotlibÚmatplotlib.pyplotr2   r   ÚsubplotsÚgetattrr>   rG   rH   rI   Úsurface_ÚwarningsÚwarnr@   r=   Úmulticlass_colors_ÚndimÚ	enumerater*   ÚLinearSegmentedColormapÚ	from_listr6   ÚmaÚarrayÚargmaxÚappendÚarangeÚListedColormapÚ
get_xlabelrC   Ú
set_xlabelÚ
get_ylabelrD   Ú
set_ylabelÚax_ÚfigureÚfigure_)rJ   Úplot_methodÚaxrC   rD   Úkwargsr.   ÚpltÚ_Ú	plot_funcÚkwargÚ	class_idxÚrÚgÚbÚmulticlass_cmapsr?   rI   s                     r    ÚplotzDecisionBoundaryDisplay.plot+  sÄ  € ôT 	!Ð!?Ô@Û Ý'àÐCÑCÜðØ"�m 9ð.óð ð
 ˆ:Ø—L‘L“N‰EˆAˆrä˜B Ó,ˆ	Ø�>‰>˜QÒÙ% d§h¡h°·±¸$¿-¹-ÑRÈ6ÑRˆDŽMà+ò &�Ø˜F’?Ü—M‘MØ˜E˜7ð #2ð 2ôð ˜u™ð&ô '5Ø�T×+Ñ+¨T¯^©^ó'ˆDÔ#ð ˜vÑ%Ø#%��xÑ à�}‰}×!Ñ! QÓ&ô 4=¸T×=TÑ=TÓ3U÷$ò $ñ
 0˜	¡< A q¨!¨Qð	 —J‘J×6Ñ6×@Ñ@Ø# I ;Ð/Ø-°°1°a¸¨~Ð>õð$Ð ô $ð !#�”Ü'0Ð1AÓ'Bò ‘O�I˜tÜ!Ÿu™uŸ{™{ØŸ™¢aª¨I oÑ6Ø"Ÿm™m×2Ñ2¸Ð2Ó:¸iÑGð  +ó  �Hð —M‘M×(Ñ(Ù! $§(¡(¨D¯H©H°hÑTÀTÐTÈVÑTõðð  )Ó+à—M‘M×(Ñ(Ù!Ø ŸH™HØ ŸH™HØ ŸM™M×0Ñ0°aÐ0Ó8Ø#*Ø#%ä#%§9¡9¨T¯^©^Ó#<ôõ
ð —‘×#Ñ# qÒ(à 6Ñ)Ø" iÒ/Ü+-¯9©9°T·^±^Ó+D˜˜xÒ(Ø$¨
Ò2Ü+-¯9©9°T·^±^ÀaÑ5GÓ+HÈ3Ñ+N˜˜xÑ(à )Ò+Ù$-ØŸ™ $§(¡(¨D¯M©Mñ%ØBIð%ØMSñ%�D•Mð
 Ÿ:™:×4Ñ4°T×5LÑ5LÓM�DÙ$-ØŸ™ $§(¡(¨D¯M©Mñ%Ø@Dð%ØHNñ%�D”Mð Ð R§]¡]¤_Ø$* N�T—[’[¸ˆFØ�M‰M˜&Ô!ØÐ R§]¡]¤_Ø$* N�T—[’[¸ˆFØ�M‰M˜&Ô!àˆŒØ—y‘yˆŒØˆùöw$s   Ä>O5éd   rX   r   )	Úgrid_resolutionÚepsrw   r   Úclass_of_interestr=   rC   rD   rx   c       	   	      ó@  — t        |«       |dkD  st        d|› d�«      ‚|dk\  st        d|› d�«      ‚d}||vr#dj                  |«      }t        d|› d	|› d�«      ‚t        |«      }|d
k7  rt        d|› d�«      ‚t	        |dd¬«      t	        |dd¬«      }}|j                  «       |z
  |j                  «       |z   }}|j                  «       |z
  |j                  «       |z   }}t        j                  t        j                  |||«      t        j                  |||«      «      \  }}t        j                  |j                  «       |j                  «       f   }t        |«      st        |«      r)t        |«      }|j                  |||j                   ¬«      }t#        ||«      }|�5t%        |d«      r)||j&                  vrt        d|› d|j&                  › �«      ‚t)        ||||d¬«      \  }}}|dk(  r8t%        |d«      r,t+        «       }|j&                  |_        |j-                  |«      }|€t/        |«      st1        |«      rd
}nÆt3        |«      r"t%        |d«      rt5        |j&                  «      }n™t7        |«      r5t%        |d«      r)t5        t        j8                  |j:                  «      «      }nYt=        |«      } | dv rd
}nG| dk(  rt5        t        j8                  |«      «      }n#t        d|j>                  j@                  › d�«      ‚|jB                  dk(  r |jD                  |jF                  Ž }n‰t/        |«      rt        d«      ‚|�Ft        jH                  |j&                  |k(  «      d   }! |dd…|!f   jD                  |jF                  Ž }n+ |jD                  g |jF                  ¢|jF                  d   ‘­Ž }|	€t%        |d«      r|j                   d   nd}	|
€t%        |d«      r|j                   d   nd}
 | ||||||	|
¬«      }" |"jJ                  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 rY   )Ú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   )rx   rw   © )&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__rf   ÚreshapeÚshapeÚflatnonzerorƒ   )#Úclsr   ÚXr…   r†   rw   r   r‡   r=   rC   rD   rx   ry   Ú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Ö  sI  € ôl 	˜	Ô"à Ò"ÜðØ#Ð$ Ið/óð ð
 �aŠxÜØ>¸s¸eÀ9ÐMóð ð !FÐØÐ3Ñ3Ø $§	¡	Ð*?Ó @ÐÜØ-Ð.?Ð-@ð AØ"�m 9ð.óð ô
 % QÓ'ˆØ˜1ÒÜØ5°l°^À9ÐMóð ô    1¨1Ô-¬~¸aÀÈÔ/KˆBˆàŸ™› C™¨¯©«°C©�ˆØŸ™› C™¨¯©«°C©�ˆä—;‘;Ü�K‰K˜ ¨Ó8Ü�K‰K˜ ¨Ó8ó
‰ˆˆSô
 —‘�s—y‘y“{ C§I¡I£KÐ/Ñ0ˆÜ˜Œ?œl¨1œoÜ1°!Ó4ˆGØ×-Ñ-ØØØŸ	™	ð .ó ˆFô <¸IÀÓWÐØÐ)¬g°iÀÔ.LØ Y×%7Ñ%7Ñ7äØ$Ð%6Ð$7ð 8$Ø$-×$6Ñ$6Ð#7ð9óð ô
 -AØØØ-Ø'Ø(,ô-
Ñ)ˆ�!Ð)ð   9Ò,´¸ÀJÔ1OÜ"“nˆGØ(×1Ñ1ˆGÔØ×(Ñ(¨Ó2ˆHð Ð)Ü˜IÔ&Ü" 9Ô-à‰IÜ˜9Ô%¬'°)¸ZÔ*HÜ˜I×.Ñ.Ó/‰IÜ˜)Ô$¬°¸IÔ)FÜœBŸI™I i×&7Ñ&7Ó8Ó9‰Iä(¨Ó2ˆKØÐ6Ñ6Ø‘	Ø Ò,Ü¤§	¡	¨(Ó 3Ó4‘	ä ØJØ ×*Ñ*×3Ñ3Ð4ð 5iðióð ð �=‰=˜AÒØ'�x×'Ñ'¨¯©Ð3‰Hä˜IÔ&Ü Ð!LÓMÐMà Ð,ô Ÿ.™.¨×);Ñ);Ð?PÑ)PÓQÐRSÑT�Ø7˜8¢A w JÑ/×7Ñ7¸¿¹ÐC‘à+˜8×+Ñ+ÐK¨S¯Y©YÐK¸¿¹ÀrÑ8JÒK�àˆ>Ü%,¨Q°	Ô%:�Q—Y‘Y˜q’\ÀˆFàˆ>Ü%,¨Q°	Ô%:�Q—Y‘Y˜q’\ÀˆFáØØØØØ/ØØô
ˆð ˆw�|‰|ÐE˜r¨{ÑE¸fÑEÐEr"   )rL   NNN)rœ   Ú
__module__Ú__qualname__Ú__doc__rK   rƒ   Úclassmethodr²   r‘   r"   r    rB   rB   ƒ   sU   „ ñRðv ØØôó&iðV ð ØØØØØØØØóQFó ñQFr"   rB   ) rc   Ú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Â      sQ   ðó ã ç WÓ WÝ .Ý (ß ?Ý IÝ 8Ý AÝ .Ý 3÷ñ òòDFH÷Re	Fò e	Fr"   