前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Defining the Gaussian process object directly直接定义高斯过程对象

Defining the Gaussian process object directly直接定义高斯过程对象

作者头像
到不了的都叫做远方
修改2019-11-11 10:55:13
3550
修改2019-11-11 10:55:13
举报
文章被收录于专栏:翻译scikit-learn Cookbook

We just touched the surface of Gaussian processes. In this recipe, we'll look at how we can directly access the Gaussian process object with the correlation function we want.

我们刚接触到高斯过程的表面,在这部分,我们将直接用我们希望的关联函数来访问高斯过程。

Getting ready准备工作

Within the gaussian_process module, there is direct access to many of the correlation functions or regression functions. This means that instead of creating the GaussianProcess object, we can just create this object through a function. If you're more familiar with object-oriented code, this is basically a class method at the module level.

在gaussian_process模块中,可以直接访问很多关联函数或回归函数,这意味着除了生成GaussianProcess对象,我们能只用一个函数生成这个对象。如果你对面向对象编程更熟悉,这就是模块级别的一个类方法。

In this chapter, we'll march through most of the functions and show their results on example data. Do not stop at these examples if you want to get more familiar with the behavior of the various covariate functions. Hopefully, you're still using IPython (or the notebook).

这章里,我们将通过大量函数和展示他们作用在样本数据的结果,不要止步于这些例子,如果你想要更熟悉各种不同共变函数的行为,希望你依然在使用IPython (or the notebook)

Since this doesn't expose anything thing new mathematically, we'll just show how to do it.这里没有讲过多的新的数学知识,所以我们只要看看怎么做就行:

How to do it…怎么做

First, we'll import some basic regression data:首先,我们导入一些基本的回归数据

>>> from sklearn.datasets import make_regression

>>> X, y = make_regression(1000, 1, 1)

>>> from sklearn.gaussian_process import regression_models

First up is the constant correlation function. This will comprise a constant and more for completeness:

首先是连续相关函数,这将包含一个连续完整的数据:

>>> regression_models.constant(X)[:5]

array([[ 1.],

[ 1.],

[ 1.],

[ 1.],

[ 1.]])

Another option is the squared exponential correlation function. This is also the default for the GaussianProcess class:

另一个选项是平方指数相关函数,这也是GaussianProcess类中默认设置的

>>> regression_models.linear(X)[:1]

array([[ 1., 0.38833572]])

>>> regression_models.quadratic(X)[:1]

array([[ 1., 0.38833572, 0.15080463]])

How it works…它怎么工作的

Now that we have the regression function, we can feed it directly into the GaussianProcess object. The default is the constant regression function, but we can just as easily pass it in a linear model or a quadratic model.

现在我们有了回归模型,我们能直接将它喂入GaussianProcess对象,默认是连续回归函数,但是我们能很简单的传入线性模型和二次方模型

本文系外文翻译,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系外文翻译前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档