Ë
    ÷Q(hX:  ã                   óv  — d dl Z d dlmZ d dlmZmZ d dlZd dlm	Z	 ddl
mZ ddlmZ dd	lmZ d
„ Zd„ Ze G d„ de«      «       Z G d„ d«      Z G d„ d«      Z G d„ d«      Z e«       Zej/                   e«       «       ej/                   e«       «       d„ Zdd„Zdd„Zd„ Zd„ Zd„ Z G d„ d«      Zddœd„Zy)é    N©Úwraps)ÚProtocolÚruntime_checkable)Úissparseé   )Ú
get_configé   )Úavailable_if)Ú2_create_pandas_dataframe_from_non_pandas_containerc                 óv   — 	 t        j                  | «      S # t        $ r}t        d| › d| › d�«      |‚d}~ww xY w)zCheck library is installed.zSetting output container to 'z' requires z to be installedN)Ú	importlibÚimport_moduleÚImportError)ÚlibraryÚexcs     úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sklearn/utils/_set_output.pyÚcheck_library_installedr      sR   € ðÜ×&Ñ& wÓ/Ð/øÜò ÜØ+¨G¨9°KÀ¸yð Ið ó
ð ð	ûðús   ‚ —	8 3³8c                 óJ   — t        | «      r	  | «       S | S # t        $ r Y y w xY w©N)ÚcallableÚ	Exception©Úcolumnss    r   Úget_columnsr      s2   € Ü�Ôð	Ù“9Ðð €Nøô ò 	Ùð	ús   � –	"¡"c                   ó2   — e Zd ZU eed<   dd„Zd„ Zd„ Zd„ Zy)ÚContainerAdapterProtocolÚcontainer_libc                  ó   — y)aò  Create container from `X_output` with additional metadata.

        Parameters
        ----------
        X_output : {ndarray, dataframe}
            Data to wrap.

        X_original : {ndarray, dataframe}
            Original input dataframe. This is used to extract the metadata that should
            be passed to `X_output`, e.g. pandas row index.

        columns : callable, ndarray, or None
            The column names or a callable that returns the column names. The
            callable is useful if the column names require some computation. If `None`,
            then no columns are passed to the container's constructor.

        inplace : bool, default=False
            Whether or not we intend to modify `X_output` in-place. However, it does
            not guarantee that we return the same object if the in-place operation
            is not possible.

        Returns
        -------
        wrapped_output : container_type
            `X_output` wrapped into the container type.
        N© )ÚselfÚX_outputÚ
X_originalr   Úinplaces        r   Úcreate_containerz)ContainerAdapterProtocol.create_container(   ó   � ó    c                  ó   — y)a  Return True if X is a supported container.

        Parameters
        ----------
        Xs: container
            Containers to be checked.

        Returns
        -------
        is_supported_container : bool
            True if X is a supported container.
        Nr    )r!   ÚXs     r   Úis_supported_containerz/ContainerAdapterProtocol.is_supported_containerD   r&   r'   c                  ó   — y)aQ  Rename columns in `X`.

        Parameters
        ----------
        X : container
            Container which columns is updated.

        columns : ndarray of str
            Columns to update the `X`'s columns with.

        Returns
        -------
        updated_container : container
            Container with new names.
        Nr    ©r!   r)   r   s      r   Úrename_columnsz'ContainerAdapterProtocol.rename_columnsR   r&   r'   c                  ó   — y)a  Stack containers horizontally (column-wise).

        Parameters
        ----------
        Xs : list of containers
            List of containers to stack.

        Returns
        -------
        stacked_Xs : container
            Stacked containers.
        Nr    )r!   ÚXss     r   ÚhstackzContainerAdapterProtocol.hstackc   r&   r'   N)F)	Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r%   r*   r-   r0   r    r'   r   r   r   $   s   … àÓóò8òó"r'   r   c                   ó*   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zy)ÚPandasAdapterÚpandasc                 ó8  — t        d«      }t        |«      }|rt        ||j                  «      sWt        ||j                  «      r|j                  }n%t        ||j                  «      r|j                  }nd }t        ||| ¬«      }|�| j                  ||«      S |S )Nr8   )r)   ÚindexÚcopy)r   r   Ú
