§
    §éUg:  ã                   ó¾  — 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                      e¦   «         ¦  «         e                      e¦   «         ¦  «         d„ Zdd„Zdd„Zd„ Zd„ Zd„ Z G d„ d¦  «        Zddœd„ZdS )é    N©Úwraps)ÚProtocolÚruntime_checkable)Úissparseé   )Ú
get_configé   )Úavailable_if)Ú2_create_pandas_dataframe_from_non_pandas_containerc                 ó~   — 	 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     úX/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/sklearn/utils/_set_output.pyÚcheck_library_installedr      sp   € ðÝÔ& wÑ/Ô/Ð/øÝð ð ð Ýð¨Gð ð Àð ð ð ñ
ô 
ð ð	øøøøðøøøs   ‚ –
< 7·<c                 ó\   — t          | ¦  «        r	  | ¦   «         S # t          $ r Y d S w xY w| S ©N)ÚcallableÚ	Exception©Úcolumnss    r   Úget_columnsr      sJ   € Ý�ÑÔð ð	Ø�7‘9”9ÐøÝð 	ð 	ð 	Ø�4�4ð	øøøà€Ns   ‘	 ›
)¨)c                   ó4   — e Zd ZU eed<   dd„Zd„ Zd„ Zd„ ZdS )	ÚContainerAdapterProtocolÚcontainer_libFc                 ó   — dS )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                 ó   — dS )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_containerA   r&   r'   c                 ó   — dS )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_columnsO   r&   r'   c                 ó   — dS )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.hstack`   r&   r'   N)F)	Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r%   r*   r-   r0   r    r'   r   r   r   !   sc   € € € € € € àÐÐÑðð ð ð ð8ð ð ðð ð ð"ð ð ð ð r'   r   c                   ó,   — e Zd ZdZdd„Zd„ Zd„ Zd„ ZdS )	ÚPandasAdapterÚpandasTc                 ó>  — t          d¦  «        }t          |¦  «        }|rt          ||j        ¦  «        sOt          ||j        ¦  «        r|j        }nt          ||j        ¦  «        r|j        }nd }t          ||| ¬¦  «        }|�|                      ||¦  «        S |S )Nr8   )r)   ÚindexÚcopy)r   r   Ú
isinstanceÚ	DataFramer:   r   r-   )r!   r"   r#   r   r$   Úpdr:   s          r   r%   zPandasAdapter.create_containerr   s¼   € Ý$ XÑ.Ô.ˆÝ˜gÑ&Ô&ˆàð 	�j¨°2´<Ñ@Ô@ð 	õ
 ˜( B¤LÑ1Ô1ð Ø œ��Ý˜J¨¬Ñ5Ô5ð Ø"Ô(��à�õ JØ %°'¨kðñ ô ˆHð ÐØ×&Ò& x°Ñ9Ô9Ð9Øˆr'   c                 óJ   — 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                 óN   — t          d¦  «        }|                     |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   o   sZ   € € € € € Ø€Mðð ð ð ð4+ð +ð +ðð ð ð%ð %ð %ð %ð %r'   r7   c                   ó,   — e Zd ZdZdd„Zd„ Zd„ Zd„ ZdS )	ÚPolarsAdapterÚpolarsTc                 ó0  — t          d¦  «        }t          |¦  «        }t          |t          j        ¦  «        r|                     ¦   «         n|}|rt          ||j        ¦  «        s|                     ||d¬¦  «        S |�|                      ||¦  «        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ž   s—   € Ý$ XÑ.Ô.ˆÝ˜gÑ&Ô&ˆÝ&0°½"¼*Ñ&EÔ&EÐR�'—.’.Ñ"Ô"Ð"È7ˆàð 	H�j¨°2´<Ñ@Ô@ð 	Hà—<’< °À�<ÑGÔGÐGàÐØ×&Ò& x°Ñ9Ô9Ð9Øˆr'   c                 óJ   — 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                 óN   — t          d¦  «        }|                     |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   ›   sZ   € € € € € Ø€Mðð ð ð ð+ð +ð +ðð ð ð/ð /ð /ð /ð /r'   rK   c                   ó0   — e Zd Zd„ Zed„ ¦   «         Zd„ ZdS )ÚContainerAdaptersManagerc                 ó   — i | _         d S r   )Úadapters©r!   s    r   Ú__init__z!ContainerAdaptersManager.__init__»   s   € ØˆŒˆˆr'   c                 ó2   — dht          | j        ¦  «        z  S )NÚdefault)Úsetr]   r^   s    r   Úsupported_outputsz*ContainerAdaptersManager.supported_outputs¾   s   € àˆ{�S ¤Ñ/Ô/Ñ/Ð/r'   c                 ó$   — || j         |j        <   d S 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[   º   sM   € € € € € ðð ð ð ð0ð 0ñ „Xð0ð7ð 7ð 7ð 7ð 7r'   r[   c                 ó  — | j         j                             d¦  «        d         }	 t          j        |         S # t
          $ rG}t          t          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×6Ò6°sÑ;Ô;¸AÔ>€KðÝÔ(¨Ô5Ð5øÝð ð ð Ý!Õ"2Ô";×"@Ò"@Ñ"BÔ"BÑCÔCÐÝð+Ø'9ð+ð +à%ð+ð +ð +ñ
ô 
ð ð		øøøøðøøøs   §9 ¹
B
ÁABÂB
c                 óv   — t          | |¦  «        d         }	 t          j        |         S # t          $ r Y dS w xY w)zGet container adapter.ÚdenseN)Ú_get_output_configrl   r]   rm   )ÚmethodÚ	estimatorÚdense_configs      r   Ú_get_container_adapterr{   Ý   sK   € å% f¨iÑ8Ô8¸ÔA€LðÝÔ(¨Ô6Ð6øÝð ð ð Øˆtˆtðøøøs   ˜* ª
8·8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Ô PÐØÐ*Ð*Ð*Ø0°Ô8ˆˆå!‘|”| vÐ$6Ð$6Ð$6Ô7ˆå(Ô:ÐØÐ,Ð,Ð,ÝØW­Ð/@Ñ(AÔ(AÐWÐWÈÐWÐWñ
ô 
ð 	
ð �\Ð"Ð"r'   c                 ó2  — t          | |¦  «        }|d         dk    st          |¦  «        s|S |d         }t          |¦  «        r%t          d|                     ¦   «         › d�¦  «        ‚t
          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Ô9€Mà�WÔ Ò*Ð*Õ2JÈ9Ñ2UÔ2UÐ*ØÐà  Ô)€LÝ�ÑÔð 
ÝðXà×&Ò&Ñ(Ô(ðXð Xð Xñ
ô 
ð 	
õ Ô'¨Ô5€GØ×#Ò#ØØØÔ/ð $ñ ô ð r'   c                 ó@   ‡ ‡— t          ‰ ¦  «        ˆ ˆfd„¦   «         }|S )z@Wrapper used by `_SetOutputMixin` to automatically wrap methods.c                 ó6  •—  ‰| |g|¢R i |¤Ž}t          |t          ¦  «        ret          ‰|d         || ¦  «        g|dd …         ¢R }t          t	          |¦  «        d¦  «        r"t	          |¦  «                             |¦  «        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˜˜qÐ2 4Ð2Ð2Ð2¨6Ð2Ð2ˆÝ�l¥EÑ*Ô*ð 
	 õ *¨&°,¸q´/À1ÀdÑKÔKðà˜a˜b˜bÔ!ðð ˆLõ •t˜LÑ)Ô)¨7Ñ3Ô3ð >Ý˜LÑ)Ô)×/Ò/°Ñ=Ô=Ð=ØÐå(¨°¸qÀ$ÑGÔGÐGr'   r   )r“   rx   r”   s   `` r   Ú_wrap_method_outputr•   7  sA   øø€ õ ˆ1�X„XðHð Hð Hð Hð Hñ „XðHð  €Nr'   c                 ód   — t          | dt          ¦   «         ¦  «        }t          | d¦  «        o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ƒ   N  s?   € õ $ IÐ/OÕQTÑQVÔQVÑWÔWÐå�	Ð2Ñ3Ô3ð 	1ØÐ0Ð0ðr'   c                   óR   ‡ — 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          ¦   «         j        di |¤Ž t          |t          ¦  «        s|�t	          d¦  «        ‚|€t          ¦   «         | _        d S dddœ}t          ¦   «         | _        |                     ¦   «         D ]m\  }}t          | |¦  «        r||vrŒ| j         	                    |¦  «         || j
        vrŒ>t          t          | |¦  «        |¦  «        }t          | ||¦  «         Œnd S )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__e  s$  ø€ Ø!�‰ŒÔ!Ð+Ð+ FÐ+Ð+Ð+õ
 Ð,­eÑ4Ô4ð	WØ8MÐ8UåÐUÑVÔVÐVà Ð(Ý14±´ˆCÔ.ØˆFð %Ø(ð
ð 
ˆõ .1©U¬UˆÔ*à(×.Ò.Ñ0Ô0ð 		1ð 		1‰KˆF�CÝ˜3 Ñ'Ô'ð ¨3Ð6KÐ+KÐ+KØØÔ.×2Ò2°3Ñ7Ô7Ð7ð ˜Sœ\Ð)Ð)ØÝ0µ¸¸fÑ1EÔ1EÀsÑKÔKˆNÝ�C˜ Ñ0Ô0Ð0Ð0ð		1ð 		1r'   Nc                óP   — |€| 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.
        Nr}   r˜   )rŽ   r}   )r!   r˜   s     r   Ú
set_outputz_SetOutputMixin.set_output…  s<   € ð2 ÐØˆKå�tÐ5Ñ6Ô6ð 	-Ø*,ˆDÔ'à3<ˆÔ# KÑ0Øˆr'   )rœ   )	r1   r2   r3   Ú__doc__r    r   rƒ   rª   Ú__classcell__)rj   s   @r   r›   r›   [  s|   ø€ € € € € ðð ð1ð 1ð 1ð 1ð 1ð 1ð@ €\Ð*Ñ+Ô+Ø&*ð ð ð ð ñ ,Ô+ðð ð ð ð r'   r›   rœ   c                óÄ   — t          | d¦  «        pt          | d¦  «        o|du}|sdS t          | d¦  «        st          d| › d�¦  «        ‚|                      |¬¦  «        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¯   ¨  s™   € õ0 	�	˜;Ñ'Ô'ð 	"Ý�9˜oÑ.Ô.ð "Ø˜TÐ!ð ð
 $ð ð 	ˆå�9˜lÑ+Ô+ð 
Ýð ¨ið  ð  ð  ñ
ô 
ð 	
ð ×Ò¨)ÐÑ4Ô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·      sj  ðØ Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à  Ð  Ð  Ð  Ð  Ð  Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø EÐ EÐ EÐ EÐ EÐ Eðð ð ðð ð ð ðJð Jð Jð Jð J˜xñ Jô Jñ ÔðJðZ)%ð )%ð )%ð )%ð )%ñ )%ô )%ð )%ðX/ð /ð /ð /ð /ñ /ô /ð /ð>	7ð 	7ð 	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð ,Ð+Ñ-Ô-Ð Ø × Ò ˜-˜-™/œ/Ñ *Ô *Ð *Ø × Ò ˜-˜-™/œ/Ñ *Ô *Ð *ðð ð ð$ð ð ð ð #ð  #ð  #ð  #ðF+ð +ð +ð\ð ð ð.
ð 
ð 
ðJð Jð Jð Jð Jñ Jô Jð JðZ .2ð &5ð &5ð &5ð &5ð &5ð &5ð &5r'   