2012-02-18 00:58:46 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
=========================================================
|
|
|
|
|
The Iris Dataset
|
|
|
|
|
=========================================================
|
|
|
|
|
This data sets consists of 3 different types of irises'
|
|
|
|
|
(Setosa, Versicolour, and Virginica) petal and sepal
|
|
|
|
|
length, stored in a 150x4 numpy.ndarray
|
|
|
|
|
|
|
|
|
|
The rows being the samples and the columns being:
|
|
|
|
|
Sepal Length, Sepal Width, Petal Length and Petal Width.
|
|
|
|
|
|
|
|
|
|
The below plot uses the first two features.
|
2012-04-28 18:04:36 +08:00
|
|
|
See `here <http://en.wikipedia.org/wiki/Iris_flower_data_set>`_ for more
|
|
|
|
|
information on this dataset.
|
2012-02-18 00:58:46 +08:00
|
|
|
"""
|
|
|
|
|
print __doc__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Code source: Gael Varoqueux
|
|
|
|
|
# Modified for Documentation merge by Jaques Grobler
|
|
|
|
|
# License: BSD
|
|
|
|
|
|
|
|
|
|
import pylab as pl
|
2012-04-28 18:04:36 +08:00
|
|
|
from sklearn import datasets
|
2012-02-18 00:58:46 +08:00
|
|
|
|
|
|
|
|
# import some data to play with
|
|
|
|
|
iris = datasets.load_iris()
|
2012-04-28 18:04:36 +08:00
|
|
|
X = iris.data[:, :2] # we only take the first two features.
|
2012-02-18 00:58:46 +08:00
|
|
|
Y = iris.target
|
|
|
|
|
|
2012-04-28 18:04:36 +08:00
|
|
|
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
|
|
|
|
|
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
|
2012-02-18 00:58:46 +08:00
|
|
|
|
|
|
|
|
pl.figure(1, figsize=(4, 3))
|
|
|
|
|
pl.clf()
|
|
|
|
|
|
|
|
|
|
# Plot also the training points
|
2012-05-06 02:24:55 +08:00
|
|
|
pl.scatter(X[:, 0], X[:, 1], c=Y, cm=pl.cm.Paired)
|
2012-02-18 00:58:46 +08:00
|
|
|
pl.xlabel('Sepal length')
|
|
|
|
|
pl.ylabel('Sepal width')
|
|
|
|
|
|
|
|
|
|
pl.xlim(x_min, x_max)
|
|
|
|
|
pl.ylim(y_min, y_max)
|
|
|
|
|
pl.xticks(())
|
|
|
|
|
pl.yticks(())
|
|
|
|
|
|
|
|
|
|
pl.show()
|