sklearn.gaussian_process.ExpSineSquared?

class sklearn.gaussian_process.kernels.ExpSineSquared(length_scale=1.0, periodicity=1.0, length_scale_bounds=(1e-05100000.0), periodicity_bounds=(1e-05100000.0))

[源碼]

sin平方核函數(又稱周期核函數)

ExpSineSquared內核允許對完全重復的函數建模。它由一個長度尺度參數和一個周期參數來參數化。目前只支持標量的各向同性變量。核函數為:

其中是核的長度尺度,核的周期性,是歐氏距離。

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

新版本0.18。

參數 說明
length_scale float >= 0, default=1.0
核的長度尺度。
periodicity float > 0, default=1.0
核函數的周期性。
length_scale_bounds pair of floats >= 0 or “fixed”, default=(1e-5, 1e5)
length_scale上的下界和上界。如果設置為“固定”,則“length_scale”在超參數調優期間無法更改。
periodicity_bounds pair of floats >= 0 or “fixed”, default=(1e-5, 1e5)
“周期性”的下界和上界。如果設置為“固定”,“periodicity”在超參數調優期間無法改變。
屬性 說明
bounds 返回的對數變換界限。
hyperparameter_constant_value
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 ExpSineSquared
>>> X, y = make_friedman2(n_samples=50, noise=0, random_state=0)
>>> kernel = ExpSineSquared(length_scale=1, periodicity=1)
>>> gpr = GaussianProcessRegressor(kernel=kernel, alpha=5,
...         random_state=0).fit(X, y)
>>> gpr.score(X, y)
0.0144...
>>> gpr.predict(X[:2,:], return_std=True)
(array([425.6..., 457.5...]), array([0.3894..., 0.3467...]))

方法

方法 說明
__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, length_scale=1.0, periodicity=1.0, length_scale_bounds=(1e-05100000.0), periodicity_bounds=(1e-05100000.0))[source]

[源碼]

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

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

[源碼]

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

參數 說明
X ndarray of shape (n_samples_X, n_features)
返回核函數k(X, Y)的左參數
Y ndarray of shape (n_samples_Y, n_features), 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 ndarray of shape (n_samples_X, n_features)
返回的核函數k(X, Y)的左參數。
返回值 說明
K_diag ndarray of shape (n_samples_X,)
核k(X, X)的對角線
get_params(self, deep=True)

[源碼]

獲取這個內核的參數。

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

返回長度比例

property hyperparameters

返回所有超參數規范的列表。

is_stationary(self)

[源碼]

返回內核是否靜止。

property n_dims

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

property requires_vector_input

返回內核是在固定長度的特征向量上定義的還是在通用對象上定義的。向后兼容性的默認值為True。

set_params(self, **params)

[源碼]

設置這個內核的參數。

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

返回值 說明
self -
property theta

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

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

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

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