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]:
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]:
In [272]:
h2
Out[272]:
In [273]:
xrange.shape
Out[273]:
In [274]:
yrange.shape
Out[274]:
In [275]:
xx,yy = n.meshgrid(xrange,yrange)
In [276]:
xx.ravel()
yy.ravel()
Out[276]:
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]:
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]:
In [ ]:
In [ ]:
In [ ]:
#PCA - principal component analysis- hidden meanings
In [ ]: