§
    rŠtjªR  ã                   óþ   — d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 ddl
m
Z
 ddlZddlmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZmZmZ ddl m!Z!m"Z" ddl#m$Z$m%Z% d„ Z& G d„ deee¬¦  «        Z'dS )zBase class for mixture models.é    N)ÚABCMetaÚabstractmethod)Únullcontext)ÚIntegralÚReal)Útime)Úcluster)ÚBaseEstimatorÚDensityMixinÚ_fit_context)Úkmeans_plusplus)ÚConvergenceWarning)Úcheck_random_state)Ú_is_numpy_namespaceÚ
_logsumexpÚ_max_precision_float_dtypeÚget_namespaceÚget_namespace_and_deviceÚmove_to)ÚIntervalÚ
StrOptions)Úcheck_is_fittedÚvalidate_datac                 óV   — | j         |k    rt          d|›d|›d| j         ›�¦  «        ‚dS )z‘Validate the shape of the input parameter 'param'.

    Parameters
    ----------
    param : array

    param_shape : tuple

    name : str
    zThe parameter 'z' should have the shape of z
, but got N)ÚshapeÚ
ValueError)ÚparamÚparam_shapeÚnames      úS/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/mixture/_base.pyÚ_check_shaper!      sE   € ð „{�kÒ!Ð!Ýˆjàˆtˆt�[�[�[ %¤+ +ð/ñ
ô 
ð 	
ð "Ð!ó    c                   ó,  — e Zd ZU dZ eeddd¬¦  «        g eeddd¬¦  «        g eeddd¬¦  «        g eeddd¬¦  «        g eeddd¬¦  «        g eh d£¦  «        gd	gd
gdg eeddd¬¦  «        gdœ
Ze	e
d<   d„ Zed&d„¦   «         Zd&d„Zed„ ¦   «         Zd&d„Z ed¬¦  «        d&d„¦   «         Zd&d„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd&d„Zd„ Zd„ Zd'd„Zd&d„Zed&d „¦   «         Zed&d!„¦   «         Zd&d"„Zd#„ Z d$„ Z!d%„ Z"dS )(ÚBaseMixturez¥Base class for mixture models.

    This abstract class specifies an interface for all mixture classes and
    provides basic common methods for mixture models.
    é   NÚleft)Úclosedg        r   >   ÚkmeansÚrandomÚrandom_from_dataú	k-means++Úrandom_stateÚbooleanÚverbose©
Ún_componentsÚtolÚ	reg_covarÚmax_iterÚn_initÚinit_paramsr,   Ú
warm_startr.   Úverbose_intervalÚ_parameter_constraintsc                 ó’   — || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        d S ©Nr/   )Úselfr0   r1   r2   r3   r4   r5   r,   r6   r.   r7   s              r    Ú__init__zBaseMixture.__init__G   sT   € ð )ˆÔØˆŒØ"ˆŒØ ˆŒØˆŒØ&ˆÔØ(ˆÔØ$ˆŒØˆŒØ 0ˆÔÐÐr"   c                 ó   — dS )z—Check initial parameters of the derived class.

        Parameters
        ----------
        X : array-like of shape  (n_samples, n_features)
        N© ©r;   ÚXÚxps      r    Ú_check_parameterszBaseMixture._check_parameters_   ó	   € ð 	ˆr"   c                 óÞ  — t          ||¬¦  «        \  }}}|j        \  }}| j        dk    rqt          j        || j        f|j        ¬¦  «        }t          j        | j        d|¬¦  «         	                    |¦  «        j
        }d|t          j        |¦  «        |f<   �n;| j        dk    rb|                     |                     || j        f¬¦  «        |j        |¬¦  «        }||                     |d¬	¦  «        d
d
…|j        f         z  }nÎ| j        dk    r^|                     || j        f|j        |¬¦  «        }|                     || j        d¬¦  «        }	t#          |	¦  «        D ]\  }
}d|||
f<   Œne| j        dk    rZt          j        || j        f|j        ¬¦  «        }t%          || j        |¬¦  «        \  }}	d||	t          j        | j        ¦  «        f<   |                      ||¦  «         d
S )a?  Initialize the model parameters.

        Parameters
        ----------
        X : array-like of shape  (n_samples, n_features)

        random_state : RandomState
            A random number generator instance that controls the random seed
            used for the method chosen to initialize the parameters.
        ©rA   r(   )Údtyper%   )Ú
