§
    qŠtjÈg  ã                   óH  — d Z ddlZddlmZmZ ddlZddlmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZmZmZ ddlmZmZmZmZ dd	lmZmZ d
dgZd„ Zd„ Zd„ Zd„ Z d"d„Z!d„ Z"d„ Z# edgdgdgdgdœd¬¦  «        	 d"dddddddddddddœd „¦   «         Z$ G d!„ d
eee
¦  «        Z%dS )#z�
Python implementation of the fast ICA algorithms.

Reference: Tables 8.3 and 8.4 page 196 in the book:
Independent Component Analysis, by  Hyvarinen et al.
é    N)ÚIntegralÚReal)Úlinalg)ÚBaseEstimatorÚClassNamePrefixFeaturesOutMixinÚTransformerMixinÚ_fit_context)ÚConvergenceWarning)Úas_float_arrayÚcheck_arrayÚcheck_random_state)ÚIntervalÚOptionsÚ
StrOptionsÚvalidate_params)Úcheck_is_fittedÚvalidate_dataÚFastICAÚfasticac                 óz   — | t           j                             | |d|…         j        |d|…         g¦  «        z  } | S )a‘  
    Orthonormalize w wrt the first j rows of W.

    Parameters
    ----------
    w : ndarray of shape (n,)
        Array to be orthogonalized

    W : ndarray of shape (p, n)
        Null space definition

    j : int < p
        The no of (from the first) rows of Null space W wrt which w is
        orthogonalized.

    Notes
    -----
    Assumes that W is orthogonal
    w changed in place
    N)Únpr   Ú	multi_dotÚT)ÚwÚWÚjs      ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/decomposition/_fastica.pyÚ_gs_decorrelationr   $   s<   € ð* �Œ×	Ò	˜a  2 A 2¤¤¨!¨B¨Q¨B¬%Ð0Ñ	1Ô	1Ñ1€AØ€Hó    c                 óD  — t          j        t          j        | | j        ¦  «        ¦  «        \  }}t          j        |t          j        | j        ¦  «        j        d¬¦  «        }t          j          	                    |dt          j
        |¦  «        z  z  |j        | g¦  «        S )z@Symmetric decorrelation
    i.e. W <- (W * W.T) ^{-1/2} * W
    N)Úa_minÚa_maxç      ð?)r   Úeighr   Údotr   ÚclipÚfinfoÚdtypeÚtinyr   Úsqrt)r   ÚsÚus      r   Ú_sym_decorrelationr-   =   s}   € õ Œ;•r”v˜a ¤‘~”~Ñ&Ô&�D€A€qõ 	Œ��œ !¤'Ñ*Ô*Ô/°tÐ<Ñ<Ô<€Aõ Œ9×Ò  S­2¬7°1©:¬:Ñ%5Ñ 6¸¼¸QÐ?Ñ@Ô@Ð@r   c                 óX  — |j         d         }t          j        ||f| j        ¬¦  «        }g }t	          |¦  «        D �]]}	||	dd…f                              ¦   «         }
|
t          j        |
dz                       ¦   «         ¦  «        z  }
t	          |¦  «        D ]ß} |t          j        |
j	        | ¦  «        |¦  «        \  }}| |z   
                    d¬¦  «        | 
                    ¦   «         |
z  z
  }t          |||	¦  «         |t          j        |dz                       ¦   «         ¦  «        z  }t          j        t          j        ||
z                       ¦   «         ¦  «        dz
  ¦  «        }|}
||k     r nŒà|                     |dz   ¦  «         |
||	dd…f<   �Œ_|t          |¦  «        fS )zcDeflationary FastICA using fun approx to neg-entropy function

    Used internally by FastICA.
    r   ©r(   Né   é   ©Úaxis)Úshaper   Úzerosr(   ÚrangeÚcopyr*   Úsumr%   r   Úmeanr   ÚabsÚappendÚmax)ÚXÚtolÚgÚfun_argsÚmax_iterÚw_initÚn_componentsr   Ún_iterr   r   ÚiÚgwtxÚg_wtxÚw1Úlims                   r   Ú_ica_defrJ   L   s“  € ð ”< ”?€LÝ
