Skip to content

Commit 8b9c248

Browse files
jaquesgrobleramueller
authored andcommitted
Andy`s suggestions
1 parent 15e40c9 commit 8b9c248

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

examples/manifold/plot_manifold_sphere.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
on a spherical data-set. Here one can see the use of
1111
dimensionality reduction in order to gain some intuition
1212
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
1515
'spread it open' whilst projecting it onto two dimensions.
1616
1717
For a similiar example, where the methods are applied to the
@@ -73,7 +73,7 @@
7373
ax = fig.add_subplot(241, projection='3d')
7474
pl.scatter(x, y, z, c=p[indices], cmap=pl.cm.rainbow)
7575

76-
sphere_data = np.array([x, y, z])
76+
sphere_data = np.array([x, y, z]).T
7777

7878
# Perform Locally Linear Embedding Manifold learning
7979
methods = ['standard', 'ltsa', 'hessian', 'modified']
@@ -83,10 +83,9 @@
8383
t0 = time()
8484
trans_data = manifold.LocallyLinearEmbedding(n_neighbors, 2,
8585
eigen_solver='auto',
86-
method=method).fit_transform(sphere_data.T)
86+
method=method).fit_transform(sphere_data).T
8787
t1 = time()
8888
print "%s: %.2g sec" % (methods[i], t1 - t0)
89-
trans_data = trans_data.T
9089

9190
ax = fig.add_subplot(242 + i)
9291
pl.scatter(trans_data[0], trans_data[1], c=colors, cmap=pl.cm.rainbow)
@@ -97,10 +96,9 @@
9796

9897
# Perform Isomap Manifold learning.
9998
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
101100
t1 = time()
102101
print "%s: %.2g sec" % ('ISO', t1 - t0)
103-
trans_data = trans_data.T
104102

105103
ax = fig.add_subplot(246)
106104
pl.scatter(trans_data[0], trans_data[1], c=colors, cmap=pl.cm.rainbow)
@@ -112,8 +110,7 @@
112110
# Perform Multi-dimensional scaling.
113111
t0 = time()
114112
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
117114
t1 = time()
118115
print "MDS: %.2g sec" % (t1 - t0)
119116

0 commit comments

Comments
 (0)