sklearn.gaussian_process.PairwiseKernel?

class sklearn.gaussian_process.kernels.PairwiseKernel(gamma=1.0, gamma_bounds=(1e-05, 100000.0), metric='linear', pairwise_kernels_kwargs=None)

用sklearn.metrics.pairwise來包裝.

在sklearn.metrics.pairwise.中,一個輕量級的包裝將內核的功能包裹起來。

注:eval_gradient的評分不是解析的,而是數值的內核只支持各向同性距離。參數gamma被認為是一個超參數,可以被優化。其他內核參數在初始化時直接設置并保持固定。

新版本0.18。

參數 說明
gamma float, default=1.0
由度規指定的成對核的參數gamma。它應該是正的。
gamma_bounds pair of floats >= 0 or “fixed”, default=(1e-5, 1e5)
gamma的上下限。如果設置為“固定”,則在超參數調優期間無法更改“gamma”。
metric {“linear”, “additive_chi2”, “chi2”, “poly”, “polynomial”, “rbf”, “laplacian”, “sigmoid”, “cosine”} or callable, default=”linear”
在計算特性數組中的實例之間的內核時要使用的度量。如果metric是一個字符串,那么它必須是PAIRWISE_KERNEL_FUNCTIONS中的一個指標。如果度量是“預先計算”的,則假設X是一個核矩陣。另外,如果metric是一個可調用的函數,那么它將在每對實例(行)和記錄的結果值上調用。可調用函數應該從X獲取兩個數組作為輸入,并返回一個值,指示它們之間的距離。
pairwise_kernels_kwargs dict, default=None
這個dict的所有條目(如果有的話)都作為關鍵字參數傳遞給兩兩的內核函數。
屬性 說明
bounds 返回的對數變換界限。
hyperparameters 返回所有超參數規范的列表。
n_dims 返回內核的非固定超參數的數量。
requires_vector_input 返回內核是否定義在離散結構上。
theta 返回(扁平的、對數轉換的)非固定超參數。

方法

方法 說明
__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, gamma=1.0, gamma_bounds=(1e-05100000.0), metric='linear', pairwise_kernels_kwargs=None)

[源碼]

初始化self.請參閱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 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,)
核函數的非固定、對數變換超參數