diff --git a/doc/modules/svm.rst b/doc/modules/svm.rst index 0ac34cdcb6a10..8f97b8dee8806 100644 --- a/doc/modules/svm.rst +++ b/doc/modules/svm.rst @@ -521,9 +521,8 @@ is advised to use :class:`~sklearn.model_selection.GridSearchCV` with * :ref:`sphx_glr_auto_examples_svm_plot_rbf_parameters.py` * :ref:`sphx_glr_auto_examples_svm_plot_svm_nonlinear.py` -|details-start| -**Custom Kernels** -|details-split| +Custom Kernels +-------------- You can define your own kernels by either giving the kernel as a python function or by precomputing the Gram matrix. @@ -539,8 +538,9 @@ classifiers, except that: use of ``fit()`` and ``predict()`` you will have unexpected results. -Using Python functions as kernels -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +|details-start| +**Using Python functions as kernels** +|details-split| You can use your own defined kernels by passing a function to the ``kernel`` parameter. @@ -558,13 +558,13 @@ instance that will use that kernel:: ... return np.dot(X, Y.T) ... >>> clf = svm.SVC(kernel=my_kernel) + +|details-end| -.. topic:: Examples: - - * :ref:`sphx_glr_auto_examples_svm_plot_custom_kernel.py`. -Using the Gram matrix -~~~~~~~~~~~~~~~~~~~~~ +|details-start| +**Using the Gram matrix** +|details-split| You can pass pre-computed kernels by using the ``kernel='precomputed'`` option. You should then pass Gram matrix instead of X to the `fit` and @@ -589,6 +589,10 @@ test vectors must be provided: |details-end| +.. topic:: Examples: + + * :ref:`sphx_glr_auto_examples_svm_plot_custom_kernel.py`. + .. _svm_mathematical_formulation: Mathematical formulation