Skip to content
Snippets Groups Projects
Select Git revision
  • 690aaf1d1f05c01c542c03818a89faf214198ef4
  • master default protected
  • 0.19.X
  • discrete
  • 0.18.X
  • ignore_lambda_to_diff_errors
  • 0.17.X
  • authors-update
  • 0.16.X
  • 0.15.X
  • 0.14.X
  • debian
  • 0.13.X
  • 0.12.X
  • 0.11.X
  • 0.10.X
  • 0.9.X
  • 0.6.X
  • 0.7.X
  • 0.8.X
  • 0.19.1
  • 0.19.0
  • 0.19b2
  • 0.19b1
  • 0.19-branching
  • 0.18.2
  • 0.18.1
  • 0.18
  • 0.18rc2
  • 0.18rc1
  • 0.18rc
  • 0.17.1-1
  • 0.17.1
  • debian/0.17.0-4
  • debian/0.17.0-3
  • debian/0.17.0-1
  • 0.17
  • debian/0.17.0_b1+git14-g4e6829c-1
  • debian/0.17.0_b1-1
  • 0.17b1
40 results

setup.py

Blame
  • plot_svm_nonlinear.py 709 B
    """
    ==============
    Non-linear SVM
    ==============
    
    Perform binary classification using non-linear SVC
    with RBF kernel. The target to predict is a XOR of the
    inputs.
    
    """
    print __doc__
    
    import numpy as np
    import pylab as pl
    from scikits.learn import svm
    
    xx, yy = np.meshgrid(np.linspace(-5, 5, 500), np.linspace(-5, 5, 500))
    np.random.seed(0)
    X = np.random.randn(300, 2)
    Y = np.logical_xor(X[:,0]>0, X[:,1]>0)
    
    # fit the model
    clf = svm.NuSVC()
    clf.fit(X, Y)
    
    # plot the line, the points, and the nearest vectors to the plane
    Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
    Z = Z.reshape(xx.shape)
    
    pl.set_cmap(pl.cm.Paired)
    pl.pcolormesh(xx, yy, Z)
    pl.scatter(X[:,0], X[:,1], c=Y)
    
    pl.axis('tight')
    pl.show()