§
    €Øjæ;  ã                   ó¾  — 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)Úparse_versionc                 ó~   — 	 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     úŽ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/sklearn/utils/_set_output.pyÚcheck_library_installedr      sp   € ðÝÔ& wÑ/Ô/Ð/øÝð ð ð Ýð¨Gð ð Àð ð ð ñ
ô 
ð ð	øøøøðøøøs   ‚ –
< 7·<c                 óŽ   — t          | ¦  «        r5	  | ¦   «         S # t          $ r}dt          |¦  «        v rY d }~d S ‚ d }~ww xY w| S )Nz&does not provide get_feature_names_out)ÚcallableÚAttributeErrorÚstr)ÚcolumnsÚes     r   Úget_columnsr      sj   € Ý�ÑÔð ð	Ø�7‘9”9ÐøÝð 	ð 	ð 	Ø7½3¸q¹6¼6ÐAÐAØ�t�t�t�t�tàøøøøð		øøøð
 €Ns   ‘	 ›
A¥=¼=½A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
        ----------
        X : container
            Container 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_containerG   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_columnsU   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.hstackf   r$   r%   N)F)	Ú__name__Ú
__module__Ú__qualname__r   Ú__annotations__r#   r(   r+   r.   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                 óX  — t          d¦  «        }t          |¦  «        }|rt          ||j        ¦  «        s\t          ||j        ¦  «        r|j        }n&t          ||j        |j        f¦  «        r|j        }nd }|                     ||| ¬¦  «        }|�|                      ||¦  «        S |S )Nr5   )ÚindexÚcopy)r   r   Ú
isinstanceÚ	DataFramer7   ÚSeriesr+   )r   r    r!   r   r"   Úpdr7   s          r   r#   zPandasAdapter.create_containerx   s¾   € Ý$ XÑ.Ô.ˆÝ˜gÑ&Ô&ˆàð 	M�j¨°2´<Ñ@Ô@ð 	Mõ
 ˜( B¤LÑ1Ô1ð Ø œ��Ý˜J¨¬°r´yÐ(AÑBÔBð Ø"Ô(��à�ð —|’| H°EÀGÀ�|ÑLÔLˆHàÐØ×&Ò& x°Ñ9Ô9Ð9Øˆr%   c                 óJ   — t          d¦  «        }t          ||j        ¦  «        S )Nr5   ©r   r9   r:   )r   r'   r<   s      r   r(   z$PandasAdapter.is_supported_container�   ó!   € Ý$ XÑ.Ô.ˆÝ˜!˜Rœ\Ñ*Ô*Ð*r%   c                 ó   — ||_         |S ©N©r   r*   s      r   r+   zPandasAdapter.rename_columns”   ó   € ð ˆŒ	Øˆr%   c                 óN   — t          d¦  «        }|                     |d¬¦  «        S )Nr5   é   )Úaxis)r   Úconcat)r   r-   r<   s      r   r.   zPandasAdapter.hstackš   s%   € Ý$ XÑ.Ô.ˆØ�yŠy˜ !ˆyÑ$Ô$Ð$r%   N©T©r/   r0   r1   r   r#   r(   r+   r.   r   r%   r   r4   r4   u   sZ   € € € € € Ø€Mðð ð ð ð0+ð +ð +ðð ð ð%ð %ð %ð %ð %r%   r4   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   r9   Ú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¯   r?   r%   c                 ó   — ||_         |S rA   rB   r*   s      r   r+   zPolarsAdapter.rename_columns³   rC   r%   c                 ó    — t          d¦  «        }d}t          |j        ¦  «        t          d¦  «        k    rd}|                     ||¬¦  «        S )NrL   Ú
horizontalz1.42.1Úhorizontal_extend)Úhow)r   r
   Ú__version__rG   )r   r-   rT   rZ   s       r   r.   zPolarsAdapter.hstack¹   sN   € Ý$ XÑ.Ô.ˆð ˆÝ˜œÑ(Ô(­M¸(Ñ,CÔ,CÒCÐCØ%ˆCà�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 rA   )Ú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 rA   )r_   r   )r   Úadapters     r   Úregisterz!ContainerAdaptersManager.registerÍ   s   € Ø/6ˆŒ�gÔ+Ñ,Ð,Ð,r%   N)r/   r0   r1   ra   Úpropertyre   rh   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__r0   ÚsplitÚADAPTERS_MANAGERr_   ÚKeyErrorÚlistÚkeysÚ
ValueError)Ú	containerÚmodule_namer   Úavailable_adapterss       r   Ú_get_adapter_from_containerrv   Ö   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_configrn   r_   ro   )Ú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 rx   )Úgetattrr   rn   re   rr   Úsorted)rz   r{   Úest_sklearn_output_configr|   re   s        r   ry   ry   ñ   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.
    rx   rc   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').rB   )	ry   Ú_auto_wrap_is_configuredr   rr   Ú
capitalizern   r_   r#   Úget_feature_names_out)rz   Údata_to_wrapÚoriginal_inputr{   Úoutput_configr|   rg   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   rE   Ú_make)r9   Útupler‹   ÚhasattrÚtyperŽ   )r   r'   ÚargsÚkwargsrˆ   Úreturn_tupleÚfrz   s         €€r   Úwrappedz$_wrap_method_output.<locals>.wrappedE  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•   rz   r–   s   `` r   Ú_wrap_method_outputr—   B  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�   rd   r�   )r{   Úauto_wrap_output_keyss     r   r…   r…   Y  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__r9   r�   rr   rd   r™   Úitemsr�   ÚaddÚ__dict__r—   r�   Úsetattr)Úclsr›   r“   Úmethod_to_keyrz   ÚkeyÚwrapped_methodrl   s          €r   r¢   z!_SetOutputMixin.__init_subclass__p  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.

        Refer to the :ref:`user guide <df_output_transform>` for more details
        and :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<   € ð4 ÐØˆKå�tÐ5Ñ6Ô6ð 	-Ø*,ˆDÔ'à3<ˆÔ# KÑ0Øˆr%   )rž   )	r/   r0   r1   Ú__doc__r¢   r	   r…   r¬   Ú__classcell__)rl   s   @r   r�   r�   f  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�   rr   r¬   )r{   rš   Úset_output_for_transforms      r   Ú_safe_set_outputr±   ´  s–   € õ.  ' y°+Ñ>Ô>ð  Ý�	˜?Ñ+Ô+ÐE°	ÀÐ0Eð ð $ð ð 	ˆå�9˜lÑ+Ô+ð 
Ýð ¨ið  ð  ð  ñ
ô 
ð 	
ð ×Ò¨)ÐÑ4Ô4Ð4r%   rA   ) r   Ú	functoolsr   Útypingr   r   ÚnumpyrQ   Úscipy.sparser   Úsklearn._configr   Úsklearn.utils._available_ifr	   Úsklearn.utils.fixesr
   r   r   r   r4   rK   r]   rn   rh   rv   r}   ry   r‹   r—   r…   r�   r±   r   r%   r   ú<module>r¹      sm  ðð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à &Ð &Ð &Ð &Ð &Ð &Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø -Ð -Ð -Ð -Ð -Ð -ðð ð ð	ð 	ð 	ð ðJð Jð Jð Jð J˜xñ Jô Jñ ÔðJðZ'%ð '%ð '%ð '%ð '%ñ '%ô '%ð '%ðT#&ð #&ð #&ð #&ð #&ñ #&ô #&ð #&ðL	7ð 	7ð 	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð ,Ð+Ñ-Ô-Ð Ø × Ò ˜-˜-™/œ/Ñ *Ô *Ð *Ø × Ò ˜-˜-™/œ/Ñ *Ô *Ð *ðð ð ð$ð ð ð ð #ð  #ð  #ð  #ðF+ð +ð +ð\ð ð ð.
ð 
ð 
ðKð Kð Kð Kð Kñ Kô Kð Kð\ .2ð $5ð $5ð $5ð $5ð $5ð $5ð $5r%   