n_clustersr4   r,   r)   ©Úsize©rF   Údevice©ÚaxisNr*   F)rI   Úreplacer+   )r,   )r   r   r5   ÚnpÚzerosr0   rF   r	   ÚKMeansÚfitÚlabels_ÚarangeÚasarrayÚuniformÚsumÚnewaxisÚchoiceÚ	enumerater   Ú_initialize)r;   r@   r,   rA   Ú_rK   Ú	n_samplesÚrespÚlabelÚindicesÚcolÚindexs               r    Ú_initialize_parametersz"BaseMixture._initialize_parametersi   s6  € õ 1°°rÐ:Ñ:Ô:‰ˆˆAˆvØ”w‰ˆ	�1àÔ˜xÒ'Ð'Ý”8˜Y¨Ô(9Ð:À!Ä'ÐJÑJÔJˆDå”Ø#Ô0¸Èðñ ô ÷ ’�Q‘”Üð ð 12ˆD•”˜9Ñ%Ô% uÐ,Ñ-Ñ-ØÔ Ò)Ð)Ø—:’:Ø×$Ò$¨9°dÔ6GÐ*HÐ$ÑIÔIØ”gØð ñ ô ˆDð
 �B—F’F˜4 a�FÑ(Ô(¨¨¨¨B¬J¨Ô7Ñ7ˆDˆDØÔÐ!3Ò3Ð3Ø—8’8Ø˜DÔ-Ð.°a´gÀfð ñ ô ˆDð #×)Ò)Ø Ô 1¸5ð *ñ ô ˆGõ (¨Ñ0Ô0ð %ð %‘
��UØ#$��U˜C�ZÑ Ð ð%àÔ Ò,Ð,Ý”8˜Y¨Ô(9Ð:À!Ä'ÐJÑJÔJˆDÝ(ØØÔ!Ø)ðñ ô ‰JˆAˆwð
 ;<ˆD��"œ) DÔ$5Ñ6Ô6Ð6Ñ7à×Ò˜˜DÑ!Ô!Ð!Ð!Ð!r"   c                 ó   — dS )zÜInitialize the model parameters of the derived class.

        Parameters
        ----------
        X : array-like of shape  (n_samples, n_features)

        resp : array-like of shape (n_samples, n_components)
        Nr>   )r;   r@   r^   s      r    r[   zBaseMixture._initialize    s	   € ð 	ˆr"   c                 ó2   — |                       ||¦  «         | S )aø  Estimate model parameters with the EM algorithm.

        The method fits the model ``n_init`` times and sets the parameters with
        which the model has the largest likelihood or lower bound. Within each
        trial, the method iterates between E-step and M-step for ``max_iter``
        times until the change of likelihood or lower bound is less than
        ``tol``, otherwise, a ``ConvergenceWarning`` is raised.
        If ``warm_start`` is ``True``, then ``n_init`` is ignored and a single
        initialization is performed upon the first call. Upon consecutive
        calls, training starts where it left off.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

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

        Returns
        -------
        self : object
            The fitted mixture.
        )Úfit_predict)r;   r@   Úys      r    rR   zBaseMixture.fit¬   s   € ð6 	×Ò˜˜AÑÔÐØˆr"   T)Úprefer_skip_nested_validationc                 ó¦  — t          |¦  «        \  }}t          | ||j        |j        gd¬¦  «        }|j        d         | j        k     r%t          d| j        › d|j        d         › �¦  «        ‚|                      ||¬¦  «         | j        ot          | d¦  «         }|r| j
        nd}|j         }g }d	| _        t          | j        ¦  «        }	|j        \  }
}t          |¦  «        D �]c}|                      |¦  «         |r|                      ||	|¬¦  «         |r|j         n| j        }g }| j        dk    r|                      ¦   «         }d}Œgd	}t          d| j        dz   ¦  «        D ]˜}|}|                      ||¬¦  «        \  }}|                      |||¬¦  «         |                      ||¦  «        }|                     |¦  «         ||z
  }|                      ||¦  «         t5          |¦  «        | j        k     rd
} nŒ™|                      ||¦  «         ||k    s||j         k    r!|}|                      ¦   «         }|}|}|| _        �Œe| j        s%| j        dk    rt;          j        dt>          ¦  «         |                       ||¬¦  «         || _!        || _        || _"        |                      ||¬¦  «        \  }}| #                    |d¬¦  «        S )aâ  Estimate model parameters using X and predict the labels for X.

        The method fits the model ``n_init`` times and sets the parameters with
        which the model has the largest likelihood or lower bound. Within each
        trial, the method iterates between E-step and M-step for `max_iter`
        times until the change of likelihood or lower bound is less than
        `tol`, otherwise, a :class:`~sklearn.exceptions.ConvergenceWarning` is
        raised. After fitting, it predicts the most probable label for the
        input data points.

        .. versionadded:: 0.20

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

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

        Returns
        -------
        labels : array, shape (n_samples,)
            Component labels.
        é   )rF   Úensure_min_samplesr   z:Expected n_samples >= n_components but got n_components = z, n_samples = rE   Ú
