sklearn.metrics.pairwise.chi2_kernel?

sklearn.metrics.pairwise.chi2_kernel(X, Y=None, gamma=1.0)

源碼

計算指數卡方內核X和Y。

在X和Y中的每對行之間計算卡方核。X和Y必須為非負數。該內核通常應用于直方圖。

卡方內核由下式給出:

k(x, y) = exp(-gamma Sum [(x - y)^2 / (x + y)])

可以解釋為每個條目的加權差。

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

參數 說明
X array-like of shape (n_samples_X, n_features)
Y array of shape (n_samples_Y, n_features)
gamma float, default=1.
chi2內核的縮放參數。
返回值 說明
kernel_matrix array of shape (n_samples_X, n_samples_Y)

另見:

additive_chi2_kernel

此內核的附加版本

sklearn.kernel_approximation.AdditiveChi2Sampler

此內核的加法版本的傅立葉近似。

參考

Zhang, J. and Marszalek, M. and Lazebnik, S. and Schmid, C. Local features and kernels for classification of texture and object categories: A comprehensive study International Journal of Computer Vision 2007 https://research.microsoft.com/en-us/um/people/manik/projects/trade-off/papers/ZhangIJCV06.pdf