ó
‡ˆ\c           @   s^   d  Z  d d l Z d d l m Z d d l m Z m Z d d l m	 Z	 d e
 d d	 „ Z d S(
   s!   Determination of parameter boundsiÿÿÿÿNi   (   t   LabelBinarizer(   t   check_consistent_lengtht   check_array(   t   safe_sparse_dott   squared_hingeg      ð?c         C   s  | d k r t  d ƒ ‚ n  t |  d d ƒ}  t |  | ƒ t d d ƒ j | ƒ j } t j t j t	 | |  ƒ ƒ ƒ } | rÙ t j
 t j | ƒ d f | d	 t j | ƒ j ƒ} t | t t j | | ƒ ƒ j ƒ  ƒ } n  | d
 k rô t  d ƒ ‚ n  | d k rd | Sd | Sd S(   s‚  
    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   t   logs)   loss type not in ("squared_hinge", "log")t   accept_sparset   csct	   neg_labeliÿÿÿÿi   t   dtypeg        sU   Ill-posed l1_min_c calculation: l1 will always select zero coefficients for this datag      à?g       @N(   R   R   (   t
   ValueErrorR   R   R    t   fit_transformt   Tt   npt   maxt   absR   t   fullt   sizet   arrayR	   t   dot(   t   Xt   yt   losst   fit_interceptt   intercept_scalingt   Yt   dent   bias(    (    s1   lib/python2.7/site-packages/sklearn/svm/bounds.pyt   l1_min_c   s    (!*(   t   __doc__t   numpyR   t   preprocessingR    t   utils.validationR   R   t   utils.extmathR   t   TrueR   (    (    (    s1   lib/python2.7/site-packages/sklearn/svm/bounds.pyt   <module>   s   