B
    	\,
                 @   sB   d Z ddlZddlmZ ddlmZmZ ddlm	Z	 dd
dZ
dS )z!Determination of parameter bounds    N   )LabelBinarizer)check_consistent_lengthcheck_array)safe_sparse_dotsquared_hingeT      ?c             C   s   |dkrt dt| dd} t| | tdd|j}ttt	|| }|rtj
t|df|t|jd}t|tt|| }|d	krt d
|dkrd| S d| S dS )a  
    Return the lowest bound for C 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 or sparse matrix, shape = [n_samples, n_features]
        Training vector, where n_samples in the number of samples and
        n_features is the number of features.

    y : array, 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
        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
    )r   logz)loss type not in ("squared_hinge", "log")Zcsc)Zaccept_sparse)Z	neg_label   )dtypeg        zUIll-posed l1_min_c calculation: l1 will always select zero coefficients for this datar   g      ?g       @N)
ValueErrorr   r   r   Zfit_transformTnpmaxabsr   ZfullsizeZarrayr   dot)XyZlossZfit_interceptZintercept_scalingYZdenZbias r   1lib/python3.7/site-packages/sklearn/svm/bounds.pyl1_min_c   s    (
r   )r   Tr   )__doc__Znumpyr   Zpreprocessingr   Zutils.validationr   r   Zutils.extmathr   r   r   r   r   r   <module>   s    