`L idZddlmZddlmZddlZddlZddl m Z m Z m Z ddl mZmZddlmZmZmZmZdd lmZmZdd lmZdd lmZdd lmZmZdd lm Z ddl!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'ddl$m(Z)ejTgdddejVfZ,ejTgdddejVfZ-GddeZ.GddeeZ/y)z"Gaussian processes classification.)Integral) itemgetterN) cho_solvecholeskysolve)erfexpit) BaseEstimatorClassifierMixin _fit_contextclone)OneVsOneClassifierOneVsRestClassifier) LabelEncoder)check_random_state)Interval StrOptions)_check_optimize_result)check_is_fitted validate_data)RBFCompoundKernelKernel)ConstantKernel)g= ףp=?g?gGz?g)\(?g(\?)g; !IgQfAy@g>[(dk@gK`@gvicZeZdZdZ ddddddddd Zd Zd Zd Z dd ZdZ ddZ dZ y)'_BinaryGaussianProcessClassifierLaplacea*Binary Gaussian process classification based on Laplace approximation. The implementation is based on Algorithm 3.1, 3.2, and 5.1 from [RW2006]_. 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 instance, default=None 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 : 'fmin_l_bfgs_b' or callable, 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 'L-BFGS-B' algorithm from scipy.optimize.minimize 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, 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, 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, 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 `. copy_X_train : bool, 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, default=None Determines random number generation used to initialize the centers. Pass an int for reproducible results across multiple function calls. See :term:`Glossary `. Attributes ---------- X_train_ : array-like of shape (n_samples, n_features) or list of object Feature vectors or other representations of training data (also required for prediction). y_train_ : array-like of shape (n_samples,) Target values in training data (also required for prediction) classes_ : array-like of shape (n_classes,) Unique class labels. kernel_ : kernl instance 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 of shape (n_samples, n_samples) Lower-triangular Cholesky decomposition of the kernel in X_train_ pi_ : array-like of shape (n_samples,) The probabilities of the positive class for the training points X_train_ W_sr_ : array-like of 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`` References ---------- .. [RW2006] `Carl E. Rasmussen and Christopher K.I. Williams, "Gaussian Processes for Machine Learning", MIT Press 2006 `_ N fmin_l_bfgs_brdFT) optimizern_restarts_optimizermax_iter_predict warm_start copy_X_train random_statecf||_||_||_||_||_||_||_yNkernelr!r"r#r$r%r&)selfr*r!r"r#r$r%r&s c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/gaussian_process/_gpc.py__init__z0_BinaryGaussianProcessClassifierLaplace.__init__s9 "$8! 0$((c 0j!tddtddz_nt j_t j _jrtj|n|_ t}|j|_|j_jj dkDr.t#j$j&djjj dk(rCt#d j)j$j&jj j*jj,d kDrdfd }j/|jj0jj2g}j4d kDrtj6jj2j9s t#d jj2}t;j4D]a}tj<jj?|ddd f|dddf}|jAj/|||ctCtEtGd|} |tjH| d j_jjKtjL|  _'n*jQjj0_'jj} jS| d \} \_*_+_,} } S)aFit Gaussian process classification model. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Feature vectors or other representations of training data. y : array-like of shape (n_samples,) Target values, must be binary. Returns ------- self : returns an instance of self. Ng?fixed)constant_value_bounds)length_scale_boundsr z9 supports only binary classification. y contains classes rz){0:s} requires 2 classes; got {1:d} classrTcj|rj|dd\}}| | fSj|d S)NTF) eval_gradient clone_kernelr5)log_marginal_likelihood)thetar4lmlgradr+s r,obj_funcz=_BinaryGaussianProcessClassifierLaplace.fit..obj_funcsO $ < <T!=!IC 4$;& 88U8SSSr.zYMultiple optimizer restarts (n_restarts_optimizer>0) requires that all bounds are finite.return_temporaries)T)-r*Crkernel_rrr&rngr%npcopyX_train_r fit_transformy_train_classes_size ValueError __class____name__formatr!n_dims_constrained_optimizationr8boundsr"isfiniteallrangeexpuniformappendlistmaprargmin_check_bounds_paramsminlog_marginal_likelihood_value_r7_posterior_modepi_W_sr_L_) r+Xy label_encoderr;optimarN iteration theta_initial lml_valuesK_s ` r,fitz+_BinaryGaussianProcessClassifierLaplace.fits ;; S@3DDL!-DL%d&7&78&*&7&7 Q % %33A6 %.. ==   !>>**DMM; ]]  1 $;BBNN++T]]-?-?  >> %$,,*=*=*A T..dll00$,,2E2EF((1,{{4<<#6#67;;=$?,,!&t'@'@!AI$&FF488+;+;F1a4L&QRTUQU,+W$XMMM66xPVWc*Q-89J!' *(=!>q!ADLL  LL - - /3566*3E2ED /262N2N ""3D / LL '373G3G $4H4 0 0DHdj$'1a r.ct||j|j|}|jj |j |j z }tj|dkD|jd|jdS)aPerform classification on an array of test vectors X. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- C : ndarray of shape (n_samples,) Predicted target values for X, values are from ``classes_`` rr) rr?rCTdotrEr\rAwhererF)r+r_K_starf_stars r,predictz/_BinaryGaussianProcessClassifierLaplace.predict sj  dmmQ/dmmdhh67xx DMM!$4dmmA6FGGr.c t||j|\}}dd|zz }t|z}tjtj |z t |tj||tdzzz zzdtj|dztj zzz }t|zjddtjzz}tjd|z |fjS)aReturn probability estimates for the test vector X. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- C : array-like of 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_``. rr r)axis?) rlatent_mean_and_varianceLAMBDASrAsqrtpirCOEFSsumvstackrj)r+r_ latent_mean latent_varalphagamma integralspi_stars r, predict_probaz5_BinaryGaussianProcessClassifierLaplace.predict_proba$s #'"?"?"B ZQ^$+% GGBEEEM "%"''%57A:+=">??@ A277:>BEE122 4  9$))q)1C%))+4EEyy!g+w/0222r.c||r td|jS|r|jj|}n|j}||_|r||j d\}}n||j }|j |d\}\}} } } } |s|Stj|jd} | ddtjft| dftj| z}t| | ddtjf|z}dtj|tjd||z z|d |z zd d |zz zz}t| jdD]}dddd|f}d | j j#|j#| zd |j j%j#|j$zz }|j"|j&|z } | |j#|j#| z }||j j#|z| |<|| fS) aReturns log-marginal likelihood of theta for training data. Parameters ---------- theta : array-like of shape (n_kernel_params,), default=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. clone_kernel : bool, default=True If True, the kernel attribute is copied. If False, the kernel attribute is modified, but may result in a performance improvement. Returns ------- log_likelihood : float Log-marginal likelihood of theta for training data. log_likelihood_gradient : ndarray of 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. N.Gradient can only be evaluated for theta!=NoneT)r4r<rz ij, ij -> jrr rr)rHrZr?clone_with_thetar8rCr[rAemptyshapenewaxisrdiagreinsumrQrjrkravelrE)r+r8r4r5r*rf K_gradientZrvW_srLbad_ZRr>s_2js_1s_3s r,r7z?_BinaryGaussianProcessClassifierLaplace.log_marginal_likelihoodKs@ = !QRR66 6 \\2259F\\F FL "4==EMAzt}}%A"&!5!5aD!5!Q BaAHhhu{{1~& BJJ )QIrwwt}"E E !T!RZZ-(1, - wwqzBIImQ:: <QV}AF + - syy|$ *A1a7#A q))C!##))+//'!'')2L,LLCdmmb()AaeeAEE!Ho%C35599S>)CF *#v r.ct||j|j|}|jj |j |j z }t|j|jddtjf|z}|jj|tjd||z }||fS)aCompute the mean and variance of the latent function values. Based on algorithm 3.2 of [RW2006]_, this function returns the latent mean (Line 4) and variance (Line 6) of the Gaussian process classification model. Note that this function is only supported for binary classification. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- latent_mean : array-like of shape (n_samples,) Mean of the latent function values at the query points. latent_var : array-like of shape (n_samples,) Variance of the latent function values at the query points. Nzij,ij->j)rr?rCrjrkrEr\rr^r]rArrr)r+r_rmrzvr{s r,rsz@_BinaryGaussianProcessClassifierLaplace.latent_mean_and_variances, dmmQ/hhll4==488#;< $''4::am4v= >\\&&q)BIIj!Q,GG J&&r.c ^|jrFt|dr:|jj|jjk(r |j}n/t j |jt j}t j }t|jD]o}t|}|d|z z}t j|}|ddt jf|z} t j|jd| |zz} t| d} ||z|j|z z} | |t!| df| j#| zz } |j#| }d| j$j#|zt j&t j(|jd zdz |zj+z t j,t j.| j+z }||z d krn|}r||_|r |   ffS|S) a 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. f_cached)dtyperNrT)lowerrr g|=)r$hasattrrrrErA zeros_likefloat64infrQr#r rureyerrrkrjlog1prRrxlogr)r+rfr=fr7rgrvWrW_sr_KBrrrr9s r,r[z7_BinaryGaussianProcessClassifierLaplace._posterior_modes OOj) ##t}}':':: A dmm2::>A$&66't,,- *AqBa"f A771:D!RZZ-(1,Fqwwqz"Vd]2A$'AA+,AD9aY 1 >>>AaA qsswwqz!((266DMMA$5$9":Q">?@DDFG&&$((*+ ,,u4&) #9 *< *Rq!Q,?? ?* *r.cH|jdk(rLtjj||dd|}t d||j |j }}||fSt|jr|j|||\}}||fStd|jz)NrzL-BFGS-BT)methodjacrNlbfgs)rNzUnknown optimizer %s.) r!scipyoptimizeminimizerxfuncallablerH)r+r; initial_thetarNopt_res theta_optfunc_mins r,rMzA_BinaryGaussianProcessClassifierLaplace._constrained_optimizations >>_ ,nn--- V.G #7G 4")))W[[xI ("" dnn %"&..=QW."X Ix(""4t~~EF Fr.r(NFT)F) rJ __module__ __qualname____doc__r-rhrorr7rsr[rMr.r,rr$s]qj)")&`DH.%3P=AM^'B8+t #r.rc eZdZUdZedgedhedgeedddgeedddgdgdgd ged d hgedgd Z e e d < dddddddd dddZ e ddZdZdZedZ ddZdZy)GaussianProcessClassifieraKGaussian process classification (GPC) based on Laplace approximation. The implementation is based on Algorithm 3.1, 3.2, and 5.1 from [RW2006]_. 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. Read more in the :ref:`User Guide `. .. versionadded:: 0.18 Parameters ---------- kernel : kernel instance, default=None 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. Also kernel cannot be a `CompoundKernel`. optimizer : 'fmin_l_bfgs_b', callable or None, 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 'L-BFGS-B' algorithm from scipy.optimize.minimize 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, 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, 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, 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 `. copy_X_train : bool, 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, default=None Determines random number generation used to initialize the centers. Pass an int for reproducible results across multiple function calls. See :term:`Glossary `. multi_class : {'one_vs_rest', 'one_vs_one'}, 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, default=None The number of jobs to use for the computation: the specified multiclass problems are computed in parallel. ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary ` for more details. Attributes ---------- base_estimator_ : ``Estimator`` instance The estimator instance that defines the likelihood function using the observed data. kernel_ : kernel instance 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 of shape (n_classes,) Unique class labels. n_classes_ : int The number of classes in the training data 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 -------- GaussianProcessRegressor : Gaussian process regression (GPR). References ---------- .. [RW2006] `Carl E. Rasmussen and Christopher K.I. Williams, "Gaussian Processes for Machine Learning", MIT Press 2006 `_ 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) 0.9866... >>> gpc.predict_proba(X[:2,:]) array([[0.83548752, 0.03228706, 0.13222543], [0.79064206, 0.06525643, 0.14410151]]) For a comparison of the GaussianProcessClassifier with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. Nrrleft)closedrbooleanr& one_vs_rest one_vs_one r*r!r"r#r$r%r& multi_classn_jobs_parameter_constraintsr FT)r!r"r#r$r%r&rrc||_||_||_||_||_||_||_||_| |_yr(r) r+r*r!r"r#r$r%r&rrs r,r-z"GaussianProcessClassifier.__init__sH "$8! 0$((& r.)prefer_skip_nested_validationc t|jtr td|j|jjrt |||ddd\}}nt |||ddd\}}t |j|j|j|j|j|j|j|_ tj||_|j j"|_|j$dk(r'td |j$|j d fz|j$d kDr|j&d k(r't)|j|j* |_ nN|j&dk(r't-|j|j* |_ ntd|j&z|jj/|||j$d kDrLtj0|jj2Dcgc]}|j5c}|_|S|jj5|_|Scc}w)aFit Gaussian process classification model. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Feature vectors or other representations of training data. y : array-like of shape (n_samples,) Target values, must be binary. Returns ------- self : object Returns an instance of self. z!kernel cannot be a CompoundKernelNFTnumeric) multi_output ensure_2drr)rzfGaussianProcessClassifier requires 2 or more distinct classes; got %d class (only class %s is present)rr r)rrzUnknown multi-class mode %s) isinstancer*rrHrequires_vector_inputrrr!r"r#r$r%r&base_estimator_rAuniquerFrG n_classes_rrrrrhmean estimators_r7rZ)r+r_r` estimators r,rhzGaussianProcessClassifier.fits" dkk> 2@A A ;; $++"C"C a$iDAq!a%tDAq G;;nn!%!:!:!22****  !  --,, ??a !%$--2B CD  ??Q =0':((($!!\1'9((($!!>AQAQ!QRR   A& ??Q 24''&*%9%9%E%E!5573D / $$<<>  / sI$ct||j|jjrt||ddd}nt||ddd}|jj |S)aPerform classification on an array of test vectors X. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- C : ndarray of shape (n_samples,) Predicted target values for X, values are from ``classes_``. NTrFrrreset)rr*rrrror+r_s r,roz!GaussianProcessClassifier.predicts]  ;; $++"C"CdAYeTAdAd%PA##++A..r.c&t||jdkDr|jdk(r td|j|jj rt ||ddd}nt ||ddd}|jj|S) aReturn probability estimates for the test vector X. Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- C : array-like of 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 :term:`classes_`. r rzlone_vs_one multi-class mode does not support predicting probability estimates. Use one_vs_rest mode instead.NTrFr) rrrrHr*rrrrrs r,rz'GaussianProcessClassifier.predict_proba+s  ??Q 4#3#3|#C,  ;; $++"C"CdAYeTAdAd%PA##11!44r.c|jdk(r|jjSt|jjDcgc]}|jc}Scc}w)z(Return the kernel of the base estimator.r )rrr?rr)r+rs r,r?z!GaussianProcessClassifier.kernel_IsR ??a ''// /!484H4H4T4TUy""U UsAc nt|||r td|jStj|}|j dk(r|j j|||S|r td|j j}|djj}|jd|k(rBtjt|Dcgc]\}}|j||c}}S|jd||jjdzk(rNtjt|Dcgc]$\}}|j|||z||dzz|&c}}Std|||jjdz|jdfzcc}}wcc}}w)aReturn 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 of shape (n_kernel_params,), default=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. clone_kernel : bool, default=True If True, the kernel attribute is copied. If False, the kernel attribute is modified, but may result in a performance improvement. Returns ------- log_likelihood : float Log-marginal likelihood of theta for training data. log_likelihood_gradient : ndarray of 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. rr r6zHGradient of log-marginal-likelihood not implemented for multi-class GPC.rrzEShape of theta must be either %d or %d. Obtained theta with shape %d.)rrHrZrAasarrayrrr7NotImplementedErrorrr?rLrr enumeraterF)r+r8r4r5 estimatorsrLirs r,r7z1GaussianProcessClassifier.log_marginal_likelihoodSsL  = !QRR66 6 5! ??a ''??}<@ )'--99J]**11F{{1~'ww -6j,A )Ay"99! :Q6DMM,?,?,B#BBww -6j,A  )Ay "99!&1*vQ/?@)5:!4v (;(;A(>> AOP's F+ )F1 c$|jdkDrtd|jdt||j|jjrt ||ddd}nt ||ddd}|j j|S) a/Compute the mean and variance of the latent function. Based on algorithm 3.2 of [RW2006]_, this function returns the latent mean (Line 4) and variance (Line 6) of the Gaussian process classification model. Note that this function is only supported for binary classification. .. versionadded:: 1.7 Parameters ---------- X : array-like of shape (n_samples, n_features) or list of object Query points where the GP is evaluated for classification. Returns ------- latent_mean : array-like of shape (n_samples,) Mean of the latent function values at the query points. latent_var : array-like of shape (n_samples,) Variance of the latent function values at the query points. r zoReturning the mean and variance of the latent function f is only supported for binary classification, received z classes.NTrFr)rrHrr*rrrrsrs r,rsz2GaussianProcessClassifier.latent_mean_and_variances0 ??Q I??#9.   ;; $++"C"CdAYeTAdAd%PA##<arrayrrtrwrrrr.r,rs( 33$FF@(&:3=00( "((0 1!RZZ- @N RZZ-  ]#m]#@I@I@r.