converged_r%   FTzˆBest performing initialization did not converge. Try different init parameters, or increase max_iter, tol, or check for degenerate data.rL   )$r   r   Úfloat64Úfloat32r   r0   r   rB   r6   Úhasattrr4   Úinfrl   r   r,   ÚrangeÚ_print_verbose_msg_init_begrc   Úlower_bound_r3   Ú_get_parametersÚ_e_stepÚ_m_stepÚ_compute_lower_boundÚappendÚ_print_verbose_msg_iter_endÚabsr1   Ú_print_verbose_msg_init_endÚwarningsÚwarnr   Ú_set_parametersÚn_iter_Úlower_bounds_Úargmax)r;   r@   rg   rA   r\   Údo_initr4   Úmax_lower_boundÚbest_lower_boundsr,   r]   ÚinitÚlower_boundÚcurrent_lower_boundsÚbest_paramsÚbest_n_iterÚ	convergedÚn_iterÚprev_lower_boundÚlog_prob_normÚlog_respÚchanges                         r    rf   zBaseMixture.fit_predictÊ   sC  € õ8 ˜aÑ Ô ‰ˆˆAÝ˜$ ¨"¬*°b´jÐ)AÐVWÐXÑXÔXˆØŒ7�1Œ:˜Ô)Ò)Ð)Ýð,Ø*.Ô*;ð,ð ,à œw qœzð,ð ,ñô ð ð
 	×Ò˜q RÐÑ(Ô(Ð(ð ”ÐF­7°4¸Ñ+FÔ+FÐGˆØ 'Ð.�”�¨Qˆàœ6˜'ˆØÐØˆŒå)¨$Ô*;Ñ<Ô<ˆà”w‰ˆ	�1Ý˜&‘M”Mð $	0ñ $	0ˆDØ×,Ò,¨TÑ2Ô2Ð2àð DØ×+Ò+¨A¨|ÀÐ+ÑCÔCÐCà%,ÐC˜2œ6˜'˜'°$Ô2CˆKØ#%Ð àŒ} Ò!Ð!Ø"×2Ò2Ñ4Ô4�Ø��à!�	Ý# A t¤}°qÑ'8Ñ9Ô9ð ð �FØ'2Ð$à.2¯lªl¸1À¨lÑ.DÔ.DÑ+�M 8Ø—L’L  H°�LÑ4Ô4Ð4Ø"&×";Ò";¸HÀmÑ"TÔ"T�KØ(×/Ò/°Ñ<Ô<Ð<à(Ð+;Ñ;�FØ×4Ò4°V¸VÑDÔDÐDå˜6‘{”{ T¤XÒ-Ð-Ø$(˜	Ø˜ð .ð ×0Ò0°¸iÑHÔHÐHà Ò0Ð0°OÈÌÀwÒ4NÐ4NØ&1�OØ"&×"6Ò"6Ñ"8Ô"8�KØ"(�KØ(<Ð%Ø&/�D”Oùð
 Œð 	 4¤=°1Ò#4Ð#4ÝŒMð9õ #ñô ð ð 	×Ò˜[¨RÐÑ0Ô0Ð0Ø"ˆŒØ+ˆÔØ.ˆÔð
 —l’l 1¨�lÑ,Ô,‰ˆˆ8à�yŠy˜¨ˆyÑ*Ô*Ð*r"   c                 óŒ   — t          ||¬¦  «        \  }}|                      ||¬¦  «        \  }}|                     |¦  «        |fS )a¸  E step.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        Returns
        -------
        log_prob_norm : float
            Mean of the logarithms of the probabilities of each sample in X

        log_responsibility : array, shape (n_samples, n_components)
            Logarithm of the posterior probabilities (or responsibilities) of
            the point of each sample in X.
        rE   )r   Ú_estimate_log_prob_respÚmean)r;   r@   rA   r\   r�   rŽ   s         r    ru   zBaseMixture._e_step:  sN   € õ  ˜a BÐ'Ñ'Ô'‰ˆˆAØ"&×">Ò">¸qÀRÐ">Ñ"HÔ"HÑˆ�xØ�wŠw�}Ñ%Ô% xÐ/Ð/r"   c                 ó   — dS )a*  M step.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        log_resp : array-like of shape (n_samples, n_components)
            Logarithm of the posterior probabilities (or responsibilities) of
            the point of each sample in X.
        Nr>   )r;   r@   rŽ   s      r    rv   zBaseMixture._m_stepN  s	   € ð 	ˆr"   c                 ó   — d S r:   r>   )r;   s    r    rt   zBaseMixture._get_parameters\  ó   € àˆr"   c                 ó   — d S r:   r>   )r;   Úparamss     r    r~   zBaseMixture._set_parameters`  r•   r"   c                 óŒ   — t          | ¦  «         t          | |d¬¦  «        }t          |                      |¦  «        d¬¦  «        S )a›  Compute the log-likelihood of each sample.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

        Returns
        -------
        log_prob : array, shape (n_samples,)
            Log-likelihood of each sample in `X` under the current model.
        F©Úresetr%   rL   )r   r   r   Ú_estimate_weighted_log_prob)r;   r@   s     r    Úscore_sampleszBaseMixture.score_samplesd  sG   € õ 	˜ÑÔÐÝ˜$ ¨Ð/Ñ/Ô/ˆå˜$×:Ò:¸1Ñ=Ô=ÀAÐFÑFÔFÐFr"   c                 ó�   — t          |¦  «        \  }}t          |                     |                      |¦  «        ¦  «        ¦  «        S )a÷  Compute the per-sample average log-likelihood of the given data X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_dimensions)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

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

        Returns
        -------
        log_likelihood : float
            Log-likelihood of `X` under the Gaussian mixture model.
        )r   Úfloatr’   rœ   )r;   r@   rg   rA   r\   s        r    ÚscorezBaseMixture.scorew  s=   € õ" ˜aÑ Ô ‰ˆˆAÝ�R—W’W˜T×/Ò/°Ñ2Ô2Ñ3Ô3Ñ4Ô4Ð4r"   c                 ó¼   — t          | ¦  «         t          |¦  «        \  }}t          | |d¬¦  «        }|                     |                      |¦  «        d¬¦  «        S )a„  Predict the labels for the data samples in X using trained model.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

        Returns
        -------
        labels : array, shape (n_samples,)
            Component labels.
        Fr™   r%   rL   )r   r   r   r�   r›   )r;   r@   rA   r\   s       r    ÚpredictzBaseMixture.predict‹  s[   € õ 	˜ÑÔÐÝ˜aÑ Ô ‰ˆˆAÝ˜$ ¨Ð/Ñ/Ô/ˆØ�yŠy˜×9Ò9¸!Ñ<Ô<À1ˆyÑEÔEÐEr"   c                 óÆ   — t          | ¦  «         t          | |d¬¦  «        }t          |¦  «        \  }}|                      ||¬¦  «        \  }}|                     |¦  «        S )a¦  Evaluate the components' density for each sample.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            List of n_features-dimensional data points. Each row
            corresponds to a single data point.

        Returns
        -------
        resp : array, shape (n_samples, n_components)
            Density of each Gaussian component for each sample in X.
        Fr™   rE   )r   r   r   r‘   Úexp)r;   r@   rA   r\   rŽ   s        r    Úpredict_probazBaseMixture.predict_probaž  se   € õ 	˜ÑÔÐÝ˜$ ¨Ð/Ñ/Ô/ˆÝ˜aÑ Ô ‰ˆˆAØ×2Ò2°1¸Ð2Ñ<Ô<‰ˆˆ8Ø�vŠv�hÑÔÐr"   c                 ó\  ‡ ‡‡‡‡	‡
— t          ‰ ¦  «         t          ‰ j        ¦  «        \  Š
}Š|dk     rt          d‰ j        z  ¦  «        ‚‰ j        j        \  }Št          ‰ j        ¦  «        Š	‰	                     |t          ‰ j
        t          d¬¦  «        ¦  «        Š‰ j        dk    rdt          j        ˆ	fd„t          t          ‰ j        t          d¬¦  «        t          ‰ j        t          d¬¦  «        ‰¦  «        D ¦   «         ¦  «        }n¹‰ j        dk    rJt          j        ˆ	ˆ fd„t          t          ‰ j        t          d¬¦  «        ‰¦  «        D ¦   «         ¦  «        }ndt          j        ˆˆ	fd	„t          t          ‰ j        t          d¬¦  «        t          ‰ j        t          d¬¦  «        ‰¦  «        D ¦   «         ¦  «        }‰
                     ˆˆˆ
fd
„t#          t%          ‰¦  «        ¦  «        D ¦   «         ¦  «        }t'          ‰
‰¬¦  «        }‰
                     ||‰¬¦  «        |fS )ay  Generate random samples from the fitted Gaussian distribution.

        Parameters
        ----------
        n_samples : int, default=1
            Number of samples to generate.

        Returns
        -------
        X : array, shape (n_samples, n_features)
            Randomly generated sample.

        y : array, shape (nsamples,)
            Component labels.
        r%   zNInvalid value for 'n_samples': %d . The sampling requires at least one sample.Úcpu©rA   rK   Úfullc           	      ó`   •— g | ]*\  }}}‰                      ||t          |¦  «        ¦  «        ‘Œ+S r>   )Úmultivariate_normalÚint)Ú.0r’   Ú