isinstanceÚ	DataFramer:   r   r-   )r!   r"   r#   r   r$   Úpdr:   s          r   r%   zPandasAdapter.create_containeru   s“   € Ü$ XÓ.ˆÜ˜gÓ&ˆáœj¨°2·<±<Ô@ô
 ˜( B§L¡LÔ1Ø Ÿ™‘Ü˜J¨¯©Ô5Ø"×(Ñ(‘à�ô JØ %°'¨kôˆHð ÐØ×&Ñ& x°Ó9Ð9Øˆr'   c                 óD   — t        d«      }t        ||j                  «      S )Nr8   ©r   r<   r=   )r!   r)   r>   s      r   r*   z$PandasAdapter.is_supported_container�   ó   € Ü$ XÓ.ˆÜ˜!˜RŸ\™\Ó*Ð*r'   c                 ó   — ||_         |S r   r   r,   s      r   r-   zPandasAdapter.rename_columns“   ó   € ð ˆŒ	Øˆr'   c                 ó>   — t        d«      }|j                  |d¬«      S )Nr8   r
   )Úaxis©r   Úconcat)r!   r/   r>   s      r   r0   zPandasAdapter.hstack™   s   € Ü$ XÓ.ˆØ�y‰y˜ !ˆyÓ$Ð$r'   N©T©r1   r2   r3   r   r%   r*   r-   r0   r    r'   r   r7   r7   r   s   „ Ø€Móò4+òó%r'   r7   c                   ó*   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zy)ÚPolarsAdapterÚpolarsc                 ó
  — t        d«      }t        |«      }t        |t        j                  «      r|j                  «       n|}|rt        ||j                  «      s|j                  ||d¬«      S |�| j                  ||«      S |S )NrL   Úrow)ÚschemaÚorient)r   r   r<   ÚnpÚndarrayÚtolistr=   r-   )r!   r"   r#   r   r$   Úpls         r   r%   zPolarsAdapter.create_container¡   st   € Ü$ XÓ.ˆÜ˜gÓ&ˆÜ&0°¼"¿*¹*Ô&E�'—.‘.Ô"È7ˆáœj¨°2·<±<Ô@à—<‘< °À�<ÓGÐGàÐØ×&Ñ& x°Ó9Ð9Øˆr'   c                 óD   — t        d«      }t        ||j                  «      S )NrL   r@   )r!   r)   rT   s      r   r*   z$PolarsAdapter.is_supported_container®   rA   r'   c                 ó   — ||_         |S r   r   r,   s      r   r-   zPolarsAdapter.rename_columns²   rC   r'   c                 ó>   — t        d«      }|j                  |d¬«      S )NrL   Ú
