In [70]:
import pandas as p
from sklearn import datasets,metrics,svm,cross_validation
import numpy as n
import matplotlib.pyplot as pl
from matplotlib.colors import ListedColormap

In [8]:
iris1 = datasets.load_iris()

In [10]:
irisd = iris1.data[:,:2]
irist = iris.target

In [ ]:


In [ ]:


In [13]:
#x_train,x_test,y_train,y_test = cross_validation.train_test_split(iris.data,iris.target,test_size = 0.2)

In [264]:
e = svm.SVC(kernel = 'rbf',C = 1000000, gamma = 0.1)

In [265]:
e.fit(irisd,irist)


Out[265]:
SVC(C=1000000, cache_size=200, class_weight=None, coef0=0.0,
  decision_function_shape=None, degree=3, gamma=0.1, kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)

In [266]:
x_min = irisd[:,0].min() - 1

In [267]:
y_min = irisd[:,1].min() - 1

In [268]:
x_max = irisd[:,0].max() + 1

In [269]:
y_max = irisd[:,1].max() + 1

In [270]:
h = (x_max - x_min)/100
xrange = n.arange(x_min,x_max,h)
h = (y_max - y_min)/100
yrange = n.arange(y_min,y_max,h)

In [271]:
h1


Out[271]:
0.056000000000000008

In [272]:
h2


Out[272]:
0.044000000000000004

In [273]:
xrange.shape


Out[273]:
(100,)

In [274]:
yrange.shape


Out[274]:
(100,)

In [275]:
xx,yy = n.meshgrid(xrange,yrange)

In [276]:
xx.ravel()
yy.ravel()


Out[276]:
array([ 1.   ,  1.   ,  1.   , ...,  5.356,  5.356,  5.356])

In [277]:
q = n.c_[xx.ravel(),yy.ravel()]

In [278]:
pred = e.predict(q)

In [279]:
%matplotlib inline

In [280]:
pred = pred.reshape(xx.shape)

In [281]:
#pl.figure()
cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#AAAAFF'])
cmap_bold = ListedColormap(['#FF0000', '#00FF00', '#0000FF'])

In [ ]:


In [282]:
pl.figure()


Out[282]:
<matplotlib.figure.Figure at 0x263ec8f86a0>
<matplotlib.figure.Figure at 0x263ec8f86a0>

In [ ]:


In [283]:
#l.contour(xx,yy,pred)
pl.pcolormesh(xx, yy, pred, cmap=cmap_light, shading = 'gouraud',edgecolor='face') 
pl.scatter(irisd[:,0],irisd[:,1],c = irist,cmap=cmap_bold)


Out[283]:
<matplotlib.collections.PathCollection at 0x263ec969c50>

In [ ]:


In [ ]:


In [ ]:
#PCA - principal component analysis- hidden meanings

In [ ]: