sklearn.gaussian_process.Exponentiation?

class sklearn.gaussian_process.kernels.Exponentiation(kernel, exponent)

[源碼]

取冪核接受一個基核和一個標量參數,并通過

請注意,剩余的__pow__魔法方法被覆蓋了,因此求冪Exponentiation(RBF(), 2)使用 ** operator with RBF() ** 2.

用戶指南中閱讀更多內容。

新版本0.18。

參數 說明
kernel Kernel
的基本內核
exponent float
基核的指數
屬性 說明
bounds 返回的對數變換界限。
hyperparameters 返回所有超參數規范的列表。
n_dims 返回內核的非固定超參數的數量。
requires_vector_input 返回內核是否定義在離散結構上。
theta 返回(扁平的、對數轉換的)非固定超參數。

示例

>>> 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__(self, X[, Y, eval_gradient]) 返回核函數k(X, Y)和它的梯度。
clone_with_theta(self, theta) 返回帶有給定超參數theta的self的克隆。
diag(self, X) 返回核函數k(X, X)的對角線。
get_params(self[, deep]) 獲取這個內核的參數。
is_stationary(self) 返回內核是否靜止。
set_params(self, **params) 設置這個內核的參數。
__init__(self, kernel, exponent)

[源碼]

初始化self. See 請參閱help(type(self))以獲得準確的說明 。

__call__(self, X, Y=None, eval_gradient=False)

[源碼]

返回核函數k(X, Y)和它的梯度。

參數 說明
X array-like of shape (n_samples_X, n_features) or list of object
返回核函數k(X, Y)的左參數
Y array-like of shape (n_samples_Y, n_features) or list of object, default=None
返回的核函數k(X, Y)的正確參數。如果沒有,則計算k(X, X)。
eval_gradient bool, default=False
確定關于核超參數的梯度是否確定。只有當Y沒有的時候才被支持。
返回值 說明
K ndarray of shape (n_samples_X, n_samples_Y)
內核k (X, Y)
K_gradient ndarray of shape (n_samples_X, n_samples_X, n_dims), optional
核函數k(X, X)關于核函數超參數的梯度。只有當eval_gradient為真時才返回。
property bounds

[源碼]

返回的對數變換界限。

返回值 說明
bounds ndarray of shape (n_dims, 2)
核函數超參數的對數變換界限
clone_with_theta(self, theta)

[源碼]

返回帶有給定超參數theta的self的克隆。

返回值 說明
theta ndarray of shape (n_dims,)
的hyperparameters
diag(self, X)

[源碼]

返回核函數k(X, X)的對角線。

該方法的結果與np.diag(self(X))相同;但是,由于只計算對角,因此可以更有效地計算它。

參數 說明
X array-like of shape (n_samples_X, n_features) or list of object
參數指向內核。
返回值 說明
K_diag ndarray of shape (n_samples_X,)
核k(X, X)的對角線
get_params(self, deep=True)

[源碼]

獲取這個內核的參數。

參數 說明
deep bool, default=True
如果為真,將返回此估計器的參數以及包含的作為估計器的子對象。
返回值 說明
params dict
參數名稱映射到它們的值。
property hyperparameters

[源碼]

返回所有超參數的列表。

is_stationary(self)

[源碼]

返回內核是否靜止。

property n_dims

返回內核的非固定超參數的數量。

property requires_vector_input

返回內核是否定義在離散結構上。

set_params(self, **params)

[源碼]

設置這個內核的參數。

該方法適用于簡單估計量和嵌套對象(如pipline)。后者具有形式為<component>_<parameter>的參數,這樣就讓更新嵌套對象的每個組件成為了可能。

返回值 說明
self -
property theta

返回(扁平的、對數轉換的)非固定超參數。

注意,theta通常是內核超參數的對數變換值,因為這種搜索空間的表示更適合超參數搜索,因為像長度尺度這樣的超參數自然存在于對數尺度上。

返回值 說明
theta ndarray of shape (n_dims,)
核函數的非固定、對數變換超參數