horizontal)ÚhowrF   )r!   r/   rT   s      r   r0   zPolarsAdapter.hstack¸   s   € Ü$ XÓ.ˆØ�y‰y˜ ˆyÓ.Ð.r'   NrH   rI   r    r'   r   rK   rK   ž   s   „ Ø€Móò+òó/r'   rK   c                   ó(   — e Zd Zd„ Zed„ «       Zd„ Zy)ÚContainerAdaptersManagerc                 ó   — i | _         y r   )Úadapters©r!   s    r   Ú__init__z!ContainerAdaptersManager.__init__¾   s	   € Øˆ�r'   c                 ó4   — dht        | j                  «      z  S )NÚdefault)Úsetr]   r^   s    r   Úsupported_outputsz*ContainerAdaptersManager.supported_outputsÁ   s   € àˆ{œS §¡Ó/Ñ/Ð/r'   c                 ó6   — || j                   |j                  <   y r   )r]   r   )r!   Úadapters     r   Úregisterz!ContainerAdaptersManager.registerÅ   s   € Ø/6ˆ�‰�g×+Ñ+Ò,r'   N)r1   r2   r3   r_   Úpropertyrc   rf   r    r'   r   r[   r[   ½   s    „ òð ñ0ó ð0ó7r'   r[   c                 ó  — | j                   j                  j                  d«      d   }	 t        j                  |   S # t
        $ r?}t        t        j                  j                  «       «      }t        d|› d| ›d�«      |‚d}~ww xY w)z˜Get the adapter that knows how to handle such container.

    See :class:`sklearn.utils._set_output.ContainerAdapterProtocol` for more
    details.
    ú.r   zZThe container does not have a registered adapter in scikit-learn. Available adapters are: z" while the container provided is: N)	Ú	__class__r2   ÚsplitÚADAPTERS_MANAGERr]   ÚKeyErrorÚlistÚkeysÚ
ValueError)Ú	containerÚmodule_namer   Úavailable_adapterss       r   Ú_get_adapter_from_containerrt   Î   s”   € ð ×%Ñ%×0Ñ0×6Ñ6°sÓ;¸AÑ>€KðÜ×(Ñ(¨Ñ5Ð5øÜò Ü!Ô"2×";Ñ";×"@Ñ"@Ó"BÓCÐÜð'Ø'9Ð&:ð ;Ø%˜=¨ð+ó
ð ð		ûðús   ª= ½	BÁ:B Â Bc                 óf   — t        | |«      d   }	 t        j                  |   S # t        $ r Y yw xY w)zGet container adapter.ÚdenseN)Ú_get_output_configrl   r]   rm   )ÚmethodÚ	estimatorÚdense_configs      r   Ú_get_container_adapterr{   à   s;   € ä% f¨iÓ8¸ÑA€LðÜ×(Ñ(¨Ñ6Ð6øÜò Ùðús   ‘$ ¤	0¯0c                 ó´   — t        |di «      }| |v r||    }nt        «       | › d�   }t        j                  }||vrt	        dt        |«      › d|› �«      ‚d|iS )a  Get output config based on estimator and global configuration.

    Parameters
    ----------
    method : {"transform"}
        Estimator's method for which the output container is looked up.

    estimator : estimator instance or None
        Estimator to get the output configuration from. If `None`, check global
        configuration is used.

    Returns
    -------
    config : dict
        Dictionary with keys:

        - "dense": specifies the dense container for `method`. This can be
          `"default"` or `"pandas"`.
    Ú_sklearn_output_configÚ_outputzoutput config must be in z, got rv   )Úgetattrr	   rl   rc   rp   Úsorted)rx   ry   Úest_sklearn_output_configrz   rc   s        r   rw   rw   é   s€   € ô( !(¨	Ð3KÈRÓ PÐØÐ*Ñ*Ø0°Ñ8‰ä!“| v h¨gÐ$6Ñ7ˆä(×:Ñ:ÐØÐ,Ñ,ÜØ'¬Ð/@Ó(AÐ'BÀ&ÈÈÐWó
ð 	
ð �\Ð"Ð"r'   c                 ó   — t        | |«      }|d   dk(  st        |«      s|S |d   }t        |«      rt        d|j	                  «       › d�«      ‚t
        j                  |   }|j                  |||j                  ¬«      S )aÖ  Wrap output with container based on an estimator's or global config.

    Parameters
    ----------
    method : {"transform"}
        Estimator's method to get container output for.

    data_to_wrap : {ndarray, dataframe}
        Data to wrap with container.

    original_input : {ndarray, dataframe}
        Original input of function.

    estimator : estimator instance
        Estimator with to get the output configuration from.

    Returns
    -------
    output : {ndarray, dataframe}
        If the output config is "default" or the estimator is not configured
        for wrapping return `data_to_wrap` unchanged.
        If the output config is "pandas", return `data_to_wrap` as a pandas
        DataFrame.
    rv   ra   zmThe transformer outputs a scipy sparse matrix. Try to set the transformer output to a dense array or disable z- output with set_output(transform='default').r   )	rw   Ú_auto_wrap_is_configuredr   rp   Ú
