8000 DOC Extended documentation of Matern kernel · scikit-learn/scikit-learn@f35506d · GitHub
[go: up one dir, main page]

Skip to content

Commit f35506d

Browse files
author
Jan Hendrik Metzen
committed
DOC Extended documentation of Matern kernel
1 parent baddcfa commit f35506d

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

doc/modules/classes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ See the :ref:`metrics` section of the user guide for further details.
861861
metrics.pairwise.pairwise_kernels
862862
metrics.pairwise.polynomial_kernel
863863
metrics.pairwise.rbf_kernel
864+
metrics.pairwise.matern_kernel
864865
metrics.pairwise_distances
865866
metrics.pairwise_distances_argmin
866867
metrics.pairwise_distances_argmin_min

doc/modules/metrics.rst

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,38 +125,59 @@ the kernel is known as the Gaussian kernel of variance :math:`\sigma^2`.
125125

126126
Matérn kernel
127127
-------------
128-
The function :func:`matern_kernel` is a generalization of the RBF kernel. It
129-
has an additional parameter :math:`\nu` which controls the smoothness of the
130-
resulting function. The general functional form of a Matérn is given by:
128+
The function :func:`matern_kernel` is a generalization of the RBF kernel. It has
129+
an additional parameter :math:`\nu` (set via the keyword coef0) which controls
130+
the smoothness of the resulting function. The general functional form of a
131+
Matérn is given by
131132

132133
.. math::
133134
134-
k(d) = \sigma^2\frac{1}{\Gamma(\nu)2^{\nu-1}}\Bigg(\sqrt{2\nu}\frac{d}{\rho}\Bigg)^\nu K_\nu\Bigg(\sqrt{2\nu}\frac{d}{\rho}\Bigg),
135+
k(d) = \sigma^2\frac{1}{\Gamma(\nu)2^{\nu-1}}\Bigg(\gamma\sqrt{2\nu} d\Bigg)^\nu K_\nu\Bigg(\gamma\sqrt{2\nu} d\Bigg),
135136
136-
where :math:`d=\| x-y \|^2` and ``x`` and ``y`` are the input vectors.
137+
where :math:`d=\| x-y \|` and ``x`` and ``y`` are the input vectors.
137138

138139
As :math:`\nu\rightarrow\infty`, the Matérn kernel converges to the RBF kernel.
139140
When :math:`\nu = 1/2`, the Matérn kernel becomes identical to the absolute
140141
exponential kernel, i.e.,
141142

142143
.. math::
143-
k(d) = \sigma^2 \exp \Bigg(-\frac{d}{\rho} \Bigg) \quad \quad \nu= \tfrac{1}{2}
144+
k(d) = \sigma^2 \exp \Bigg(-\gamma d \Bigg) \quad \quad \nu= \tfrac{1}{2}
144145
145-
See Rasmussen and Williams 2006, pp84 for further details regarding the
146-
different variants of the Matérn kernel. In particular, :math:`\nu = 3/2`:
146+
In particular, :math:`\nu = 3/2`:
147147

148148
.. math::
149-
k(d) = \sigma^2 \Bigg(1 + \frac{ \sqrt{3}d }{\rho} \Bigg) \exp \Bigg(-\frac{\sqrt{3}d}{\rho} \Bigg) \quad \quad \nu= \tfrac{3}{2}
149+
k(d) = \sigma^2 \Bigg(1 + \gamma \sqrt{3} d \Bigg) \exp \Bigg(-\gamma \sqrt{3}d \Bigg) \quad \quad \nu= \tfrac{3}{2}
150150
151151
and :math:`\nu = 5/2`:
152152

153153
.. math::
154-
k(d) = \sigma^2 \Bigg(1 + \frac{ \sqrt{5}d }{\rho} +\frac{ 5d^2}{3 \rho^2 } \Bigg) \exp \Bigg(-\frac{\sqrt{5}d}{\rho} \Bigg) \quad \quad \nu= \tfrac{5}{2}.
154+
k(d) = \sigma^2 \Bigg(1 + \gamma \sqrt{5}d +\frac{5}{3} \gamma^2d^2 \Bigg) \exp \Bigg(-\gamma \sqrt{5}d \Bigg) \quad \quad \nu= \tfrac{5}{2}
155155
156156
are popular choices for learning functions that are not infinitely
157157
differentiable (as assumed by the RBF kernel) but at least once (:math:`\nu =
158158
3/2`) or twice differentiable (:math:`\nu = 5/2`).
159159

160+
The following example illustrates how the Matérn kernel's covariance decreases
161+
with increasing dissimilarity of the two inputs for different values of coef0
162+
(the parameter :math:`\nu` of the Matérn kernel):
163+
164+
.. figure:: ../auto_examples/metrics/images/plot_matern_kernel_001.png
165+
:target: ../auto_examples/metrics/plot_matern_kernel.html
166+
:align: center
167+
168+
The flexibility of controlling the smoothness of the learned function via coef0
169+
allows adapting to the properties of the true underlying functional relation.
170+
The following example shows that support vector regression with Matérn kernel
171+
with smaller values of coef0 can better approximate a discontinuous
172+
step-function:
173+
174+
.. figure:: ../auto_examples/svm/images/plot_svm_matern_kernel_001.png
175+
:target: ../auto_examples/svm/plot_svm_matern_kernel.html
176+
:align: center
177+
178+
See Rasmussen and Williams 2006, pp84 for further details regarding the
179+
different variants of the Matérn kernel.
180+
160181

161182
Chi-squared kernel
162183
------------------
@@ -207,3 +228,8 @@ The chi squared kernel is most commonly used on histograms (bags) of visual word
207228
International Journal of Computer Vision 2007
208229
http://eprints.pascal-network.org/archive/00002309/01/Zhang06-IJCV.pdf
209230

231+
* Rasmussen, C. E. and Williams, C.
232+
Gaussian Processes for Machine Learning
233+
The MIT Press, 2006
234+
http://www.gaussianprocess.org/gpml/chapters/
235+

doc/whats_new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ New features
5858
- Added :func:`metrics.median_absolute_error`, a robust metric.
5959
By `Gael Varoquaux`_ and `Florian Wilhelm`_.
6060

61+
- Added :func:`metrics.pairwise.matern_kernel`, a kernel where the
62+
smoothness of the learned function can be controlled.
63+
By `Jan Hendrik Metzen`_.
64+
6165

6266
Enhancements
6367
............
@@ -3110,3 +3114,5 @@ David Huard, Dave Morrill, Ed Schofield, Travis Oliphant, Pearu Peterson.
31103114
.. _Matt Terry: https://github.com/mrterry
31113115

31123116
.. _Antony Lee: https://www.ocf.berkeley.edu/~antonyl/
3117+
3118+
.. _Jan Hendrik Metzen: https://jmetzen.github.io/

sklearn/metrics/pairwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def matern_kernel(X, Y=None, gamma=None, coef0=1.5):
774774
775775
gamma : float
776776
777-
coef0 : float in [0.5, 1.5, 2.5, inf]
777+
coef0 : float>0.0 (the parameter nu)
778778
779779
Returns
780780
-------

0 commit comments

Comments
 (0)
0