Exponentiation#

class sklearn.gaussian_process.kernels.Exponentiation(kernel, exponent)[source]#

Exponentiation 核接受一个基础核函数和一个标量参数 \(p\),并通过以下方式组合它们:

\[k_{exp}(X, Y) = k(X, Y) ^p\]

请注意,`__pow__` 魔法方法已被重写,因此 `Exponentiation(RBF(), 2)` 等同于使用 `RBF() ** 2` 运算符。

用户指南中阅读更多内容。

0.18 版本新增。

参数:
kernelKernel(核函数)

基础核函数

exponentfloat(浮点数)

基础核函数的指数

示例

>>> from sklearn.datasets import make_friedman2
>>> from sklearn.gaussian_process import GaussianProcessRegressor
>>> from sklearn.gaussian_process.kernels import (RationalQuadratic,
...            Exponentiation)
>>> X, y = make_friedman2(n_samples=500, noise=0, random_state=0)
>>> kernel = Exponentiation(RationalQuadratic(), exponent=2)
>>> gpr = GaussianProcessRegressor(kernel=kernel, alpha=5,
...         random_state=0).fit(X, y)
>>> gpr.score(X, y)
0.419
>>> gpr.predict(X[:1,:], return_std=True)
(array([635.5]), array([0.559]))
__call__(X, Y=None, eval_gradient=False)[source]#

返回核函数 k(X, Y) 及其可选的梯度。

参数:
Xarray-like of shape (n_samples_X, n_features) 或 list of object(类数组,形状为 (n_samples_X, n_features) 或对象列表)

返回的核函数 k(X, Y) 的左参数

Yarray-like of shape (n_samples_Y, n_features) 或 list of object, default=None(类数组,形状为 (n_samples_Y, n_features) 或对象列表,默认为 None)

返回的核函数 k(X, Y) 的右参数。如果为 None,则计算 k(X, X)。

eval_gradientbool, default=False(布尔值,默认为 False)

确定是否计算关于核函数超参数对数的梯度。

返回:
Kndarray of shape (n_samples_X, n_samples_Y)(形状为 (n_samples_X, n_samples_Y) 的 ndarray)

核函数 k(X, Y)

K_gradientndarray of shape (n_samples_X, n_samples_X, n_dims), optional(形状为 (n_samples_X, n_samples_X, n_dims) 的 ndarray,可选)

核函数 k(X, X) 关于核函数超参数对数的梯度。仅当 eval_gradient 为 True 时返回。

property bounds#

返回 theta 的对数变换边界。

返回:
boundsndarray of shape (n_dims, 2)(形状为 (n_dims, 2) 的 ndarray)

核函数超参数 theta 的对数变换边界

clone_with_theta(theta)[source]#

返回一个使用给定超参数 theta 的自身克隆。

参数:
thetandarray of shape (n_dims,)(形状为 (n_dims,) 的 ndarray)

超参数

diag(X)[source]#

返回核函数 k(X, X) 的对角线。

此方法的结果与 np.diag(self(X)) 相同;然而,由于只计算对角线,因此可以更有效地进行评估。

参数:
Xarray-like of shape (n_samples_X, n_features) 或 list of object(类数组,形状为 (n_samples_X, n_features) 或对象列表)

核函数的参数。

返回:
K_diagndarray of shape (n_samples_X,)(形状为 (n_samples_X,) 的 ndarray)

核函数 k(X, X) 的对角线

get_params(deep=True)[source]#

获取此核函数的参数。

参数:
deepbool, default=True(布尔值,默认为 True)

如果为 True,将返回此估计器及其包含的子对象(如果它们是估计器)的参数。

返回:
paramsdict(字典)

参数名称映射到其值。

property hyperparameters#

返回所有超参数的列表。

is_stationary()[source]#

返回核函数是否是平稳的。

property n_dims#

返回核函数的非固定超参数的数量。

property requires_vector_input#

返回核函数是否定义在离散结构上。

set_params(**params)[source]#

设置此核函数的参数。

该方法适用于简单核函数和嵌套核函数。后者具有 <component>__<parameter> 形式的参数,以便可以更新嵌套对象的每个组件。

返回:
自身
property theta#

返回(展平的、对数变换的)非固定超参数。

请注意,theta 通常是核函数超参数的对数变换值,因为这种搜索空间表示更适合超参数搜索,因为诸如长度尺度之类的超参数自然存在于对数尺度上。

返回:
thetandarray of shape (n_dims,)(形状为 (n_dims,) 的 ndarray)

核函数的非固定、对数变换超参数