跟着Leo机器学习:sklearn之 Gaussian Processes

1.7. Gaussian Processes

sklearn 框架

跟着Leo机器学习:sklearn之 Gaussian Processes_第1张图片

函数导图

跟着Leo机器学习:sklearn之 Gaussian Processes_第2张图片

1.7.1. Gaussian Process Regression (GPR)

from sklearn.datasets import make_friedman2
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import DotProduct, WhiteKernel
X, y = make_friedman2(n_samples=500, noise=0, random_state=0)
kernel = DotProduct() + WhiteKernel()
gpr = GaussianProcessRegressor(kernel=kernel,
        random_state=0).fit(X, y)
gpr.score(X, y)

gpr.predict(X[:2,:], return_std=True)

源地址

https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.html#sklearn.gaussian_process.GaussianProcessRegressor

1.7.3. Gaussian Process Classification (GPC)

类包

sklearn.gaussian_process.GaussianProcessClassifier(kernel=None, optimizer='fmin_l_bfgs_b', n_restarts_optimizer=0, max_iter_predict=100, warm_start=False, copy_X_train=True, random_state=None, multi_class='one_vs_rest', n_jobs=None)[source]
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)

gpc.predict_proba(X[:2,:])

你可能感兴趣的:(机器学习sklearn应用笔记)