|
31 | 31 | # import some data to play with |
32 | 32 | iris = datasets.load_iris() |
33 | 33 | X = iris.data[:, :2] # we only take the first two features. |
34 | | -Y = iris.target |
| 34 | +y = iris.target |
35 | 35 |
|
36 | 36 | x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5 |
37 | 37 | y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5 |
|
40 | 40 | plt.clf() |
41 | 41 |
|
42 | 42 | # Plot the training points |
43 | | -plt.scatter(X[:, 0], X[:, 1], c=Y, cmap=plt.cm.Paired) |
| 43 | +plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired) |
44 | 44 | plt.xlabel('Sepal length') |
45 | 45 | plt.ylabel('Sepal width') |
46 | 46 |
|
|
54 | 54 | fig = plt.figure(1, figsize=(8, 6)) |
55 | 55 | ax = Axes3D(fig, elev=-150, azim=110) |
56 | 56 | X_reduced = PCA(n_components=3).fit_transform(iris.data) |
57 | | -ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=Y, |
| 57 | +ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=y, |
58 | 58 | cmap=plt.cm.Paired) |
59 | 59 | ax.set_title("First three PCA directions") |
60 | 60 | ax.set_xlabel("1st eigenvector") |
|
0 commit comments