-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo9.py
36 lines (35 loc) · 1.01 KB
/
demo9.py
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
import matplotlib.pyplot as plt
from sklearn import datasets
import numpy as np
iris = datasets.load_iris()
print(type(iris), iris.keys())
print(type(iris.data))
print(type(iris.target))
print(type(iris.target_names), iris.target_names)
print(iris.feature_names)
labels = iris.feature_names
data = iris.data
target = iris.target
print(data[:10])
print(target[:10])
print(np.unique(iris.target_names))
print(np.mean(data, axis=0))
# print(np.mean(data, axis=1))
counter = 1
for i in range(4):
for j in range(i + 1, 4):
plt.figure(counter, figsize=(8, 6))
counter += 1
xData = data[:, i]
yData = data[:, j]
x_min, x_max = xData.min()-0.5, xData.max()+0.5
y_min, y_max = yData.min()-0.5, yData.max()+0.5
plt.clf()
plt.scatter(xData, yData, c=target, marker='.', cmap=plt.cm.Paired)
plt.xlabel(labels[i])
plt.ylabel(labels[j])
plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
plt.xticks(())
plt.yticks(())
plt.show()