|
10 | 10 | on a spherical data-set. Here one can see the use of |
11 | 11 | dimensionality reduction in order to gain some intuition |
12 | 12 | regarding the Manifold learning methods. Regarding the dataset, |
13 | | -The poles are cut from the sphere, as well as a thin slice down its |
14 | | -side. This enables the Manifold Learning techniques to |
| 13 | +the poles are cut from the sphere, as well as a thin slice down its |
| 14 | +side. This enables the manifold learning techniques to |
15 | 15 | 'spread it open' whilst projecting it onto two dimensions. |
16 | 16 |
|
17 | 17 | For a similiar example, where the methods are applied to the |
|
73 | 73 | ax = fig.add_subplot(241, projection='3d') |
74 | 74 | pl.scatter(x, y, z, c=p[indices], cmap=pl.cm.rainbow) |
75 | 75 |
|
76 | | -sphere_data = np.array([x, y, z]) |
| 76 | +sphere_data = np.array([x, y, z]).T |
77 | 77 |
|
78 | 78 | # Perform Locally Linear Embedding Manifold learning |
79 | 79 | methods = ['standard', 'ltsa', 'hessian', 'modified'] |
|
83 | 83 | t0 = time() |
84 | 84 | trans_data = manifold.LocallyLinearEmbedding(n_neighbors, 2, |
85 | 85 | eigen_solver='auto', |
86 | | - method=method).fit_transform(sphere_data.T) |
| 86 | + method=method).fit_transform(sphere_data).T |
87 | 87 | t1 = time() |
88 | 88 | print "%s: %.2g sec" % (methods[i], t1 - t0) |
89 | | - trans_data = trans_data.T |
90 | 89 |
|
91 | 90 | ax = fig.add_subplot(242 + i) |
92 | 91 | pl.scatter(trans_data[0], trans_data[1], c=colors, cmap=pl.cm.rainbow) |
|
97 | 96 |
|
98 | 97 | # Perform Isomap Manifold learning. |
99 | 98 | t0 = time() |
100 | | -trans_data = manifold.Isomap(n_neighbors, n_components=2).fit_transform(sphere_data.T) |
| 99 | +trans_data = manifold.Isomap(n_neighbors, n_components=2).fit_transform(sphere_data).T |
101 | 100 | t1 = time() |
102 | 101 | print "%s: %.2g sec" % ('ISO', t1 - t0) |
103 | | -trans_data = trans_data.T |
104 | 102 |
|
105 | 103 | ax = fig.add_subplot(246) |
106 | 104 | pl.scatter(trans_data[0], trans_data[1], c=colors, cmap=pl.cm.rainbow) |
|
112 | 110 | # Perform Multi-dimensional scaling. |
113 | 111 | t0 = time() |
114 | 112 | mds = manifold.MDS(2, max_iter=100, n_init=1) |
115 | | -trans_data = mds.fit_transform(euclidean_distances(sphere_data.T)) |
116 | | -trans_data = trans_data.T |
| 113 | +trans_data = mds.fit_transform(euclidean_distances(sphere_data)).T |
117 | 114 | t1 = time() |
118 | 115 | print "MDS: %.2g sec" % (t1 - t0) |
119 | 116 |
|
|
0 commit comments