covarianceÚsampleÚrngs       €r    ú
<listcomp>z&BaseMixture.sample.<locals>.<listcomp>Ó  sG   ø€ ð ð ð á2˜˜z¨6ð ×+Ò+¨D°*½cÀ&¹k¼kÑJÔJðð ð r"   Útiedc           
      ó’   •— g | ]C\  }}‰                      |t          ‰j        t          d ¬¦  «        t	          |¦  «        ¦  «        ‘ŒDS )r¦   r§   )rª   r   Úcovariances_rO   r«   )r¬   r’   r®   r¯   r;   s      €€r    r°   z&BaseMixture.sample.<locals>.<listcomp>Þ  s`   ø€ ð 	ð 	ð 	ñ '˜˜vð ×+Ò+ØÝ Ô 1µbÀÐGÑGÔGÝ˜F™œñô ð	ð 	ð 	r"   c                 óx   •— g | ]6\  }}}|‰                      |‰f¬ ¦  «        t          j        |¦  «        z  z   ‘Œ7S )rH   )Ústandard_normalrO   Úsqrt)r¬   r’   r­   r®   Ú
n_featuresr¯   s       €€r    r°   z&BaseMixture.sample.<locals>.<listcomp>ë  sa   ø€ ð 	ð 	ð 	ñ 3˜˜z¨6ð Ø×)Ò)°¸
Ð/CÐ)ÑDÔDÝ”g˜jÑ)Ô)ñ*ñ*ð	ð 	ð 	r"   c                 ór   •— g | ]3}‰                      t          ‰|         ¦  «        |‰j        ‰¬ ¦  «        ‘Œ4S )rJ   )r¨   r«   Úint64)r¬   ÚiÚdevice_Ún_samples_comprA   s     €€€r    r°   z&BaseMixture.sample.<locals>.<listcomp>ø  sL   ø€ ð ð ð àð —’�˜N¨1Ô-Ñ.Ô.°¸¼È'�ÑRÔRðð ð r"   rJ   )r   r   Úmeans_r   r0   r   r   r,   Úmultinomialr   Úweights_rO   Úcovariance_typeÚvstackÚzipr³   Úconcatrq   Úlenr   rU   )r;   r]   r\   r@   rg   Úmax_float_dtyper»   r·   r¼   r¯   rA   s   `     @@@@@r    r®   zBaseMixture.sample²  sŒ  øøøøøø€ õ  	˜ÑÔÐÝ1°$´+Ñ>Ô>‰ˆˆAˆwà�qŠ=ˆ=Ýð$Ø'+Ô'8ñ:ñô ð ð
 œÔ)‰ˆˆ:Ý  Ô!2Ñ3Ô3ˆØŸšØ•w˜tœ}µ¸EÐBÑBÔBñ
