核#
- class sklearn.gaussian_process.kernels.Kernel[source]#
- 所有核的基类。 - 版本0.18中添加。 - 示例 - >>> from sklearn.gaussian_process.kernels import Kernel, RBF >>> import numpy as np >>> class CustomKernel(Kernel): ... def __init__(self, length_scale=1.0): ... self.length_scale = length_scale ... def __call__(self, X, Y=None): ... if Y is None: ... Y = X ... return np.inner(X, X if Y is None else Y) ** 2 ... def diag(self, X): ... return np.ones(X.shape[0]) ... def is_stationary(self): ... return True >>> kernel = CustomKernel(length_scale=2.0) >>> X = np.array([[1, 2], [3, 4]]) >>> print(kernel(X)) [[ 25 121] [121 625]] - property bounds#
- 返回theta的对数变换边界。 - 返回:
- bounds形状为(n_dims, 2)的ndarray
- 核的超参数theta的对数变换边界 
 
 
 - 抽象 diag(X)[源代码]#
- 返回核函数 k(X, X) 的对角线。 - 此方法的结果与 np.diag(self(X)) 相同;但是,它可以更有效地计算,因为只计算对角线。 - 参数:
- X形状为 (n_samples,) 的类数组
- 返回的核函数 k(X, Y) 的左参数 
 
- 返回:
- K_diag形状为 (n_samples_X,) 的ndarray
- 核函数 k(X, X) 的对角线 
 
 
 - get_params(deep=True)[源代码]#
- 获取此内核的参数。 - 参数:
- deep布尔值,默认为 True
- 如果为 True,则将返回此估计器及其包含的作为估计器的子对象的参数。 
 
- 返回:
- params字典
- 参数名称与其值的映射。 
 
 
 - 属性 hyperparameters#
- 返回所有超参数规范的列表。 
 - 属性 n_dims#
- 返回内核的非固定超参数的数量。 
 - 属性 requires_vector_input#
- 返回内核是定义在固定长度特征向量上还是通用对象上。为向后兼容性,默认为 True。 
 - set_params(**params)[源代码]#
- 设置此内核的参数。 - 此方法适用于简单的内核以及嵌套内核。后者具有 - <component>__<parameter>形式的参数,因此可以更新嵌套对象的每个组件。- 返回:
- 自身
 
 
 - 属性 theta#
- 返回(扁平化,对数转换)的非固定超参数。 - 请注意,theta 通常是内核超参数的对数转换值,因为搜索空间的这种表示形式更适合超参数搜索,因为像长度尺度这样的超参数自然地存在于对数尺度上。 - 返回:
- theta形状为 (n_dims,) 的ndarray
- 内核的非固定,对数转换的超参数 
 
 
 
 
    