capitalizerl   r]   r%   Úget_feature_names_out)rx   Údata_to_wrapÚoriginal_inputry   Úoutput_configrz   re   s          r   Ú_wrap_data_with_containerr‰     s¡   € ô2 ' v¨yÓ9€Mà�WÑ Ò*Ô2JÈ9Ô2UØÐà  Ñ)€LÜ�ÔÜðMà×&Ñ&Ó(Ð)Ð)VðXó
ð 	
ô ×'Ñ'¨Ñ5€GØ×#Ñ#ØØØ×/Ñ/ð $ó ð r'   c                 ó2   ‡ ‡— t        ‰ «      ˆ ˆfd„«       }|S )z@Wrapper used by `_SetOutputMixin` to automatically wrap methods.c                 óì   •—  ‰| |g|¢­i |¤Ž}t        |t        «      rIt        ‰|d   || «      g|dd  ¢­}t        t	        |«      d«      rt	        |«      j                  |«      S |S t        ‰||| «      S )Nr   r
   Ú_make)r<   Útupler‰   ÚhasattrÚtyperŒ   )r!   r)   ÚargsÚkwargsr†   Úreturn_tupleÚfrx   s         €€r   Úwrappedz$_wrap_method_output.<locals>.wrapped=  s‹   ø€ á˜˜qÐ2 4Ò2¨6Ñ2ˆÜ�l¤EÔ*ô *¨&°,¸q±/À1ÀdÓKðà˜a˜bÐ!ñˆLô ”t˜LÓ)¨7Ô3Ü˜LÓ)×/Ñ/°Ó=Ð=ØÐä(¨°¸qÀ$ÓGÐGr'   r   )r“   rx   r”   s   `` r   Ú_wrap_method_outputr•   :  s$   ù€ ô ˆ1ƒXôHó ðHð  €Nr'   c                 óP   — t        | dt        «       «      }t        | d«      xr d|v S )zÆReturn True if estimator is configured for auto-wrapping the transform method.

    `_SetOutputMixin` sets `_sklearn_auto_wrap_output_keys` to `set()` if auto wrapping
    is manually disabled.
    Ú_sklearn_auto_wrap_output_keysr…   Ú	transform)r   rb   rŽ   )ry   Úauto_wrap_output_keyss     r   rƒ   rƒ   Q  s6   € ô $ IÐ/OÔQTÓQVÓWÐä�	Ð2Ó3ò 	1ØÐ0Ð0ðr'   c                   óF   ‡ — e Zd ZdZdˆ fd„	Z ee«      ddœd„«       Zˆ xZS )Ú_SetOutputMixina\  Mixin that dynamically wraps methods to return container based on config.

    Currently `_SetOutputMixin` wraps `transform` and `fit_transform` and configures
    it based on `set_output` of the global configuration.

    `set_output` is only defined if `get_feature_names_out` is defined and
    `auto_wrap_output_keys` is the default value.
    ©r˜   c                 ó–  •— t        ‰| �  di |¤Ž t        |t        «      s|�t	        d«      ‚|€t        «       | _        y dddœ}t        «       | _        |j                  «       D ]c  \  }}t        | |«      r||vrŒ| j                  j                  |«       || j                  vrŒAt        t        | |«      |«      }t        | ||«       Œe y )Nz6auto_wrap_output_keys must be None or a tuple of keys.r˜   )r˜   Úfit_transformr    )ÚsuperÚ__init_subclass__r<   r�   rp   rb   r—   ÚitemsrŽ   ÚaddÚ__dict__r•   r   Úsetattr)Úclsr™   r‘   Úmethod_to_keyrx   ÚkeyÚwrapped_methodrj   s          €r   r    z!_SetOutputMixin.__init_subclass__h  sÕ   ø€ Ü‰Ñ!Ñ+ FÒ+ô
 Ð,¬eÔ4Ð8MÐ8UäÐUÓVÐVà Ð(Ü14³ˆCÔ.Øð %Ø(ñ
ˆô .1«UˆÔ*à(×.Ñ.Ó0ò 		1‰KˆF�CÜ˜3 Ô'¨3Ð6KÑ+KØØ×.Ñ.×2Ñ2°3Ô7ð ˜SŸ\™\Ñ)ØÜ0´¸¸fÓ1EÀsÓKˆNÜ�C˜ Õ0ñ		1r'   Nc                óR   — |€| S t        | d«      si | _        || j                  d<   | S )aÆ  Set output container.

        See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py`
        for an example on how to use the API.

        Parameters
        ----------
        transform : {"default", "pandas", "polars"}, default=None
            Configure output of `transform` and `fit_transform`.

            - `"default"`: Default output format of a transformer
            - `"pandas"`: DataFrame output
            - `"polars"`: Polars output
            - `None`: Transform configuration is unchanged

            .. versionadded:: 1.4
                `"polars"` option was added.

        Returns
        -------
        self : estimator instance
            Estimator instance.
        r}   r˜   )rŽ   r}   )r!   r˜   s     r   Ú
set_outputz_SetOutputMixin.set_outputˆ  s7   € ð2 ÐØˆKä�tÐ5Ô6Ø*,ˆDÔ'à3<ˆ×#Ñ# KÑ0Øˆr'   )rœ   )	r1   r2   r3   Ú__doc__r    r   rƒ   rª   Ú__classcell__)rj   s   @r   r›   r›   ^  s+   ø„ ñõ1ñ@ Ð*Ó+Ø&*ó ó ,ôr'   r›   rœ   c                ó¢   — t        | d«      xs t        | d«      xr |du}|syt        | d«      st        d| › d�«      ‚| j                  |¬«      S )a)  Safely call estimator.set_output and error if it not available.

    This is used by meta-estimators to set the output for child estimators.

    Parameters
    ----------
    estimator : estimator instance
        Estimator instance.

    transform : {"default", "pandas", "polars"}, default=None
        Configure output of the following estimator's methods:

        - `"transform"`
        - `"fit_transform"`

        If `None`, this operation is a no-op.

    Returns
    -------
    estimator : estimator instance
        Estimator instance.
    r˜   rž   Nrª   zUnable to configure output for z' because `set_output` is not available.rœ   )rŽ   rp   rª   )ry   r˜   Úset_output_for_transforms      r   Ú_safe_set_outputr¯   «  sw   € ô0 	�	˜;Ó'ò 	"Ü�9˜oÓ.ò "Ø˜TÐ!ð ñ
 $ð 	ä�9˜lÔ+ÜØ-¨i¨[ð 9 ð  ó
ð 	
ð ×Ñ¨)ÐÓ4Ð4r'   r   ) r   Ú	functoolsr   Útypingr   r   ÚnumpyrQ   Úscipy.sparser   Ú_configr	   Ú_available_ifr   Úfixesr   r   r   r   r7   rK   r[   rl   rf   rt   r{   rw   r‰   r•   rƒ   r›   r¯   r    r'   r   ú<module>r·      sÉ   ðó Ý ß .ã Ý !å  Ý 'Ý Eòòð ôJ˜xó Jó ðJ÷Z)%ñ )%÷X/ñ /÷>	7ñ 	7ñ ,Ó-Ð Ø × Ñ ™-›/Ô *Ø × Ñ ™-›/Ô *òó$ó #òF+ò\ò.
÷Jñ JðZ .2õ &5r'   