§
    qŠtjP  ã                   ó€   — d dl mZ d dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZmZ  G d„ d	ee¦  «        ZdS )
é    )ÚRealN)ÚBaseEstimatorÚ_fit_context)ÚSelectorMixin)ÚInterval)Úmean_variance_axisÚmin_max_axis)Úcheck_is_fittedÚvalidate_datac                   óŒ   ‡ — e Zd ZU dZd eeddd¬¦  «        giZeed<   dd	„Z	 e
d
¬¦  «        dd„¦   «         Zd„ Zˆ fd„Zˆ xZS )ÚVarianceThresholdat  Feature selector that removes all low-variance features.

    This feature selection algorithm looks only at the features (X), not the
    desired outputs (y), and can thus be used for unsupervised learning.

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

    Parameters
    ----------
    threshold : float, default=0
        Features with a training-set variance lower than this threshold will
        be removed. The default is to keep all features with non-zero variance,
        i.e. remove the features that have the same value in all samples.

    Attributes
    ----------
    variances_ : array, shape (n_features,)
        Variances of individual features.

    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

    See Also
    --------
    SelectFromModel: Meta-transformer for selecting features based on
        importance weights.
    SelectPercentile : Select features according to a percentile of the highest
        scores.
    SequentialFeatureSelector : Transformer that performs Sequential Feature
        Selection.

    Notes
    -----
    Allows NaN in the input.
    Raises ValueError if no feature in X meets the variance threshold.

    Examples
    --------
    The following dataset has integer features, two of which are the same
    in every sample. These are removed with the default setting for threshold::

        >>> from sklearn.feature_selection import VarianceThreshold
        >>> X = [[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]]
        >>> selector = VarianceThreshold()
        >>> selector.fit_transform(X)
        array([[2, 0],
               [1, 4],
               [1, 1]])
    Ú	thresholdr   NÚleft)ÚclosedÚ_parameter_constraintsç        c                 ó   — || _         d S ©N)r   )Úselfr   s     úk/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/feature_selection/_variance_threshold.pyÚ__init__zVarianceThreshold.__init__N   s   € Ø"ˆŒˆˆó    T)Úprefer_skip_nested_validationc                 óÐ  — t          | |dt          j        d¬¦  «        }t          |d¦  «        r>t	          |d¬¦  «        \  }| _        | j        dk    rt          |d¬¦  «        \  }}||z
  }n<t          j        |d¬¦  «        | _        | j        dk    rt          j	        |d¬¦  «        }| j        dk    r6t          j
        | j        |g¦  «        }t          j        |d¬¦  «        | _        t          j        t          j        | j        ¦  «         | j        | j        k    z  ¦  «        r?d}|j        d         dk    r|d	z  }t          |                     | j        ¦  «        ¦  «        ‚| S )
a  Learn empirical variances from X.

        Parameters
        ----------
        X : {array-like, sparse matrix}, shape (n_samples, n_features)
            Data from which to compute variances, where `n_samples` is
            the number of samples and `n_features` is the number of features.

        y : any, default=None
            Ignored. This parameter exists only for compatibility with
            sklearn.pipeline.Pipeline.

        Returns
        -------
        self : object
            Returns the instance itself.
        )ÚcsrÚcscz	allow-nan)Úaccept_sparseÚdtypeÚensure_all_finiteÚtoarrayr   )Úaxisz4No feature in X meets the variance threshold {0:.5f}é   z (X contains only one sample))r   ÚnpÚfloat64Úhasattrr   Ú
variances_r   r	   ÚnanvarÚptpÚarrayÚnanminÚallÚisfiniteÚshapeÚ
ValueErrorÚformat)	r   ÚXÚyÚ_ÚminsÚmaxesÚpeak_to_peaksÚcompare_arrÚmsgs	            r   ÚfitzVarianceThreshold.fitQ   sd  € õ& ØØØ(Ý”*Ø)ð
ñ 
ô 
ˆõ �1�iÑ Ô ð 	2Ý!3°A¸AÐ!>Ñ!>Ô!>ÑˆAˆtŒØŒ~ Ò"Ð"Ý*¨1°1Ð5Ñ5Ô5‘��eØ %¨¡�øå œi¨°Ð2Ñ2Ô2ˆDŒOØŒ~ Ò"Ð"Ý "¤ q¨qÐ 1Ñ 1Ô 1�àŒ>˜QÒÐõ œ( D¤O°]Ð#CÑDÔDˆKÝ œi¨¸!Ð<Ñ<Ô<ˆDŒOåŒ6•2”;˜tœÑ/Ô/Ð/°4´?ÀdÄnÒ3TÑUÑVÔVð 	9ØHˆCØŒw�qŒz˜QŠˆØÐ6Ñ6�Ý˜SŸZšZ¨¬Ñ7Ô7Ñ8Ô8Ð8àˆr   c                 ó@   — t          | ¦  «         | j        | j        k    S r   )r
   r&   r   )r   s    r   Ú_get_support_maskz#VarianceThreshold._get_support_mask„   s   € Ý˜ÑÔÐàŒ ¤Ò/Ð/r   c                 óx   •— t          ¦   «                              ¦   «         }d|j        _        d|j        _        |S )NT)ÚsuperÚ__sklearn_tags__Ú
input_tagsÚ	allow_nanÚsparse)r   ÚtagsÚ	__class__s     €r   r=   z"VarianceThreshold.__sklearn_tags__‰   s1   ø€ Ý‰wŒw×'Ò'Ñ)Ô)ˆØ$(ˆŒÔ!Ø!%ˆŒÔØˆr   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚdictÚ__annotations__r   r   r8   r:   r=   Ú__classcell__)rB   s   @r   r   r      sÍ   ø€ € € € € € ð8ð 8ðv 	�h�h˜t Q¨°VÐ<Ñ<Ô<Ð=ð$Ð˜Dð ð ñ ð#ð #ð #ð #ð €\°Ð5Ñ5Ô5ð0ð 0ð 0ñ 6Ô5ð0ðd0ð 0ð 0ð
ð ð ð ð ð ð ð ð r   r   )Únumbersr   Únumpyr#   Úsklearn.baser   r   Úsklearn.feature_selection._baser   Úsklearn.utils._param_validationr   Úsklearn.utils.sparsefuncsr   r	   Úsklearn.utils.validationr
   r   r   © r   r   ú<module>rR      sÑ   ðð Ð Ð Ð Ð Ð à Ð Ð Ð à 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cð~ð ~ð ~ð ~ð ~˜ }ñ ~ô ~ð ~ð ~ð ~r   