Module Expr Str Print NameLoad Import alias identifier Import alias identifier ImportFrom alias alias Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Slice Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore Num Assign NameStore Num Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr keyword Str keyword NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr keyword Str keyword Num keyword NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr keyword Str keyword Num keyword NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr keyword NameLoad attr NameLoad NameLoad Assign TupleStore NameStore NameStore TupleLoad BinOpSub Call AttributeLoad SubscriptLoad NameLoad ExtSlice Slice Index Num attr Num BinOpAdd Call AttributeLoad SubscriptLoad NameLoad ExtSlice Slice Index Num attr Num Assign TupleStore NameStore NameStore TupleLoad BinOpSub Call AttributeLoad SubscriptLoad NameLoad ExtSlice Slice Index Num attr Num BinOpAdd Call AttributeLoad SubscriptLoad NameLoad ExtSlice Slice Index Num attr Num Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore ListLoad Str Str Str Str For TupleStore NameStore NameStore Call NameLoad TupleLoad NameLoad NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Num Num BinOpAdd NameLoad Num Expr Call AttributeLoad NameLoad attr keyword Num keyword Num Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Num Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num SubscriptLoad NameLoad ExtSlice Slice Index Num keyword NameLoad keyword AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr TupleLoad Expr Call AttributeLoad NameLoad attr TupleLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad NameLoad attr
N/A N/A 
==================================================
Plot different SVM classifiers in the iris dataset
==================================================

Comparison of different linear SVM classifiers on a 2D projection of the iris
dataset. We only consider the first 2 features of this dataset:

- Sepal length
- Sepal width

This example shows how to plot the decision surface for four SVM classifiers
with different kernels.

The linear models ``LinearSVC()`` and ``SVC(kernel='linear')`` yield slightly
different decision boundaries. This can be a consequence of the following
differences:

- ``LinearSVC`` minimizes the squared hinge loss while ``SVC`` minimizes the
  regular hinge loss.

- ``LinearSVC`` uses the One-vs-All (also known as One-vs-Rest) multiclass
  reduction while ``SVC`` uses the One-vs-One multiclass reduction.

Both linear models have linear decision boundaries (intersecting hyperplanes)
while the non-linear kernel models (polynomial or Gaussian RBF) have more
flexible non-linear decision boundaries with shapes that depend on the kind of
kernel and its parameters.

.. NOTE:: while plotting the decision function of classifiers for toy 2D
   datasets can help get an intuitive understanding of their respective
   expressive power, be aware that those intuitions don't always generalize to
   more realistic high-dimensional problems.

 N/A __doc__ N/A numpy np N/A matplotlib.pyplot plt sklearn svm datasets N/A iris N/A N/A datasets load_iris N/A X N/A N/A iris data N/A N/A N/A 2 N/A y N/A iris target N/A h 0.02 N/A C 1.0 N/A svc N/A N/A N/A N/A svm SVC kernel linear C C fit X y N/A rbf_svc N/A N/A N/A N/A svm SVC kernel rbf gamma 0.7 C C fit X y N/A poly_svc N/A N/A N/A N/A svm SVC kernel poly degree 3 C C fit X y N/A lin_svc N/A N/A N/A N/A svm LinearSVC C C fit X y N/A N/A x_min x_max N/A N/A N/A N/A N/A X N/A N/A N/A 0 min 1 N/A N/A N/A N/A X N/A N/A N/A 0 max 1 N/A N/A y_min y_max N/A N/A N/A N/A N/A X N/A N/A N/A 1 min 1 N/A N/A N/A N/A X N/A N/A N/A 1 max 1 N/A N/A xx yy N/A N/A np meshgrid N/A N/A np arange x_min x_max h N/A N/A np arange y_min y_max h N/A titles N/A SVC with linear kernel LinearSVC (linear kernel) SVC with RBF kernel SVC with polynomial (degree 3) kernel N/A N/A i clf N/A enumerate N/A svc lin_svc rbf_svc poly_svc N/A N/A N/A N/A plt subplot 2 2 N/A i 1 N/A N/A N/A plt subplots_adjust wspace 0.4 hspace 0.4 N/A Z N/A N/A clf predict N/A N/A np c_ N/A N/A N/A N/A xx ravel N/A N/A yy ravel N/A Z N/A N/A Z reshape N/A xx shape N/A N/A N/A plt contourf xx yy Z cmap N/A N/A plt cm Paired alpha 0.8 N/A N/A N/A plt scatter N/A X N/A N/A N/A 0 N/A X N/A N/A N/A 1 c y cmap N/A N/A plt cm Paired N/A N/A N/A plt xlabel Sepal length N/A N/A N/A plt ylabel Sepal width N/A N/A N/A plt xlim N/A N/A xx min N/A N/A xx max N/A N/A N/A plt ylim N/A N/A yy min N/A N/A yy max N/A N/A N/A plt xticks N/A N/A N/A N/A plt yticks N/A N/A N/A N/A plt title N/A titles N/A i N/A N/A N/A plt show