FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
BuildingMachineLearningSystemsWithPython/ch02/figure1.py at master · luispedro/BuildingMachineLearningSystemsWithPython · GitHub
luispedro
/
BuildingMachineLearningSystemsWithPython
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
2.1k
Code
Issues
1
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
BuildingMachineLearningSystemsWithPython
/
ch02
/
figure1.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (36 loc) · 1.17 KB
Breadcrumbs
BuildingMachineLearningSystemsWithPython
/
ch02
/
figure1.py
Copy path
File metadata and controls
42 lines (36 loc) · 1.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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
from
matplotlib
import
pyplot
as
plt
# We load the data with load_iris from sklearn
from
sklearn
.
datasets
import
load_iris
# load_iris returns an object with several fields
data
=
load_iris
()
features
=
data
.
data
feature_names
=
data
.
feature_names
target
=
data
.
target
target_names
=
data
.
target_names
fig
,
axes
=
plt
.
subplots
(
2
,
3
)
pairs
=
[(
0
,
1
), (
0
,
2
), (
0
,
3
), (
1
,
2
), (
1
,
3
), (
2
,
3
)]
# Set up 3 different pairs of (color, marker)
color_markers
=
[
(
'r'
,
'>'
),
(
'g'
,
'o'
),
(
'b'
,
'x'
),
]
for
i
, (
p0
,
p1
)
in
enumerate
(
pairs
):
ax
=
axes
.
flat
[
i
]
for
t
in
range
(
3
):
# Use a different color/marker for each class `t`
c
,
marker
=
color_markers
[
t
]
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
.
tight_layout
()
fig
.
savefig
(
'figure1.png'
)
Back
|
FazBrowse Home
|
New Git URL