
    2VhO	                         	 d dl Z d dlmZ d dlmZ d Zd	 Z G d
 dee      Zy# e$ r dZ  G d d      Z G d d      ZY 0w xY w)    N)BaseEstimator)TransformerMixinc                       e Zd Zy)r   N__name__
__module____qualname__     H/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/wrappers/utils.pyr   r          r   r   c                       e Zd Zy)r   Nr   r
   r   r   r   r      r   r   r   c                 ,    t         t        |  d      y )NzW requires `scikit-learn` to be installed. Run `pip install scikit-learn` to install it.)sklearnImportError)symbol_names    r   assert_sklearn_installedr      s(    m < <
 	
 r   c                 b    | j                   r| j                  r| j                  st        d      y)z-Check whether the model need sto be compiled.zCGiven model needs to be compiled, and have a loss and an optimizer.N)compiledloss	optimizerRuntimeError)models    r   _check_modelr      s/     >>5??
 	
 4Cr   c                   "    e Zd ZdZd Zd Zd Zy)TargetReshapera   Convert 1D targets to 2D and back.

    For use in pipelines with transformers that only accept
    2D inputs, like OneHotEncoder and OrdinalEncoder.

    Attributes:
        ndim_ : int
            Dimensions of y that the transformer was trained on.
    c                 (    |j                   | _        | S )zFit the transformer to a target y.

        Returns:
            TargetReshaper
                A reference to the current instance of TargetReshaper.
        )ndimndim_selfys     r   fitzTargetReshaper.fit,   s     VV
r   c                 H    |j                   dk(  r|j                  dd      S |S )zMakes 1D y 2D.

        Args:
            y : np.ndarray
                Target y to be transformed.

        Returns:
            np.ndarray
                A numpy array, of dimension at least 2.
           )r   reshaper    s     r   	transformzTargetReshaper.transform6   s%     66Q;99R##r   c                     t         j                  j                  |        t         j                  j                  j                  |      \  }}| j                  dk(  r"|j                  dk(  r|j                  |d      S |S )a  Revert the transformation of transform.

        Args:
            y: np.ndarray
                Transformed numpy array.

        Returns:
            np.ndarray
                If the transformer was fit to a 1D numpy array,
                and a 2D numpy array with a singleton second dimension
                is passed, it will be squeezed back to 1D. Otherwise, it
                will eb left untouched.
        r%      )axis)	r   basecheck_is_fittedutils
_array_apiget_namespacer   r   squeeze)r!   r"   xp_s       r   inverse_transformz TargetReshaper.inverse_transformE   sa     	$$T*((66q9A::?qvv{::aa:((r   N)r   r   r	   __doc__r#   r(   r4   r
   r   r   r   r   !   s    r   r   )r   sklearn.baser   r   r   r   r   r   r
   r   r   <module>r7      sV   *-

6%} 69  G  s   % AA