ó
‡ˆ\c           @   sŸ  d  Z  d d l Z d d l m Z d d l Z d d l m Z m Z m	 Z	 d d l
 m Z d d l m Z m Z d d l m Z m Z m Z d d l m Z m Z 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! m" Z" d d l# m$ Z$ e j% d d d d d g ƒ d d … e j& f Z' e j% d d d d d g ƒ d d … e j& f Z( d e f d „  ƒ  YZ) d e e f d „  ƒ  YZ* d S(   s"   Gaussian processes classification.iÿÿÿÿN(   t
   itemgetter(   t   choleskyt	   cho_solvet   solve(   t   fmin_l_bfgs_b(   t   erft   expit(   t   BaseEstimatort   ClassifierMixint   clone(   t   RBFt   CompoundKernelt   ConstantKernel(   t	   check_X_yt   check_is_fittedt   check_array(   t   check_random_state(   t   LabelEncoder(   t   OneVsRestClassifiert   OneVsOneClassifier(   t   ConvergenceWarningg=
×£p=Ú?gš™™™™™Ù?g®Gáz®×?g)\Âõ(Ü?gö(\ÂõØ?gÃ;
!IûœÀgÄQfAÌy«@g>[(d©k@gîKìñ`@gv¨…úiŸÀt'   _BinaryGaussianProcessClassifierLaplacec           B   sk   e  Z d  Z d d d d e e d d „ Z d „  Z d „  Z d „  Z	 d e d „ Z
 e d	 „ Z d
 „  Z RS(   sï  Binary Gaussian process classification based on Laplace approximation.

    The implementation is based on Algorithm 3.1, 3.2, and 5.1 of
    ``Gaussian Processes for Machine Learning'' (GPML) by Rasmussen and
    Williams.

    Internally, the Laplace approximation is used for approximating the
    non-Gaussian posterior by a Gaussian.

    Currently, the implementation is restricted to using the logistic link
    function.

    .. versionadded:: 0.18

    Parameters
    ----------
    kernel : kernel object
        The kernel specifying the covariance function of the GP. If None is
        passed, the kernel "1.0 * RBF(1.0)" is used as default. Note that
        the kernel's hyperparameters are optimized during fitting.

    optimizer : string or callable, optional (default: "fmin_l_bfgs_b")
        Can either be one of the internally supported optimizers for optimizing
        the kernel's parameters, specified by a string, or an externally
        defined optimizer passed as a callable. If a callable is passed, it
        must have the  signature::

            def optimizer(obj_func, initial_theta, bounds):
                # * 'obj_func' is the objective function to be maximized, which
                #   takes the hyperparameters theta as parameter and an
                #   optional flag eval_gradient, which determines if the
                #   gradient is returned additionally to the function value
                # * 'initial_theta': the initial value for theta, which can be
                #   used by local optimizers
                # * 'bounds': the bounds on the values of theta
                ....
                # Returned are the best found hyperparameters theta and
                # the corresponding value of the target function.
                return theta_opt, func_min

        Per default, the 'fmin_l_bfgs_b' algorithm from scipy.optimize
        is used. If None is passed, the kernel's parameters are kept fixed.
        Available internal optimizers are::

            'fmin_l_bfgs_b'

    n_restarts_optimizer: int, optional (default: 0)
        The number of restarts of the optimizer for finding the kernel's
        parameters which maximize the log-marginal likelihood. The first run
        of the optimizer is performed from the kernel's initial parameters,
        the remaining ones (if any) from thetas sampled log-uniform randomly
        from the space of allowed theta-values. If greater than 0, all bounds
        must be finite. Note that n_restarts_optimizer=0 implies that one
        run is performed.

    max_iter_predict: int, optional (default: 100)
        The maximum number of iterations in Newton's method for approximating
        the posterior during predict. Smaller values will reduce computation
        time at the cost of worse results.

    warm_start : bool, optional (default: False)
        If warm-starts are enabled, the solution of the last Newton iteration
        on the Laplace approximation of the posterior mode is used as
        initialization for the next call of _posterior_mode(). This can speed
        up convergence when _posterior_mode is called several times on similar
        problems as in hyperparameter optimization. See :term:`the Glossary
        <warm_start>`.

    copy_X_train : bool, optional (default: True)
        If True, a persistent copy of the training data is stored in the
        object. Otherwise, just a reference to the training data is stored,
        which might cause predictions to change if the data is modified
        externally.

    random_state : int, RandomState instance or None, optional (default: None)
        The generator used to initialize the centers. If int, random_state is
        the seed used by the random number generator; If RandomState instance,
        random_state is the random number generator; If None, the random number
        generator is the RandomState instance used by `np.random`.

    Attributes
    ----------
    X_train_ : array-like, shape = (n_samples, n_features)
        Feature values in training data (also required for prediction)

    y_train_ : array-like, shape = (n_samples,)
        Target values in training data (also required for prediction)

    classes_ : array-like, shape = (n_classes,)
        Unique class labels.

    kernel_ : kernel object
        The kernel used for prediction. The structure of the kernel is the
        same as the one passed as parameter but with optimized hyperparameters

    L_ : array-like, shape = (n_samples, n_samples)
        Lower-triangular Cholesky decomposition of the kernel in X_train_

    pi_ : array-like, shape = (n_samples,)
        The probabilities of the positive class for the training points
        X_train_

    W_sr_ : array-like, shape = (n_samples,)
        Square root of W, the Hessian of log-likelihood of the latent function
        values for the observed labels. Since W is diagonal, only the diagonal
        of sqrt(W) is stored.

    log_marginal_likelihood_value_ : float
        The log-marginal-likelihood of ``self.kernel_.theta``

    R   i    id   c         C   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   kernelt	   optimizert   n_restarts_optimizert   max_iter_predictt
   warm_startt   copy_X_traint   random_state(   t   selfR   R   R   R   R   R   R   (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   __init__”   s    						c            sÒ  ˆ  j  d k r7 t d d d ƒt d d d ƒˆ  _ n t ˆ  j  ƒ ˆ  _ t ˆ  j ƒ ˆ  _ ˆ  j	 rs t
 j | ƒ n | ˆ  _ t ƒ  } | j | ƒ ˆ  _ | j ˆ  _ ˆ  j j d k r× t d ˆ  j j ˆ  j f ƒ ‚ n9 ˆ  j j d k rt d j ˆ  j j ˆ  j j ƒ ƒ ‚ n  ˆ  j d k	 rqˆ  j j d	 k rqt ‡  f d
 † } ˆ  j | ˆ  j j ˆ  j j ƒ g } ˆ  j d	 k r#t
 j ˆ  j j ƒ j ƒ  s t d ƒ ‚ n  ˆ  j j } xt t ˆ  j ƒ D]` } t
 j  ˆ  j j! | d d … d	 f | d d … d f ƒ ƒ } | j" ˆ  j | | | ƒ ƒ q¼Wn  t# t$ t% d ƒ | ƒ ƒ }	 | t
 j& |	 ƒ d	 ˆ  j _ t
 j' |	 ƒ ˆ  _( n ˆ  j) ˆ  j j ƒ ˆ  _( ˆ  j ˆ  j ƒ }
 ˆ  j* |
 d t ƒ\ } \ ˆ  _+ ˆ  _, ˆ  _- } } ˆ  S(   sP  Fit Gaussian process classification model

        Parameters
        ----------
        X : array-like, shape = (n_samples, n_features)
            Training data

        y : array-like, shape = (n_samples,)
            Target values, must be binary

        Returns
        -------
        self : returns an instance of self.
        g      ð?t   constant_value_boundst   fixedt   length_scale_boundsi   s=   %s supports only binary classification. y contains classes %si   s)   {0:s} requires 2 classes; got {1:d} classi    c            s?   | r- ˆ  j  |  d t ƒ\ } } | | f Sˆ  j  |  ƒ Sd  S(   Nt   eval_gradient(   t   log_marginal_likelihoodt   True(   t   thetaR"   t   lmlt   grad(   R   (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   obj_funcÉ   s
    sY   Multiple optimizer restarts (n_restarts_optimizer>0) requires that all bounds are finite.Nt   return_temporaries(.   R   t   Nonet   CR
   t   kernel_R	   R   R   t   rngR   t   npt   copyt   X_train_R   t   fit_transformt   y_train_t   classes_t   sizet
   ValueErrort	   __class__t   __name__t   formatR   t   n_dimsR$   t   _constrained_optimizationR%   t   boundsR   t   isfinitet   allt   ranget   expt   uniformt   appendt   listt   mapR    t   argmint   mint   log_marginal_likelihood_value_R#   t   _posterior_modet   pi_t   W_sr_t   L_(   R   t   Xt   yt   label_encoderR(   t   optimaR;   t	   iterationt   theta_initialt
   lml_valuest   Kt   _(    (   R   s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   fitŸ   sN    !			!			"3c         C   st   t  |  d d d d d g ƒ |  j |  j | ƒ } | j j |  j |  j ƒ } t j | d k |  j	 d |  j	 d ƒ S(   s.  Perform classification on an array of test vectors X.

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

        Returns
        -------
        C : array, shape = (n_samples,)
            Predicted target values for X, values are from ``classes_``
        R0   R2   RH   RI   RJ   i    i   (
   R   R,   R0   t   Tt   dotR2   RH   R.   t   whereR3   (   R   RK   t   K_start   f_star(    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   predictö   s    c   
      C   sI  t  |  d d d d d g ƒ |  j |  j | ƒ } | j j |  j |  j ƒ } t |  j |  j	 d d … t
 j f | ƒ } |  j j | ƒ t
 j d | | ƒ } d d	 | } t | } t
 j t
 j | ƒ t | t
 j | | t d	 ƒ ƒ d	 t
 j | d	 t
 j ƒ } t | j d
 d ƒ d t j ƒ  }	 t
 j d |	 |	 f ƒ j S(   sÀ  Return probability estimates for the test vector X.

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

        Returns
        -------
        C : array-like, shape = (n_samples, n_classes)
            Returns the probability of the samples for each class in
            the model. The columns correspond to the classes in sorted
            order, as they appear in the attribute ``classes_``.
        R0   R2   RH   RI   RJ   Ns   ij,ij->ji   i   t   axisi    g      à?(   R   R,   R0   RU   RV   R2   RH   R   RJ   RI   R.   t   newaxist   diagt   einsumt   LAMBDASt   sqrtt   piR   t   COEFSt   sumt   vstack(
   R   RK   RX   RY   t   vt
   var_f_start   alphat   gammat	   integralst   pi_star(    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   predict_proba  s    ,%	
U$c         C   s"  | d k r( | r! t d ƒ ‚ n  |  j S|  j j | ƒ } | r^ | |  j d t ƒ\ } } n | |  j ƒ } |  j | d t ƒ\ } \ } } }	 }
 } | s¡ | St j	 | j
 d ƒ } | d d … t j f t |	 t f t j | ƒ ƒ } t |	 | d d … t j f | ƒ } d t j | ƒ t j d | | ƒ | d | d d	 | } xÅ t | j
 d ƒ D]° } | d d … d d … | f } d
 | j j | ƒ j | ƒ d
 | j j ƒ  j | j ƒ  ƒ } | j |  j | ƒ }
 |
 | j | j |
 ƒ ƒ } | | j j | ƒ | | <qdW| | f S(   só  Returns log-marginal likelihood of theta for training data.

        Parameters
        ----------
        theta : array-like, shape = (n_kernel_params,) or None
            Kernel hyperparameters for which the log-marginal likelihood is
            evaluated. If None, the precomputed log_marginal_likelihood
            of ``self.kernel_.theta`` is returned.

        eval_gradient : bool, default: False
            If True, the gradient of the log-marginal likelihood with respect
            to the kernel hyperparameters at position theta is returned
            additionally. If True, theta must not be None.

        Returns
        -------
        log_likelihood : float
            Log-marginal likelihood of theta for training data.

        log_likelihood_gradient : array, shape = (n_kernel_params,), optional
            Gradient of the log-marginal likelihood with respect to the kernel
            hyperparameters at position theta.
            Only returned when eval_gradient is True.
        s.   Gradient can only be evaluated for theta!=NoneR"   R)   i    Ng      à¿s   ij, ij -> ji   i   g      à?(   R*   R5   RF   R,   t   clone_with_thetaR0   R$   RG   R.   t   emptyt   shapeR\   R   R]   R   R^   R>   RU   RV   t   ravelR2   (   R   R%   R"   R   RR   t
   K_gradientt   ZRa   t   W_srt   Lt   bt   at   d_Zt   RR+   t   s_2t   jt   s_1t   s_3(    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR#   3  s.    *5&>?c         C   sã  |  j  r< t |  d ƒ r< |  j j |  j j k r< |  j } n t j |  j d t j ƒ} t j } xOt	 |  j
 ƒ D]>} t | ƒ } | d | } t j | ƒ } | d d … t j f | }	 t j | j d ƒ |	 | }
 t |
 d t ƒ} | | |  j | } | | t | t f |	 j | ƒ ƒ } | j | ƒ } d | j j | ƒ t j t j |  j d d | ƒ ƒ j ƒ  t j t j | ƒ ƒ j ƒ  } | | d	 k  r©Pn  | } qq W| |  _ | rÛ| | | | | | f f S| Sd S(
   s   Mode-finding for binary Laplace GPC and fixed kernel.

        This approximates the posterior of the latent function values for given
        inputs and target observations with a Gaussian approximation and uses
        Newton's iteration to find the mode of this approximation.
        t   f_cachedt   dtypei   Ni    t   lowerg      à¿i   g»½×Ùß|Û=(   R   t   hasattrR|   Rn   R2   R.   t
   zeros_liket   float64t   infR>   R   R   R`   R\   t   eyeR   R$   R   RV   RU   t   log1pR?   Rc   t   logR]   (   R   RR   R)   t   fR#   RS   Ra   t   WRr   t   W_sr_Kt   BRs   Rt   Ru   R&   (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyRG   v  s.    
&^
	c         C   s¤   |  j  d k rW t | | d | ƒ\ } } } | d d k rš t j d | t ƒ qš nC t |  j  ƒ r‡ |  j  | | d | ƒ\ } } n t d |  j  ƒ ‚ | | f S(   NR   R;   t   warnflagi    s7   fmin_l_bfgs_b terminated abnormally with the  state: %ss   Unknown optimizer %s.(   R   R   t   warningst   warnR   t   callableR5   (   R   R(   t   initial_thetaR;   t	   theta_optt   func_mint   convergence_dict(    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR:   «  s    	!N(   R7   t
   __module__t   __doc__R*   t   FalseR$   R   RT   RZ   Rk   R#   RG   R:   (    (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR   $   s   o		W		'C5t   GaussianProcessClassifierc        
   B   sk   e  Z d  Z d d d d e e d d d d „	 Z d „  Z d „  Z d „  Z	 e
 d	 „  ƒ Z d e d
 „ Z RS(   sÈ  Gaussian process classification (GPC) based on Laplace approximation.

    The implementation is based on Algorithm 3.1, 3.2, and 5.1 of
    Gaussian Processes for Machine Learning (GPML) by Rasmussen and
    Williams.

    Internally, the Laplace approximation is used for approximating the
    non-Gaussian posterior by a Gaussian.

    Currently, the implementation is restricted to using the logistic link
    function. For multi-class classification, several binary one-versus rest
    classifiers are fitted. Note that this class thus does not implement
    a true multi-class Laplace approximation.

    Parameters
    ----------
    kernel : kernel object
        The kernel specifying the covariance function of the GP. If None is
        passed, the kernel "1.0 * RBF(1.0)" is used as default. Note that
        the kernel's hyperparameters are optimized during fitting.

    optimizer : string or callable, optional (default: "fmin_l_bfgs_b")
        Can either be one of the internally supported optimizers for optimizing
        the kernel's parameters, specified by a string, or an externally
        defined optimizer passed as a callable. If a callable is passed, it
        must have the  signature::

            def optimizer(obj_func, initial_theta, bounds):
                # * 'obj_func' is the objective function to be maximized, which
                #   takes the hyperparameters theta as parameter and an
                #   optional flag eval_gradient, which determines if the
                #   gradient is returned additionally to the function value
                # * 'initial_theta': the initial value for theta, which can be
                #   used by local optimizers
                # * 'bounds': the bounds on the values of theta
                ....
                # Returned are the best found hyperparameters theta and
                # the corresponding value of the target function.
                return theta_opt, func_min

        Per default, the 'fmin_l_bfgs_b' algorithm from scipy.optimize
        is used. If None is passed, the kernel's parameters are kept fixed.
        Available internal optimizers are::

            'fmin_l_bfgs_b'

    n_restarts_optimizer : int, optional (default: 0)
        The number of restarts of the optimizer for finding the kernel's
        parameters which maximize the log-marginal likelihood. The first run
        of the optimizer is performed from the kernel's initial parameters,
        the remaining ones (if any) from thetas sampled log-uniform randomly
        from the space of allowed theta-values. If greater than 0, all bounds
        must be finite. Note that n_restarts_optimizer=0 implies that one
        run is performed.

    max_iter_predict : int, optional (default: 100)
        The maximum number of iterations in Newton's method for approximating
        the posterior during predict. Smaller values will reduce computation
        time at the cost of worse results.

    warm_start : bool, optional (default: False)
        If warm-starts are enabled, the solution of the last Newton iteration
        on the Laplace approximation of the posterior mode is used as
        initialization for the next call of _posterior_mode(). This can speed
        up convergence when _posterior_mode is called several times on similar
        problems as in hyperparameter optimization. See :term:`the Glossary
        <warm_start>`.

    copy_X_train : bool, optional (default: True)
        If True, a persistent copy of the training data is stored in the
        object. Otherwise, just a reference to the training data is stored,
        which might cause predictions to change if the data is modified
        externally.

    random_state : int, RandomState instance or None, optional (default: None)
        The generator used to initialize the centers.
        If int, random_state is the seed used by the random number generator;
        If RandomState instance, random_state is the random number generator;
        If None, the random number generator is the RandomState instance used
        by `np.random`.

    multi_class : string, default : "one_vs_rest"
        Specifies how multi-class classification problems are handled.
        Supported are "one_vs_rest" and "one_vs_one". In "one_vs_rest",
        one binary Gaussian process classifier is fitted for each class, which
        is trained to separate this class from the rest. In "one_vs_one", one
        binary Gaussian process classifier is fitted for each pair of classes,
        which is trained to separate these two classes. The predictions of
        these binary predictors are combined into multi-class predictions.
        Note that "one_vs_one" does not support predicting probability
        estimates.

    n_jobs : int or None, optional (default=None)
        The number of jobs to use for the computation.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    Attributes
    ----------
    kernel_ : kernel object
        The kernel used for prediction. In case of binary classification,
        the structure of the kernel is the same as the one passed as parameter
        but with optimized hyperparameters. In case of multi-class
        classification, a CompoundKernel is returned which consists of the
        different kernels used in the one-versus-rest classifiers.

    log_marginal_likelihood_value_ : float
        The log-marginal-likelihood of ``self.kernel_.theta``

    classes_ : array-like, shape = (n_classes,)
        Unique class labels.

    n_classes_ : int
        The number of classes in the training data

    Examples
    --------
    >>> from sklearn.datasets import load_iris
    >>> from sklearn.gaussian_process import GaussianProcessClassifier
    >>> from sklearn.gaussian_process.kernels import RBF
    >>> X, y = load_iris(return_X_y=True)
    >>> kernel = 1.0 * RBF(1.0)
    >>> gpc = GaussianProcessClassifier(kernel=kernel,
    ...         random_state=0).fit(X, y)
    >>> gpc.score(X, y) # doctest: +ELLIPSIS
    0.9866...
    >>> gpc.predict_proba(X[:2,:])
    array([[0.83548752, 0.03228706, 0.13222543],
           [0.79064206, 0.06525643, 0.14410151]])

    .. versionadded:: 0.18
    R   i    id   t   one_vs_restc
   
      C   sU   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ d  S(   N(	   R   R   R   R   R   R   R   t   multi_classt   n_jobs(
   R   R   R   R   R   R   R   R   R—   R˜   (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR   B  s    								c         C   s  t  | | d t ƒ\ } } t |  j |  j |  j |  j |  j |  j |  j	 ƒ |  _
 t j | ƒ |  _ |  j j |  _ |  j d k r¤ t d |  j |  j d f ƒ ‚ n  |  j d k r#|  j d k rà t |  j
 d |  j ƒ|  _
 q#|  j d k rt |  j
 d |  j ƒ|  _
 q#t d	 |  j ƒ ‚ n  |  j
 j | | ƒ |  j d k ryt j g  |  j
 j D] } | j ƒ  ^ qXƒ |  _ n |  j
 j ƒ  |  _ |  S(
   sP  Fit Gaussian process classification model

        Parameters
        ----------
        X : array-like, shape = (n_samples, n_features)
            Training data

        y : array-like, shape = (n_samples,)
            Target values, must be binary

        Returns
        -------
        self : returns an instance of self.
        t   multi_outputi   sf   GaussianProcessClassifier requires 2 or more distinct classes; got %d class (only class %s is present)i    i   R–   R˜   t
   one_vs_ones   Unknown multi-class mode %s(   R   R”   R   R   R   R   R   R   R   R   t   base_estimator_R.   t   uniqueR3   R4   t
   n_classes_R5   R—   R   R˜   R   RT   t   meant   estimators_R#   RF   (   R   RK   RL   t	   estimator(    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyRT   P  s4    +c         C   s/   t  |  d d g ƒ t | ƒ } |  j j | ƒ S(   s.  Perform classification on an array of test vectors X.

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

        Returns
        -------
        C : array, shape = (n_samples,)
            Predicted target values for X, values are from ``classes_``
        R3   R   (   R   R   R›   RZ   (   R   RK   (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyRZ   †  s    c         C   s\   t  |  d d g ƒ |  j d k r@ |  j d k r@ t d ƒ ‚ n  t | ƒ } |  j j | ƒ S(   s¾  Return probability estimates for the test vector X.

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

        Returns
        -------
        C : array-like, shape = (n_samples, n_classes)
            Returns the probability of the samples for each class in
            the model. The columns correspond to the classes in sorted
            order, as they appear in the attribute `classes_`.
        R3   R   i   Rš   sl   one_vs_one multi-class mode does not support predicting probability estimates. Use one_vs_rest mode instead.(   R   R   R—   R5   R   R›   Rk   (   R   RK   (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyRk   –  s
    c         C   sC   |  j  d k r |  j j St g  |  j j D] } | j ^ q) ƒ Sd  S(   Ni   (   R   R›   R,   R   RŸ   (   R   R    (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR,   ¬  s
    
c      	   C   s€  t  |  d d g ƒ | d	 k r; | r4 t d ƒ ‚ n  |  j St j | ƒ } |  j d k rl |  j j | | ƒ S| r t	 d ƒ ‚ n  |  j j
 } | d j j } | j d | k rå t j g  t | ƒ D] \ } } | j | ƒ ^ qÃ ƒ S| j d | |  j j d k rNt j g  t | ƒ D]. \ } } | j | | | | | d !ƒ ^ qƒ St d | | |  j j d | j d f ƒ ‚ d	 S(
   sÎ  Returns log-marginal likelihood of theta for training data.

        In the case of multi-class classification, the mean log-marginal
        likelihood of the one-versus-rest classifiers are returned.

        Parameters
        ----------
        theta : array-like, shape = (n_kernel_params,) or none
            Kernel hyperparameters for which the log-marginal likelihood is
            evaluated. In the case of multi-class classification, theta may
            be the  hyperparameters of the compound kernel or of an individual
            kernel. In the latter case, all individual kernel get assigned the
            same theta values. If None, the precomputed log_marginal_likelihood
            of ``self.kernel_.theta`` is returned.

        eval_gradient : bool, default: False
            If True, the gradient of the log-marginal likelihood with respect
            to the kernel hyperparameters at position theta is returned
            additionally. Note that gradient computation is not supported
            for non-binary classification. If True, theta must not be None.

        Returns
        -------
        log_likelihood : float
            Log-marginal likelihood of theta for training data.

        log_likelihood_gradient : array, shape = (n_kernel_params,), optional
            Gradient of the log-marginal likelihood with respect to the kernel
            hyperparameters at position theta.
            Only returned when eval_gradient is True.
        R3   R   s.   Gradient can only be evaluated for theta!=Nonei   sH   Gradient of log-marginal-likelihood not implemented for multi-class GPC.i    i   sE   Shape of theta must be either %d or %d. Obtained theta with shape %d.N(   R   R*   R5   RF   R.   t   asarrayR   R›   R#   t   NotImplementedErrorRŸ   R,   R9   Rn   Rž   t	   enumerateR3   (   R   R%   R"   t
   estimatorsR9   t   iR    (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR#   µ  s4     	
,!?N(   R7   R’   R“   R*   R”   R$   R   RT   RZ   Rk   t   propertyR,   R#   (    (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyR•   ¼  s   …		6			(+   R“   R‹   t   operatorR    t   numpyR.   t   scipy.linalgR   R   R   t   scipy.optimizeR   t   scipy.specialR   R   t   sklearn.baseR   R   R	   t    sklearn.gaussian_process.kernelsR
   R   R   R+   t   sklearn.utils.validationR   R   R   t   sklearn.utilsR   t   sklearn.preprocessingR   t   sklearn.multiclassR   R   t   sklearn.exceptionsR   t   arrayR\   R_   Rb   R   R•   (    (    (    s;   lib/python2.7/site-packages/sklearn/gaussian_process/gpc.pyt   <module>   s&   	1"ÿ ™