Œ�, Ð-°Q´WÐ=Ñ=Ô=€AØ€Fõ �<Ñ Ô ð ñ ˆØ�1�a�a�a�4ŒL×ÒÑÔˆØ	�RŒW�a˜‘d—Z’Z‘\”\Ñ"Ô"Ñ"ˆå�x‘”ð 	ð 	ˆAØ˜!�BœF 1¤3¨™NœN¨HÑ5Ô5‰KˆD�%à�d‘(—’ a�Ñ(Ô(¨5¯:ª:©<¬<¸!Ñ+;Ñ;ˆBå˜b ! QÑ'Ô'Ð'à•"”'˜2˜q™5Ÿ+š+™-œ-Ñ(Ô(Ñ(ˆBå”&�œ  a¡§¢¡¤Ñ/Ô/°!Ñ3Ñ4Ô4ˆCØˆAØ�SŠyˆyØ�ð ð 	�Š�a˜!‘eÑÔÐØˆˆ!ˆQˆQˆQˆ$‰‰à�c�&‰kŒkˆ>Ðr   c                 ó   — t          |¦  «        }~t          | j        d         ¦  «        }t          |¦  «        D ]´} |t	          j        || ¦  «        |¦  «        \  }	}
t          t	          j        |	| j        ¦  «        |z  |
dd…t          j        f         |z  z
  ¦  «        }~	~
t          t          t          t	          j
        d||¦  «        ¦  «        dz
  ¦  «        ¦  «        }|}||k     r nŒµt          j        dt          ¦  «         ||dz   fS )zCParallel FastICA.

    Used internally by FastICA --main loop

    r1   Nzij,ij->iz\FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.)r-   Úfloatr4   r6   r   r%   r   Únewaxisr<   r:   ÚeinsumÚwarningsÚwarnr
   )r=   r>   r?   r@   rA   rB   r   Úp_ÚiirF   rG   ÚW1rI   s                r   Ú_ica_parrT   o   s  € õ 	˜6Ñ"Ô"€AØÝ	ˆqŒw�qŒzÑ	Ô	€BÝ�H‰oŒoð 
ð 
ˆØ�a�œ˜q !™œ hÑ/Ô/‰ˆˆeÝ¥¤ t¨Q¬SÑ 1Ô 1°BÑ 6¸¸q¸q¸qÅ"Ä*¸}Ô9MÐPQÑ9QÑ QÑRÔRˆØ�%õ •#•c�"œ) J°°AÑ6Ô6Ñ7Ô7¸!Ñ;Ñ<Ô<Ñ=Ô=ˆØˆØ�Š9ˆ9ØˆEð õ 	ŒðAõ ñ	
ô 	
ð 	
ð ˆb�1‰fˆ9Ðr   c                 óP  — |                      dd¦  «        }| |z  } t          j        | | ¦  «        }| j        dk    r||d|dz  z
  z  fS t          j        | j        d         | j        ¬¦  «        }t          |¦  «        D ]%\  }}|d|dz  z
  z                       ¦   «         ||<   Œ&||fS )NÚalphar#   r1   r0   r   r/   )	Úgetr   ÚtanhÚndimÚemptyr4   r(   Ú	enumerater9   )Úxr@   rV   ÚgxÚg_xrE   Úgx_is          r   Ú_logcoshr`   �   s´   € Ø�LŠL˜ #Ñ&Ô&€Eàˆ�J€AÝ	Œ��A‰Œ€Bà„v�‚{€{Ø�5˜A  A¡™IÑ&Ð&Ð&õ Œ(�1”7˜1”: Q¤WÐ
-Ñ
-Ô
-€CÝ˜R‘=”=ð 0ð 0‰ˆˆ4Ø˜1˜t Q™w™;Ñ'×-Ò-Ñ/Ô/ˆˆA‰ˆØˆsˆ7€Nr   c                 óˆ   — t          j        | dz   dz  ¦  «        }| |z  }d| dz  z
  |z  }||                     d¬¦  «        fS )Nr0   r1   éÿÿÿÿr2   )r   Úexpr9   )r\   r@   rc   r]   r^   s        r   Ú_exprd       sO   € Ý
