
    0Ph                         d 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mZ  e
d	d
gd	g e	ddh          gdg eeddd          gdd          ddddd            ZdS )z!Determination of parameter bounds    )RealN   )LabelBinarizer)Interval
StrOptionsvalidate_params)safe_sparse_dot)check_arraycheck_consistent_lengthz
array-likezsparse matrixsquared_hingelogbooleanneither)closed)Xylossfit_interceptintercept_scalingT)prefer_skip_nested_validationg      ?)r   r   r   c          	      R   t          | d          } t          | |           t          d                              |          j        }t          j        t          j        t          ||                               }|rt          j	        t          j
        |          df|t          j        |          j                  }t          |t          t          j        ||                                                              }|dk    rt          d          |d	k    rd
|z  S d|z  S )a  Return the lowest bound for C.

    The lower bound for C is computed such that for C in (l1_min_C, infinity)
    the model is guaranteed not to be empty. This applies to l1 penalized
    classifiers, such as LinearSVC with penalty='l1' and
    linear_model.LogisticRegression with penalty='l1'.

    This value is valid if class_weight parameter in fit() is not set.

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

    y : array-like of shape (n_samples,)
        Target vector relative to X.

    loss : {'squared_hinge', 'log'}, default='squared_hinge'
        Specifies the loss function.
        With 'squared_hinge' it is the squared hinge loss (a.k.a. L2 loss).
        With 'log' it is the loss of logistic regression models.

    fit_intercept : bool, default=True
        Specifies if the intercept should be fitted by the model.
        It must match the fit() method parameter.

    intercept_scaling : float, default=1.0
        When fit_intercept is True, instance vector x becomes
        [x, intercept_scaling],
        i.e. a "synthetic" feature with constant value equals to
        intercept_scaling is appended to the instance vector.
        It must match the fit() method parameter.

    Returns
    -------
    l1_min_c : float
        Minimum value for C.

    Examples
    --------
    >>> from sklearn.svm import l1_min_c
    >>> from sklearn.datasets import make_classification
    >>> X, y = make_classification(n_samples=100, n_features=20, random_state=42)
    >>> print(f"{l1_min_c(X, y, loss='squared_hinge', fit_intercept=True):.4f}")
    0.0044
    csc)accept_sparse)	neg_label   )dtypeg        zUIll-posed l1_min_c calculation: l1 will always select zero coefficients for this datar   g      ?g       @)r
   r   r   fit_transformTnpmaxabsr	   fullsizearrayr   dot
ValueError)r   r   r   r   r   Ydenbiass           S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/svm/_bounds.pyl1_min_cr,      s   v 	AU+++AAq!!!$$$221557A
&1--..
/
/C 3wWQZZO.bh?P6Q6Q6W
 
 
 #s26!T??++//1122
czz5
 
 	
 SySy    )__doc__numbersr   numpyr    preprocessingr   utils._param_validationr   r   r   utils.extmathr	   utils.validationr
   r   r,    r-   r+   <module>r6      s(   ' '
           * * * * * * K K K K K K K K K K + + + + + + C C C C C C C C O,^_e4556#&htQYGGGH  #'	 	 	 +$RU E E E E	 	E E Er-   