-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (26 loc) · 918 Bytes
/
main.py
File metadata and controls
34 lines (26 loc) · 918 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
30
31
32
33
34
import pandas as pd
import matplotlib.pyplot as plt
import time
__path__ = 'iris/iris.data'
df = pd.read_csv(__path__, names=['sepal length', 'sepal width', 'petal length', 'petal width', 'class'])
# print(df)
X = df[['sepal length', 'sepal width', 'petal length']]. values
mapping = {
'Iris-setosa': 0,
'Iris-versicolor': 1,
'Iris-virginica': 2
}
df['class'] = df['class'].map(mapping)
y = df['class']
figure = plt.figure()
ax = figure.add_subplot(111, projection='3d')
ax.scatter(X[y == 0, 0],X[y == 0, 1],X[y == 0, 2],c='r',label="Iris-setosa")
ax.scatter(X[y == 1, 0],X[y == 1, 1],X[y == 1, 2],c='g',label="Iris-versicolor")
ax.scatter(X[y == 2, 0],X[y == 2, 1],X[y == 2, 2],c='b',label="Iris-virginica")
ax.set_xlabel('sepal length(cm)')
ax.set_ylabel('sepal width(cm)')
ax.set_zlabel('petal length(cm)')
plt.title('Iris')
plt.legend()
plt.show()
time.sleep(2)