CompoundKernel#
- class sklearn.gaussian_process.kernels.CompoundKernel(kernels)[source]#
由一组其他核组成的核。
版本 0.18 新增。
- 参数:
- kernelslist of Kernels
The other kernels
示例
>>> from sklearn.gaussian_process.kernels import WhiteKernel >>> from sklearn.gaussian_process.kernels import RBF >>> from sklearn.gaussian_process.kernels import CompoundKernel >>> kernel = CompoundKernel( ... [WhiteKernel(noise_level=3.0), RBF(length_scale=2.0)]) >>> print(kernel.bounds) [[-11.51292546 11.51292546] [-11.51292546 11.51292546]] >>> print(kernel.n_dims) 2 >>> print(kernel.theta) [1.09861229 0.69314718]
- __call__(X, Y=None, eval_gradient=False)[source]#
返回核 k(X, Y) 及其可选的梯度。
Note that this compound kernel returns the results of all simple kernel stacked along an additional axis.
- 参数:
- Xarray-like of shape (n_samples_X, n_features) or list of object, default=None
返回的核 k(X, Y) 的左参数
- Yarray-like of shape (n_samples_X, n_features) or list of object, default=None
返回核 k(X, Y) 的右参数。如果为 None,则计算 k(X, X)。
- eval_gradientbool, default=False
确定是否计算关于核超参数对数的梯度。
- 返回:
- Kndarray of shape (n_samples_X, n_samples_Y, n_kernels)
核 k(X, Y)
- K_gradientndarray of shape (n_samples_X, n_samples_X, n_dims, n_kernels), optional
核 k(X, X) 关于核超参数对数的梯度。仅当
eval_gradient为 True 时返回。
- property bounds#
返回 theta 的对数变换边界。
- 返回:
- boundsarray of shape (n_dims, 2)
核超参数 theta 的对数变换边界
- diag(X)[source]#
返回核 k(X, X) 的对角线。
The result of this method is identical to
np.diag(self(X)); however, it can be evaluated more efficiently since only the diagonal is evaluated.- 参数:
- Xarray-like of shape (n_samples_X, n_features) or list of object
核的参数。
- 返回:
- K_diagndarray of shape (n_samples_X, n_kernels)
核 k(X, X) 的对角线
- get_params(deep=True)[source]#
获取此核的参数。
- 参数:
- deepbool, default=True
如果为 True,将返回此估计器以及包含的子对象(如果它们是估计器)的参数。
- 返回:
- paramsdict
参数名称映射到其值。
- property hyperparameters#
返回所有超参数规范的列表。
- property n_dims#
返回核的非固定超参数的数量。
- property requires_vector_input#
Returns whether the kernel is defined on discrete structures.
- set_params(**params)[source]#
设置此核的参数。
此方法适用于简单核以及嵌套核。后者具有
<component>__<parameter>形式的参数,因此可以更新嵌套对象的每个组件。- 返回:
- self
- property theta#
返回(展平的、对数变换的)非固定超参数。
请注意,theta 通常是核超参数的对数变换值,因为这种搜索空间的表示形式更适合超参数搜索,因为像长度尺度这样的超参数自然存在于对数尺度上。
- 返回:
- thetandarray of shape (n_dims,)
核的非固定、对数变换超参数