

.. _example_svm_plot_rbf_parameters.py:


==================
RBF SVM parameters
==================

This example illustrates the effect of the parameters `gamma`
and `C` of the rbf kernel SVM.

Intuitively, the `gamma` parameter defines how far the influence
of a single training example reaches, with low values meaning 'far'
and high values meaning 'close'.
The `C` parameter trades off misclassification of training examples
against simplicity of the decision surface. A low C makes
the decision surface smooth, while a high C aims at classifying
all training examples correctly.

Two plots are generated.  The first is a visualization of the
decision function for a variety of parameter values, and the second
is a heatmap of the classifier's cross-validation accuracy as
a function of `C` and `gamma`.



.. rst-class:: horizontal


    *

      .. image:: images/plot_rbf_parameters_1.png
            :scale: 47

    *

      .. image:: images/plot_rbf_parameters_2.png
            :scale: 47


**Script output**::

  ('The best classifier is: ', SVC(C=1000000.0, cache_size=200, class_weight=None, coef0=0.0, degree=3,
    gamma=0.0001, kernel='rbf', max_iter=-1, probability=False,
    shrinking=True, tol=0.001, verbose=False))



**Python source code:** :download:`plot_rbf_parameters.py <plot_rbf_parameters.py>`

.. literalinclude:: plot_rbf_parameters.py
    :lines: 22-

**Total running time of the example:**  3.14 seconds
    