8000 DOC Documentation of parameter coef0 of matern_kernel · scikit-learn/scikit-learn@86680c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 86680c5

Browse files
author
Jan Hendrik Metzen
committed
DOC Documentation of parameter coef0 of matern_kernel
1 parent 0b035a8 commit 86680c5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sklearn/metrics/pairwise.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def matern_kernel(X, Y=None, gamma=None, coef0=1.5):
752752
The class of Matern kernels is a generalization of the RBF and
753753
absolute exponential kernel parameterized by an additional parameter
754754
coef0 (commonly denoted as nu in the literature). The smaller coef0,
755-
the less smooth the approximated function is. For nu->inf, the kernel
755+
the less smooth the approximated function is. For nu=inf, the kernel
756756
becomes equivalent to the RBF kernel and for nu=0.5 to the absolute
757757
exponential kernel. Important intermediate values are nu=1.5 (once
758758
differentiable functions) and nu=2.5 (twice differentiable functions).
@@ -769,13 +769,25 @@ def matern_kernel(X, Y=None, gamma=None, coef0=1.5):
769769
gamma : float
770770
771771
coef0 : float>0.0 (the parameter nu)
772+
The parameter nu controlling the smoothness of the learned function.
773+
The smaller coef0, the less smooth the approximated function is.
774+
For nu=inf, the kernel becomes equivalent to the RBF kernel and for
775+
nu=0.5 to the absolute exponential kernel. Important intermediate
776+
values are nu=1.5 (once differentiable functions) and nu=2.5
777+
(twice differentiable functions). Note that values of nu not in
778+
[0.5, 1.5, 2.5, inf] incur a considerably higher computational cost
779+
(appr. 10 times higher) since they require to evaluate the modified
780+
Bessel function.
781+
772782
773783
Returns
774784
-------
775785
kernel_matrix : array of shape (n_samples_X, n_samples_Y)
776786
"""
777787
if coef0 == np.inf: # fall back to rbf-kernel
778788
return rbf_kernel(X, Y, gamma)
789+
elif coef0 <= 0.0:
790+
raise ValueError("coef0 of Matérn kernel must be strictly positive.")
779791

780792
X, Y = check_pairwise_arrays(X, Y)
781793
if gamma is None:

0 commit comments

Comments
 (0)
0