In [1]:
import yellowbrick as yb
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (12, 8)
from yellowbrick.features.rankd import Rank2D
from yellowbrick.features.radviz import RadViz
from yellowbrick.features.pcoords import ParallelCoordinates
from yellowbrick.features.scatter import ScatterViz
In [2]:
import pandas as pd
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
col_names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species']
iris = pd.read_csv(url, header=None, names=col_names)
iris['species_num'] = iris.species.map({'Iris-setosa':0, 'Iris-versicolor':1, 'Iris-virginica':2})
In [3]:
all_features = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species_num']
features = ['petal_length', 'sepal_width']
classes = ['Iris-setosa', 'Iris-versicolor', 'Iris-virginica']
# Extract the numpy arrays from the data frame
X = iris[all_features]
y = iris.species_num.as_matrix()
In [17]:
from yellowbrick.style import palettes
from matplotlib.colors import Colormap
In [21]:
colors = palettes.PALETTES['pastel']
In [22]:
visualizer = ScatterViz(classes=classes, features=features, color=colors)
visualizer.fit(X, y) # Fit the data to the visualizer
visualizer.show() # Draw/show/show the data
In [7]:
visualizer.colormap
Out[7]:
In [ ]: