§
    ¥˜ºh2&  ã                   óŽ   — 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	œd
„Z
dd„Zd„ Zd„ Zd„ Z G d„ d¦  «        Zddœd„ZdS )é    ©Úwraps)Úissparseé   )Ú
get_configé   )Úcheck_pandas_support)Úavailable_ifN)Úindexc                ó(  — t          | ¦  «        rt          d¦  «        ‚t          |¦  «        r	  |¦   «         }n# t          $ r d}Y nw xY wt	          d¦  «        }t          | |j        ¦  «        r|�|| _        | S |                     | ||d¬¦  «        S )aA  Create a Pandas DataFrame.

    If `data_to_wrap` is a DataFrame, then the `columns` and `index` will be changed
    inplace. If `data_to_wrap` is a ndarray, then a new DataFrame is created with
    `columns` and `index`.

    Parameters
    ----------
    data_to_wrap : {ndarray, dataframe}
        Data to be wrapped as pandas dataframe.

    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 `columns` is a callable that raises an error, `columns` will have
        the same semantics as `None`. If `None` and `data_to_wrap` is already a
        dataframe, then the column names are not changed. If `None` and
        `data_to_wrap` is **not** a dataframe, then columns are
        `range(n_features)`.

    index : array-like, default=None
        Index for data. `index` is ignored if `data_to_wrap` is already a DataFrame.

    Returns
    -------
    dataframe : DataFrame
        Container with column names or unchanged `output`.
    z+Pandas output does not support sparse data.Nz$Setting output container to 'pandas'F)r   ÚcolumnsÚcopy)r   Ú
ValueErrorÚcallableÚ	Exceptionr	   Ú
isinstanceÚ	DataFramer   )Údata_to_wrapr   r   Úpds       úa/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/sklearn/utils/_set_output.pyÚ_wrap_in_pandas_containerr   
   s½   € õD �ÑÔð HÝÐFÑGÔGÐGå�ÑÔð ð	Ø�g‘i”iˆGˆGøÝð 	ð 	ð 	ØˆGˆGˆGð	øøøõ 
ÐDÑ	EÔ	E€Bå�, ¤Ñ-Ô-ð ØÐØ#*ˆLÔ ØÐà�<Š<˜¨E¸7Èˆ<ÑOÔOÐOs   ¯
: ºA	ÁA	c                 ó    — t          |di ¦  «        }| |v r	||          }nt          ¦   «         | › d�         }|dvr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Ú_output>   ÚpandasÚdefaultz0output config must be 'default' or 'pandas' got Údense)Úgetattrr   r   )ÚmethodÚ	estimatorÚest_sklearn_output_configÚdense_configs       r   Ú_get_output_configr#   ?   s|   € õ( !(¨	Ð3KÈRÑ PÔ PÐØÐ*Ð*Ð*Ø0°Ô8ˆˆå!‘|”| vÐ$6Ð$6Ð$6Ô7ˆàÐ0Ð0Ð0ÝØM¸|ÐMÐMñ
ô 
ð 	
ð �\Ð"Ð"ó    c                 ó¸   — t          | |¦  «        }|d         dk    st          |¦  «        s|S d„ } ||¦  «        r|j        nd}t          |||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.
    r   r   c                 ó¸   — ddl }t          | d¦  «        rEt          | d¦  «        r5	 |j        d         }n# t          $ r Y dS w xY wt	          | |j        ¦  «        S dS )zvReturn True if the X is a pandas dataframe.

        This is is backport from 1.4 in 1.3.1 for compatibility.
        r   Nr   Úilocr   F)ÚsysÚhasattrÚmodulesÚKeyErrorr   r   )ÚXr(   r   s      r   Ú_is_pandas_dfz0_wrap_data_with_container.<locals>._is_pandas_df   s|   € ð
 	ˆ
ˆ
ˆ
å�1�iÑ Ô ð 	/¥W¨Q°Ñ%7Ô%7ð 	/ðØ”[ Ô*��øÝð ð ð Ø�u�uðøøøå˜a ¤Ñ.Ô.Ð.Øˆus   ¦4 ´
AÁAN)r   r   r   )r#   Ú_auto_wrap_is_configuredr   r   Úget_feature_names_out)r   r   Úoriginal_inputr    Úoutput_configr-   r   s          r   Ú_wrap_data_with_containerr2   a   s‡   € õ2 ' v¨yÑ9Ô9€Mà�WÔ Ò*Ð*Õ2JÈ9Ñ2UÔ2UÐ*ØÐðð ð ð" %2 M°.Ñ$AÔ$AÐKˆNÔ Ð Àt€EÝ$Ø!ØØÔ/ðñ ô ð 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   Útupler2   r)   Útyper5   )Úselfr,   ÚargsÚkwargsr   Úreturn_tupleÚfr   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<   r   r=   s   `` r   Ú_wrap_method_outputr>   ˜   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   Úsetr)   )r    Úauto_wrap_output_keyss     r   r.   r.   ¯   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.
    ©rA   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.rA   )rA   Úfit_transform© )ÚsuperÚ__init_subclass__r   r6   r   rB   r@   Úitemsr)   ÚaddÚ__dict__r>   r   Úsetattr)ÚclsrC   r:   Úmethod_to_keyr   ÚkeyÚwrapped_methodÚ	__class__s          €r   rK   z!_SetOutputMixin.__init_subclass__Æ   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 )aD  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"}, default=None
            Configure output of `transform` and `fit_transform`.

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

        Returns
        -------
        self : estimator instance
            Estimator instance.
        Nr   rA   )r)   r   )r8   rA   s     r   Ú
set_outputz_SetOutputMixin.set_outputæ   s<   € ð* ÐØˆKå�tÐ5Ñ6Ô6ð 	-Ø*,ˆDÔ'à3<ˆÔ# KÑ0Øˆr$   )rF   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rK   r
   r.   rV   Ú__classcell__)rT   s   @r   rE   rE   ¼   s|   ø€ € € € € ðð ð1ð 1ð 1ð 1ð 1ð 1ð@ €\Ð*Ñ+Ô+Ø&*ð ð ð ð ñ ,Ô+ðð ð ð ð r$   rE   rF   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"}, 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.
    rA   rH   NrV   zUnable to configure output for z' because `set_output` is not available.rF   )r)   r   rV   )r    rA   Úset_output_for_transforms      r   Ú_safe_set_outputr^     s™   € õ0 	�	˜;Ñ'Ô'ð 	"Ý�9˜oÑ.Ô.ð "Ø˜TÐ!ð ð
 $ð ð 	ˆå�9˜lÑ+Ô+ð 
Ýð ¨ið  ð  ð  ñ
ô 
ð 	
ð ×Ò¨)ÐÑ4Ô4Ð4r$   )N)Ú	functoolsr   Úscipy.sparser   Ú_configr   Ú r	   Ú_available_ifr
   r   r#   r2   r>   r.   rE   r^   rI   r$   r   ú<module>rd      s  ðØ Ð Ð Ð Ð Ð à !Ð !Ð !Ð !Ð !Ð !à  Ð  Ð  Ð  Ð  Ð  Ø "Ð "Ð "Ð "Ð "Ð "Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'ð ð	2Pð 2Pð 2Pð 2Pð 2Pðj#ð #ð #ð #ðD4ð 4ð 4ðnð ð ð.
ð 
ð 
ðFð Fð Fð Fð Fñ Fô Fð FðR .2ð &5ð &5ð &5ð &5ð &5ð &5ð &5r$   