Œ&�1�a‘4�˜1‘Ñ
Ô
€CØ	
ˆS‰€BØˆq�!‰t‰8�sÑ
€CØˆs�xŠx˜RˆxÑ Ô Ð Ð r   c                 óD   — | dz  d| dz  z                        d¬¦  «        fS )Né   r0   rb   r2   )r9   )r\   r@   s     r   Ú_cuberg   §   s'   € Øˆa‰4�!�a˜‘d‘(—’ b�Ñ)Ô)Ð)Ð)r   ú
array-likeÚboolean)r=   Úreturn_X_meanÚcompute_sourcesÚreturn_n_iterF©Úprefer_skip_nested_validationÚparallelúunit-varianceÚlogcoshéÈ   ç-Cëâ6?ÚsvdT)Ú	algorithmÚwhitenÚfunr@   rA   r>   rB   Úwhiten_solverÚrandom_staterj   rk   rl   c                ó@  — t          |||||||||	|
¬¦
  «
        }|                     ¦   «          |                     | |¬¦  «        }|j        dv r|j        }|j        }nd}d}||j        |g}|r|                     |¦  «         |r|                     |j        ¦  «         |S )a#  Perform Fast Independent Component Analysis.

    The implementation is based on [1]_.

    Read more in the :ref:`User Guide <ICA>`.

    Parameters
    ----------
    X : array-like of shape (n_samples, n_features)
        Training vector, where `n_samples` is the number of samples and
        `n_features` is the number of features.

    n_components : int, default=None
        Number of components to use. If None is passed, all are used.

    algorithm : {'parallel', 'deflation'}, default='parallel'
        Specify which algorithm to use for FastICA.

    whiten : str or bool, default='unit-variance'
        Specify the whitening strategy to use.

        - If 'arbitrary-variance', a whitening with variance
          arbitrary is used.
        - If 'unit-variance', the whitening matrix is rescaled to ensure that
          each recovered source has unit variance.
        - If False, the data is already considered to be whitened, and no
          whitening is performed.

        .. versionchanged:: 1.3
            The default value of `whiten` changed to 'unit-variance' in 1.3.

    fun : {'logcosh', 'exp', 'cube'} or callable, default='logcosh'
        The functional form of the G function used in the
        approximation to neg-entropy. Could be either 'logcosh', 'exp',
        or 'cube'.
        You can also provide your own function. It should return a tuple
        containing the value of the function, and of its derivative, in the
        point. The derivative should be averaged along its last dimension.
        Example::

            def my_g(x):
                return x ** 3, (3 * x ** 2).mean(axis=-1)

    fun_args : dict, default=None
        Arguments to send to the functional form.
        If empty or None and if fun='logcosh', fun_args will take value
        {'alpha' : 1.0}.

    max_iter : int, default=200
        Maximum number of iterations to perform.

    tol : float, default=1e-4
        A positive scalar giving the tolerance at which the
        un-mixing matrix is considered to have converged.

    w_init : ndarray of shape (n_components, n_components), default=None
        Initial un-mixing array. If `w_init=None`, then an array of values
        drawn from a normal distribution is used.

    whiten_solver : {"eigh", "svd"}, default="svd"
        The solver to use for whitening.

        - "svd" is more stable numerically if the problem is degenerate, and
          often faster when `n_samples <= n_features`.

        - "eigh" is generally more memory efficient when
          `n_samples >= n_features`, and can be faster when
          `n_samples >= 50 * n_features`.

        .. versionadded:: 1.2

    random_state : int, RandomState instance or None, default=None
        Used to initialize ``w_init`` when not specified, with a
        normal distribution. Pass an int, for reproducible results
        across multiple function calls.
        See :term:`Glossary <random_state>`.

    return_X_mean : bool, default=False
        If True, X_mean is returned too.

    compute_sources : bool, default=True
        If False, sources are not computed, but only the rotation matrix.
        This can save memory when working with big data. Defaults to True.

    return_n_iter : bool, default=False
        Whether or not to return the number of iterations.

    Returns
    -------
    K : ndarray of shape (n_components, n_features) or None
        If whiten is 'True', K is the pre-whitening matrix that projects data
        onto the first n_components principal components. If whiten is 'False',
        K is 'None'.

    W : ndarray of shape (n_components, n_components)
        The square matrix that unmixes the data after whitening.
        The mixing matrix is the pseudo-inverse of matrix ``W K``
        if K is not None, else it is the inverse of W.

    S : ndarray of shape (n_samples, n_components) or None
        Estimated source matrix.

    X_mean : ndarray of shape (n_features,)
        The mean over features. Returned only if return_X_mean is True.

    n_iter : int
        If the algorithm is "deflation", n_iter is the
        maximum number of iterations run across all components. Else
        they are just the number of iterations taken to converge. This is
        returned only when return_n_iter is set to `True`.

    Notes
    -----
    The data matrix X is considered to be a linear combination of
    non-Gaussian (independent) components i.e. X = AS where columns of S
    contain the independent components and A is a linear mixing
    matrix. In short ICA attempts to `un-mix' the data by estimating an
    un-mixing matrix W where ``S = W K X.``
    While FastICA was proposed to estimate as many sources
    as features, it is possible to estimate less by setting
    n_components < n_features. It this case K is not a square matrix
    and the estimated A is the pseudo-inverse of ``W K``.

    This implementation was originally made for data of shape
    [n_features, n_samples]. Now the input is transposed
    before the algorithm is applied. This makes it slightly
    faster for Fortran-ordered input.

    References
    ----------
    .. [1] A. Hyvarinen and E. Oja, "Fast Independent Component Analysis",
           Algorithms and Applications, Neural Networks, 13(4-5), 2000,
           pp. 411-430.

    Examples
    --------
    >>> from sklearn.datasets import load_digits
    >>> from sklearn.decomposition import fastica
    >>> X, _ = load_digits(return_X_y=True)
    >>> K, W, S = fastica(X, n_components=7, random_state=0, whiten='unit-variance')
    >>> K.shape
    (7, 64)
    >>> W.shape
    (7, 7)
    >>> S.shape
    (1797, 7)
    ©
rC   ru   rv   rw   r@   rA   r>   rB   rx   ry   ©rk   )rp   úarbitrary-varianceN)	r   Ú_validate_paramsÚ_fit_transformrv   Ú
whitening_Úmean_Ú	_unmixingr;   Ún_iter_)r=   rC   ru   rv   rw   r@   rA   r>   rB   rx   ry   rj   rk   rl   ÚestÚSÚKÚX_meanÚreturned_valuess                      r   r   r   «   sÙ   € õZ Ø!ØØØØØØØØ#Ø!ðñ ô €Cð ×ÒÑÔÐØ×Ò˜1¨oÐÑ>Ô>€Aà
„zÐ<Ð<Ð<ØŒNˆØ”ˆˆàˆØˆà˜#œ-¨Ð+€OØð 'Ø×Ò˜vÑ&Ô&Ð&Øð ,Ø×Ò˜sœ{Ñ+Ô+Ð+àÐr   c                   óÌ  ‡ — e Zd ZU dZ eeddd¬¦  «        dg eddh¦  «        g edd	h¦  «         eed
h¦  «        g eh d£¦  «        e	ge
dg eeddd¬¦  «        g eeddd¬¦  «        gddg eddh¦  «        gdgdœ
Ze
ed<   	 d!dd	ddddddddœ	ˆ fd„Zd"d„Z ed¬¦  «        d!d„¦   «         Z ed¬¦  «        d!d„¦   «         Zd#d„Zd#d„Zed„ ¦   «         Zˆ fd „Zˆ xZS )$r   aõ  FastICA: a fast algorithm for Independent Component Analysis.

    The implementation is based on [1]_.

    Read more in the :ref:`User Guide <ICA>`.

    Parameters
    ----------
    n_components : int, default=None
        Number of components to use. If None is passed, all are used.

    algorithm : {'parallel', 'deflation'}, default='parallel'
        Specify which algorithm to use for FastICA.

    whiten : str or bool, default='unit-variance'
        Specify the whitening strategy to use.

        - If 'arbitrary-variance', a whitening with variance
          arbitrary is used.
        - If 'unit-variance', the whitening matrix is rescaled to ensure that
          each recovered source has unit variance.
        - If False, the data is already considered to be whitened, and no
          whitening is performed.

        .. versionchanged:: 1.3
            The default value of `whiten` changed to 'unit-variance' in 1.3.

    fun : {'logcosh', 'exp', 'cube'} or callable, default='logcosh'
        The functional form of the G function used in the
        approximation to neg-entropy. Could be either 'logcosh', 'exp',
        or 'cube'.
        You can also provide your own function. It should return a tuple
        containing the value of the function, and of its derivative, in the
        point. The derivative should be averaged along its last dimension.
        Example::

            def my_g(x):
                return x ** 3, (3 * x ** 2).mean(axis=-1)

    fun_args : dict, default=None
        Arguments to send to the functional form.
        If empty or None and if fun='logcosh', fun_args will take value
        {'alpha' : 1.0}.

    max_iter : int, default=200
        Maximum number of iterations during fit.

    tol : float, default=1e-4
        A positive scalar giving the tolerance at which the
        un-mixing matrix is considered to have converged.

    w_init : array-like of shape (n_components, n_components), default=None
        Initial un-mixing array. If `w_init=None`, then an array of values
        drawn from a normal distribution is used.

    whiten_solver : {"eigh", "svd"}, default="svd"
        The solver to use for whitening.

        - "svd" is more stable numerically if the problem is degenerate, and
          often faster when `n_samples <= n_features`.

        - "eigh" is generally more memory efficient when
          `n_samples >= n_features`, and can be faster when
          `n_samples >= 50 * n_features`.

        .. versionadded:: 1.2

    random_state : int, RandomState instance or None, default=None
        Used to initialize ``w_init`` when not specified, with a
        normal distribution. Pass an int, for reproducible results
        across multiple function calls.
        See :term:`Glossary <random_state>`.

    Attributes
    ----------
    components_ : ndarray of shape (n_components, n_features)
        The linear operator to apply to the data to get the independent
        sources. This is equal to the unmixing matrix when ``whiten`` is
        False, and equal to ``np.dot(unmixing_matrix, self.whitening_)`` when
        ``whiten`` is True.

    mixing_ : ndarray of shape (n_features, n_components)
        The pseudo-inverse of ``components_``. It is the linear operator
        that maps independent sources to the data.

    mean_ : ndarray of shape(n_features,)
        The mean over features. Only set if `self.whiten` is True.

    n_features_in_ : int
        Number of features seen during :term:`fit`.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    n_iter_ : int
        If the algorithm is "deflation", n_iter is the
        maximum number of iterations run across all components. Else
        they are just the number of iterations taken to converge.

    whitening_ : ndarray of shape (n_components, n_features)
        Only set if whiten is 'True'. This is the pre-whitening matrix
        that projects data onto the first `n_components` principal components.

    See Also
    --------
    PCA : Principal component analysis (PCA).
    IncrementalPCA : Incremental principal components analysis (IPCA).
    KernelPCA : Kernel Principal component analysis (KPCA).
    MiniBatchSparsePCA : Mini-batch Sparse Principal Components Analysis.
    SparsePCA : Sparse Principal Components Analysis (SparsePCA).

    References
    ----------
    .. [1] A. Hyvarinen and E. Oja, Independent Component Analysis:
           Algorithms and Applications, Neural Networks, 13(4-5), 2000,
           pp. 411-430.

    Examples
    --------
    >>> from sklearn.datasets import load_digits
    >>> from sklearn.decomposition import FastICA
    >>> X, _ = load_digits(return_X_y=True)
    >>> transformer = FastICA(n_components=7,
    ...         random_state=0,
    ...         whiten='unit-variance')
    >>> X_transformed = transformer.fit_transform(X)
    >>> X_transformed.shape
    (1797, 7)
    r1   NÚleft)Úclosedro   Ú	deflationr}   rp   F>   rc   Úcuberq   g        rh   r$   rt   ry   r{   Ú_parameter_constraintsrq   rr   rs   )	ru   rv   rw   r@   rA   r>   rB   rx   ry   c       	         óÔ   •— t          ¦   «                              ¦   «          || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        d S ©N)ÚsuperÚ__init__rC   ru   rv   rw   r@   rA   r>   rB   rx   ry   )ÚselfrC   ru   rv   rw   r@   rA   r>   rB   rx   ry   Ú	__class__s              €r   r’   zFastICA.__init__  sj   ø€ õ 	‰Œ×ÒÑÔÐØ(ˆÔØ"ˆŒØˆŒØˆŒØ ˆŒØ ˆŒØˆŒØˆŒØ*ˆÔØ(ˆÔÐÐr   c                 ó˜	  ‡ — t          ‰ |‰ j        t          j        t          j        gd¬¦  «        j        }‰ j        €i n‰ j        }t          ‰ j        ¦  «        }| 	                    dd¦  «        }d|cxk    rdk    sn t          d¦  «        ‚‰ j        dk    rt          }n?‰ j        d	k    rt          }n,‰ j        d
k    rt          }nt          ‰ j        ¦  «        rˆ fd„}|j        \  }}	‰ j        }
‰ j        s|
�d}
t%          j        d¦  «         |
€t)          |	|¦  «        }
|
t)          |	|¦  «        k    r't)          |	|¦  «        }
t%          j        d|
z  ¦  «         ‰ j        �r‹|                     d¬¦  «        }||dd…t          j        f         z  }‰ j        dk    rÆt1          j        |                     |¦  «        ¦  «        \  }}t          j        |¦  «        ddd…         }t          j        |j        ¦  «        j        dz  }||k     }t          j        |¦  «        rt%          j        d¦  «         |||<   t          j         ||¬¦  «         ||         |dd…|f         }}n-‰ j        dk    r"t1          j!        |dd¬¦  «        dd…         \  }}|t          j"        |d         ¦  «        z  }||z  j        d|
…         }~~t          j        ||¦  «        }|t          j         |	¦  «        z  }ntG          |d¬¦  «        }‰ j$        }|€2t          j%        | &                    |
|
f¬¦  «        |j        ¬¦  «        }n7t          j%        |¦  «        }|j        |
|
fk    rt          dd|
|
fiz  ¦  «        ‚‰ j'        ||‰ j(        |dœ}‰ j)        dk    rtU          |fi |¤Ž\  }}n‰ j)        dk    rtW          |fi |¤Ž\  }}~|‰ _,        |rJ‰ j        r(t          j         -                    |||g¦  «        j        }nt          j        ||¦  «        j        }nd}‰ j        rƒ‰ j        d k    rO|s't          j         -                    |||g¦  «        j        }t          j.        |dd!¬"¦  «        }||z  }||j        z  }t          j        ||¦  «        ‰ _/        |‰ _0        |‰ _1        n|‰ _/        t1          j2        ‰ j/        d¬#¦  «        ‰ _3        |‰ _4        |S )$ad  Fit the model.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.

        compute_sources : bool, default=False
            If False, sources are not computes but only the rotation matrix.
            This can save memory when working with big data. Defaults to False.

        Returns
        -------
        S : ndarray of shape (n_samples, n_components) or None
            Sources matrix. `None` if `compute_sources` is `False`.
        r0   )r7   r(   Úensure_min_samplesNrV   r#   r1   zalpha must be in [1,2]rq   rc   r�   c                 ó    •—  ‰j         | fi |¤ŽS r�   )rw   )r\   r@   r“   s     €r   r?   z!FastICA._fit_transform.<locals>.gQ  s   ø€ Ø�t”x Ð.Ð. XÐ.Ð.Ð.r   z(Ignoring n_components with whiten=False.z/n_components is too large: it will be set to %srb   r2   r$   é
   zfThere are some small singular values, using whiten_solver = 'svd' might lead to more accurate results.)Úoutrt   F)Úfull_matricesÚcheck_finiter   )r7   )Úsizer/   z/w_init has invalid shape -- should be %(shape)sr4   )r>   r?   r@   rA   rB   ro   rŒ   rp   T)r3   Úkeepdims)r›   )5r   rv   r   Úfloat64Úfloat32r   r@   r   ry   rW   Ú
ValueErrorrw   r`   rd   rg   Úcallabler4   rC   rO   rP   Úminr9   rM   rx   r   r$   r%   Úargsortr'   r(   ÚepsÚanyr*   rt   Úsignr   rB   ÚasarrayÚnormalr>   rA   ru   rT   rJ   rƒ   r   ÚstdÚcomponents_r�   r€   ÚpinvÚmixing_r‚   )r“   r=   rk   ÚXTr@   ry   rV   r?   Ú
n_featuresÚ	n_samplesrC   r‡   Údr,   Úsort_indicesr¤   Údegenerate_idxr†   ÚX1rB   Úkwargsr   rD   r…   ÚS_stds   `                        r   r   zFastICA._fit_transform)  s;  ø€ õ$ ØØØ”Ý”:�rœzÐ*Ø ð
ñ 
ô 
ô ð 	ð œÐ.�2�2°D´MˆÝ)¨$Ô*;Ñ<Ô<ˆà—’˜W cÑ*Ô*ˆØ�EˆˆŠˆ˜QŠˆˆˆÝÐ5Ñ6Ô6Ð6àŒ8�yÒ Ð ÝˆAˆAØŒX˜ÒÐÝˆAˆAØŒX˜ÒÐÝˆAˆAÝ�d”hÑÔð 	/ð/ð /ð /ð /ð /ð !#¤Ñˆ
�IØÔ(ˆØŒ{ð 	F˜|Ð7ØˆLÝŒMÐDÑEÔEÐEàÐÝ˜y¨*Ñ5Ô5ˆLØ�#˜i¨Ñ4Ô4Ò4Ð4Ý˜y¨*Ñ5Ô5ˆLÝŒMØAÀLÑPñô ð ð Œ;ñ $	0à—W’W "�WÑ%Ô%ˆFØ�&˜˜˜�BœJ˜Ô'Ñ'ˆBð Ô! VÒ+Ð+å”{ 2§6¢6¨!¡9¤9Ñ-Ô-‘��1Ý!œz¨!™}œ}¨T¨T¨r¨TÔ2�Ý”h˜qœwÑ'Ô'Ô+¨bÑ0�Ø!" S¢�Ý”6˜.Ñ)Ô)ð Ý”Mð,ñô ð ð
 %(��.Ñ!Ý”˜˜qÐ!Ñ!Ô!Ð!Ø˜”¨¨!¨!¨!¨\¨/Ô(:�1��ØÔ# uÒ,Ð,Ý”z "°EÈÐNÑNÔNÈrÐPQÈrÔR‘��1ð •”˜˜1œ‘”ÑˆAà�Q‘”	˜-˜<˜-Ô(ˆAØ�1Ý”˜˜2‘”ˆBð •"”'˜)Ñ$Ô$Ñ$ˆBˆBõ   ¨Ð/Ñ/Ô/ˆBà”ˆØˆ>Ý”ZØ×#Ò#¨,¸Ð)EÐ#ÑFÔFÈbÌhðñ ô ˆFˆFõ
 ”Z Ñ'Ô'ˆFØŒ| ¨lÐ;Ò;Ð;Ý ØEØ ¨|Ð <Ð=ñ>ñô ð ð ”8ØØ ØœØð
ð 
ˆð Œ>˜ZÒ'Ð'Ý  Ð.Ð. vÐ.Ð.‰IˆAˆvˆvØŒ^˜{Ò*Ð*Ý  Ð.Ð. vÐ.Ð.‰IˆAˆvØàˆŒàð 	ØŒ{ð $Ý”I×'Ò'¨¨A¨r¨
Ñ3Ô3Ô5��å”F˜1˜b‘M”M”O��àˆAàŒ;ð 	!ØŒ{˜oÒ-Ð-Ø&ð :Ýœ	×+Ò+¨Q°°2¨JÑ7Ô7Ô9�AÝœ˜q q°4Ð8Ñ8Ô8�Ø�U‘
�Ø�U”W‘�å!œv a¨™|œ|ˆDÔØˆDŒJØˆDŒOˆOà ˆDÔå”{ 4Ô#3À%ÐHÑHÔHˆŒØˆŒàˆr   Trm   c                 ó0   — |                       |d¬¦  «        S )a5  Fit the model and recover the sources from X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.

        y : Ignored
            Not used, present for API consistency by convention.

        Returns
        -------
        X_new : ndarray of shape (n_samples, n_components)
            Estimated sources obtained by transforming the data with the
            estimated unmixing matrix.
        Tr|   ©r   ©r“   r=   Úys      r   Úfit_transformzFastICA.fit_transformÁ  s   € ð& ×"Ò" 1°dÐ"Ñ;Ô;Ð;r   c                 ó4   — |                       |d¬¦  «         | S )a¯  Fit the model to X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.

        y : Ignored
            Not used, present for API consistency by convention.

        Returns
        -------
        self : object
            Returns the instance itself.
        Fr|   r·   r¸   s      r   ÚfitzFastICA.fitÖ  s"   € ð$ 	×Ò˜A¨uÐÑ5Ô5Ð5Øˆr   c                 óâ   — t          | ¦  «         t          | ||o| j        t          j        t          j        gd¬¦  «        }| j        r
|| j        z  }t          j        || j        j	        ¦  «        S )a_  Recover the sources from X (apply the unmixing matrix).

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Data to transform, where `n_samples` is the number of samples
            and `n_features` is the number of features.

        copy : bool, default=True
            If False, data passed to fit can be overwritten. Defaults to True.

        Returns
        -------
        X_new : ndarray of shape (n_samples, n_components)
            Estimated sources obtained by transforming the data with the
            estimated unmixing matrix.
        F)r7   r(   Úreset)
r   r   rv   r   rž   rŸ   r�   r%   rª   r   ©r“   r=   r7   s      r   Ú	transformzFastICA.transformë  st   € õ$ 	˜ÑÔÐåØØØÐ&˜4œ;Ý”:�rœzÐ*Øð
ñ 
ô 
ˆð Œ;ð 	Ø�”‰OˆAåŒv�a˜Ô)Ô+Ñ,Ô,Ð,r   c                 óâ   — t          | ¦  «         t          ||o| j        t          j        t          j        g¬¦  «        }t          j        || j        j        ¦  «        }| j        r
|| j	        z  }|S )a6  Transform the sources back to the mixed data (apply mixing matrix).

        Parameters
        ----------
        X : array-like of shape (n_samples, n_components)
            Sources, where `n_samples` is the number of samples
            and `n_components` is the number of components.
        copy : bool, default=True
            If False, data passed to fit are overwritten. Defaults to True.

        Returns
        -------
        X_original : ndarray of shape (n_samples, n_features)
            Reconstructed data obtained with the mixing matrix.
        )r7   r(   )
r   r   rv   r   rž   rŸ   r%   r¬   r   r�   r¿   s      r   Úinverse_transformzFastICA.inverse_transform  se   € õ  	˜ÑÔÐå˜ Ð!5¨$¬+½r¼zÍ2Ì:Ð>VÐWÑWÔWˆÝŒF�1�d”l”nÑ%Ô%ˆØŒ;ð 	Ø�”‰OˆAàˆr   c                 ó&   — | j         j        d         S )z&Number of transformed output features.r   )rª   r4   )r“   s    r   Ú_n_features_outzFastICA._n_features_out$  s   € ð ÔÔ% aÔ(Ð(r   c                 ód   •— t          ¦   «                              ¦   «         }ddg|j        _        |S )Nrž   rŸ   )r‘   Ú__sklearn_tags__Útransformer_tagsÚpreserves_dtype)r“   Útagsr”   s     €r   rÆ   zFastICA.__sklearn_tags__)  s-   ø€ Ý‰wŒw×'Ò'Ñ)Ô)ˆØ1:¸IÐ0FˆÔÔ-Øˆr   r�   )F)T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Úboolr¡   Údictr   rŽ   Ú__annotations__r’   r   r	   rº   r¼   rÀ   rÂ   ÚpropertyrÄ   rÆ   Ú__classcell__)r”   s   @r   r   r   w  s9  ø€ € € € € € ðEð EðP "˜ (¨A¨t¸FÐCÑCÔCÀTÐJØ �j *¨kÐ!:Ñ;Ô;Ð<àˆJÐ,¨oÐ>Ñ?Ô?ØˆG�D˜5˜'Ñ"Ô"ð
ð �
Ð5Ð5Ð5Ñ6Ô6¸ÐAØ˜4�LØ�X˜h¨¨4¸Ð?Ñ?Ô?Ð@Ø�˜˜s D°Ð8Ñ8Ô8Ð9Ø Ð&Ø$˜* f¨e _Ñ5Ô5Ð6Ø'Ð(ð$ð $Ð˜Dð ð ñ ð$ ð)ð ØØØØØØØØð)ð )ð )ð )ð )ð )ð )ð4Vð Vð Vð Vðp €\°Ð5Ñ5Ô5ð<ð <ð <ñ 6Ô5ð<ð( €\°Ð5Ñ5Ô5ðð ð ñ 6Ô5ðð(-ð -ð -ð -ð@ð ð ð ð2 ð)ð )ñ „Xð)ðð ð ð ð ð ð ð ð r   r�   )&rÍ   rO   Únumbersr   r   Únumpyr   Úscipyr   Úsklearn.baser   r   r   r	   Úsklearn.exceptionsr
   Úsklearn.utilsr   r   r   Úsklearn.utils._param_validationr   r   r   r   Úsklearn.utils.validationr   r   Ú__all__r   r-   rJ   rT   r`   rd   rg   r   r   © r   r   ú<module>rÝ      si  ððð ð €€€Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð 2Ð 1Ð 1Ð 1Ð 1Ð 1Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ Iðð ð ð ð ð ð ð ð ð ð ð ð DÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà�iÐ
 €ðð ð ð2Að Að Að ð  ð  ðFð ð ð@ð ð ð ð"!ð !ð !ð*ð *ð *ð €àˆ^Ø#˜Ø%˜;Ø#˜ð	ð ð #(ðñ ô ð ð@ð ØØØØØØØØØØØð@ð @ð @ð @ñô ð@ðFuð uð uð uð uÐ-Ð/?Àñ uô uð uð uð ur   