-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigure1.py
More file actions
29 lines (25 loc) · 878 Bytes
/
figure1.py
File metadata and controls
29 lines (25 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This code is supporting material for the book
# Building Machine Learning Systems with Python
# by Willi Richert and Luis Pedro Coelho
# published by PACKT Publishing
#
# It is made available under the MIT License
import numpy as np
from sklearn.datasets import load_iris
from matplotlib import pyplot as plt
data = load_iris()
features = data['data']
feature_names = data['feature_names']
target = data['target']
fig,axes = plt.subplots(2, 3)
pairs = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]
for i, (p0, p1) in enumerate(pairs):
ax = axes.flat[i]
for t, marker, c in zip(range(3), ">ox", "rgb"):
ax.scatter(features[target == t, p0], features[
target == t, p1], marker=marker, c=c)
ax.set_xlabel(feature_names[p0])
ax.set_ylabel(feature_names[p1])
ax.set_xticks([])
ax.set_yticks([])
fig.savefig('figure1.png')