ô 
ˆð Ô 6Ò)Ð)Ý”	ðð ð ð å69Ý ¤µ¸5ÐAÑAÔAÝ Ô 1µbÀÐGÑGÔGØ&ñ7ô 7ðñ ô ñ	ô 	ˆAˆAð Ô! VÒ+Ð+Ý”	ð	ð 	ð 	ð 	ð 	õ +.Ý ¤µ¸5ÐAÑAÔAÀ>ñ+ô +ð	ñ 	ô 	ñô ˆAˆAõ ”	ð	ð 	ð 	ð 	ð 	õ 7:Ý ¤µ¸5ÐAÑAÔAÝ Ô 1µbÀÐGÑGÔGØ&ñ7ô 7ð		ñ 	ô 	ñô ˆAð �IŠIðð ð ð ð ð å�s >Ñ2Ô2Ñ3Ô3ðñ ô ñ
ô 
ˆõ 5¸À7ÐKÑKÔKˆØ�zŠz˜! ?¸7ˆzÑCÔCÀQÐFÐFr"   c                 ó^   — |                       ||¬¦  «        |                      |¬¦  «        z   S )a  Estimate the weighted log-probabilities, log P(X | Z) + log weights.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        Returns
        -------
        weighted_log_prob : array, shape (n_samples, n_component)
        rE   )Ú_estimate_log_probÚ_estimate_log_weightsr?   s      r    r›   z'BaseMixture._estimate_weighted_log_prob  s4   € ð ×&Ò& q¨RÐ&Ñ0Ô0°4×3MÒ3MÐQSÐ3MÑ3TÔ3TÑTÐTr"   c                 ó   — dS )zŸEstimate log-weights in EM algorithm, E[ log pi ] in VB algorithm.

        Returns
        -------
        log_weight : array, shape (n_components, )
        Nr>   )r;   rA   s     r    rÈ   z!BaseMixture._estimate_log_weights  rC   r"   c                 ó   — dS )a9  Estimate the log-probabilities log P(X | Z).

        Compute the log-probabilities per each component for each sample.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        Returns
        -------
        log_prob : array, shape (n_samples, n_component)
        Nr>   r?   s      r    rÇ   zBaseMixture._estimate_log_prob  s	   € ð 	ˆr"   c                 óD  — t          ||¬¦  «        \  }}|                      ||¬¦  «        }t          |d|¬¦  «        }t          |¦  «        rt	          j        d¬¦  «        nt          ¦   «         }|5  ||dd…|j        f         z
  }ddd¦  «         n# 1 swxY w Y   ||fS )a@  Estimate log probabilities and responsibilities for each sample.

        Compute the log probabilities, weighted log probabilities per
        component and responsibilities for each sample in X with respect to
        the current state of the model.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)

        Returns
        -------
        log_prob_norm : array, shape (n_samples,)
            log p(X)

        log_responsibilities : array, shape (n_samples, n_components)
            logarithm of the responsibilities
        rE   r%   )rM   rA   Úignore)ÚunderN)r   r›   r   r   rO   Úerrstater   rX   )r;   r@   rA   r\   Úweighted_log_probr�   Úcontext_managerrŽ   s           r    r‘   z#BaseMixture._estimate_log_prob_resp(  s	  € õ& ˜a BÐ'Ñ'Ô'‰ˆˆAØ ×<Ò<¸QÀ2Ð<ÑFÔFÐÝ"Ð#4¸1ÀÐDÑDÔDˆõ ,?¸rÑ+BÔ+BÐU�BŒK˜hÐ'Ñ'Ô'Ð'ÍÉÌð 	ð ð 	Hð 	Hà(¨=¸¸¸¸B¼J¸Ô+GÑGˆHð	Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hð ˜hÐ&Ð&s   Á2BÂBÂBc                 óÀ   — | j         dk    rt          d|z  ¦  «         dS | j         dk    r3t          d|z  ¦  «         t          ¦   «         | _        | j        | _        dS dS )ú(Print verbose message on initialization.r%   zInitialization %drj   N)r.   Úprintr   Ú_init_prev_timeÚ_iter_prev_time)r;   r4   s     r    rr   z'BaseMixture._print_verbose_msg_init_begH  so   € àŒ<˜1ÒÐÝÐ%¨Ñ.Ñ/Ô/Ð/Ð/Ð/ØŒ\˜QÒÐÝÐ%¨Ñ.Ñ/Ô/Ð/Ý#'¡6¤6ˆDÔ Ø#'Ô#7ˆDÔ Ð Ð ð Ðr"   c                 óâ   — || j         z  dk    r^| j        dk    rt          d|z  ¦  «         dS | j        dk    r6t          ¦   «         }t          d||| j        z
  |fz  ¦  «         || _        dS dS dS )rÒ   r   r%   z  Iteration %drj   z0  Iteration %d	 time lapse %.5fs	 ll change %.5fN)r7   r.   rÓ   r   rÕ   )r;   r‹   Údiff_llÚcur_times       r    ry   z'BaseMixture._print_verbose_msg_iter_endQ  sŸ   € à�DÔ)Ñ)¨QÒ.Ð.ØŒ|˜qÒ Ð ÝÐ&¨Ñ/Ñ0Ô0Ð0Ð0Ð0Ø” Ò"Ð"Ý™6œ6�ÝØHØ˜x¨$Ô*>Ñ>ÀÐHñIñô ð ð (0�Ô$Ð$Ð$ð /Ð.ð #Ð"r"   c           	      óÎ   — |rdnd}| j         dk    rt          d|› d�¦  «         d
S | j         dk    r3t          ¦   «         | j        z
  }t          d|› d|d›d	|d›d�¦  «         d
S d
S )z.Print verbose message on the end of iteration.rŠ   zdid not converger%   zInitialization ú.rj   z. time lapse z.5fzs	 lower bound N)r.   rÓ   r   rÔ   )r;   ÚlbÚinit_has_convergedÚconverged_msgÚts        r    r{   z'BaseMixture._print_verbose_msg_init_end^  s´   € à'9ÐQ˜˜Ð?QˆØŒ<˜1ÒÐÝÐ4 MÐ4Ð4Ð4Ñ5Ô5Ð5Ð5Ð5ØŒ\˜QÒÐÝ‘”˜Ô-Ñ-ˆAÝð -ð ð ¸aÐTð ð Ø�ðð ð ñô ð ð ð ð Ðr"   r:   )r%   )#Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r8   ÚdictÚ__annotations__r<   r   rB   rc   r[   rR   r   rf   ru   rv   rt   r~   rœ   rŸ   r¡   r¤   r®   r›   rÈ   rÇ   r‘   rr   ry   r{   r>   r"   r    r$   r$   1   s
  € € € € € € ðð ð "˜ (¨A¨t¸FÐCÑCÔCÐDØ�˜˜s D°Ð8Ñ8Ô8Ð9Ø�h˜t S¨$°vÐ>Ñ>Ô>Ð?Ø�X˜h¨¨4¸Ð?Ñ?Ô?Ð@Ø�8˜H a¨°fÐ=Ñ=Ô=Ð>àˆJÐLÐLÐLÑMÔMð
ð (Ð(Ø �kØ�;Ø%˜X h°°4ÀÐGÑGÔGÐHð$ð $Ð˜Dð ð ñ ð1ð 1ð 1ð0 ðð ð ñ „^ðð5"ð 5"ð 5"ð 5"ðn ð	ð 	ñ „^ð	ðð ð ð ð< €\°Ð5Ñ5Ô5ðm+ð m+ð m+ñ 6Ô5ðm+ð^0ð 0ð 0ð 0ð( ðð ñ „^ðð ðð ñ „^ðð ðð ñ „^ððGð Gð Gð&5ð 5ð 5ð 5ð(Fð Fð Fð& ð  ð  ð(MGð MGð MGð MGð^Uð Uð Uð Uð ðð ð ñ „^ðð ðð ð ñ „^ðð'ð 'ð 'ð 'ð@8ð 8ð 8ð0ð 0ð 0ð
ð 
ð 
ð 
ð 
r"   r$   )Ú	metaclass)(râ   r|   Úabcr   r   Ú
contextlibr   Únumbersr   r   r   ÚnumpyrO   Úsklearnr	   Úsklearn.baser
   r   r   Úsklearn.clusterr   Úsklearn.exceptionsr   Úsklearn.utilsr   Úsklearn.utils._array_apir   r   r   r   r   r   Úsklearn.utils._param_validationr   r   Úsklearn.utils.validationr   r   r!   r$   r>   r"   r    ú<module>rò      s¶  ðØ $Ð $ð
 €€€Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø "Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à Ð Ð Ð à Ð Ð Ð Ð Ð Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ +Ð +Ð +Ð +Ð +Ð +Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð AÐ @Ð @Ð @Ð @Ð @Ð @Ð @Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cð
ð 
ð 
ð$wð wð wð wð w�, ¸ð wñ wô wð wð wð wr"   