From 2eceb2360dceb5d00009e22bacd2f56bbc9972ed Mon Sep 17 00:00:00 2001 From: hiramatsuyuusuke <140389350+hiramatsuyuusuke@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:06:21 +0900 Subject: [PATCH 1/2] Update svm.rst --- doc/modules/svm.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/modules/svm.rst b/doc/modules/svm.rst index 7e886366aebae..79fbe77380695 100644 --- a/doc/modules/svm.rst +++ b/doc/modules/svm.rst @@ -511,9 +511,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. @@ -530,7 +529,7 @@ classifiers, except that: Using Python functions as kernels -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +--------------------------------- You can use your own defined kernels by passing a function to the ``kernel`` parameter. @@ -548,13 +547,16 @@ instance that will use that kernel:: ... return np.dot(X, Y.T) ... >>> clf = svm.SVC(kernel=my_kernel) + + .. 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 From 2f915e4fe89bdd8227cbf71556b7ebc2782ce13e Mon Sep 17 00:00:00 2001 From: hiramatsuyuusuke <140389350+hiramatsuyuusuke@users.noreply.github.com> Date: Sat, 19 Aug 2023 01:11:17 +0900 Subject: [PATCH 2/2] Update svm.rst --- doc/modules/svm.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/modules/svm.rst b/doc/modules/svm.rst index 60a195649e557..8f97b8dee8806 100644 --- a/doc/modules/svm.rst +++ b/doc/modules/svm.rst @@ -538,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,12 +559,9 @@ instance that will use that kernel:: ... >>> clf = svm.SVC(kernel=my_kernel) +|details-end| -.. topic:: Examples: - - * :ref:`sphx_glr_auto_examples_svm_plot_custom_kernel.py`. - |details-start| **Using the Gram matrix** |details-split| @@ -591,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