Skip to content

Commit e2e545f

Browse files
NelleVGaelVaroquaux
authored andcommitted
DOC: added references to papers and licence - fixed the MDS example
1 parent 0ee486f commit e2e545f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

examples/manifold/plot_mds.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
noise[np.arange(noise.shape[0]), np.arange(noise.shape[0])] = 0
3333
similarities += noise
3434

35-
mds = manifold.MDS(n_components=2, max_iter=3000, n_jobs=2,
35+
mds = manifold.MDS(n_components=2, max_iter=3000,
3636
eps=1e-9)
3737
pos = mds.fit(similarities).positions_
3838

3939
nmds = manifold.MDS(n_components=2, metric=False,
40-
max_iter=3000, n_jobs=2,
40+
max_iter=3000,
4141
eps=1e-9)
4242
npos = mds.fit(similarities).positions_
4343

@@ -52,9 +52,9 @@
5252
fig = plt.figure(1)
5353
ax = plt.axes([0., 0., 1., 1.])
5454

55-
plt.scatter(X_true[:, 0] + 0.2, X_true[:, 1] + 0.2, c='r', s=10)
55+
plt.scatter(X_true[:, 0], X_true[:, 1], c='r', s=10)
5656
plt.scatter(pos[:, 0] + 0.2, pos[:, 1] + 0.2, s=10, c='g')
57-
plt.scatter(pos[:, 0] - 0.2, pos[:, 1] - 0.2, s=10, c='b')
57+
plt.scatter(npos[:, 0] - 0.2, npos[:, 1] - 0.2, s=10, c='b')
5858
plt.legend(('True position', 'MDS', 'NMDS'))
5959

6060
similarities = similarities.max() / similarities * 100

sklearn/manifold/mds.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
# author: Nelle Varoquaux <nelle.varoquaux@gmail.com>
6+
# Licence: BSD
67

78
import numpy as np
89

@@ -39,6 +40,11 @@ def pool_adjacent_violators(distances, similarities, max_iter=300,
3940
Returns
4041
-------
4142
distances: ndarray, shape (n, 1)
43+
44+
Notes
45+
-----
46+
"Modern Multidimensional Scaling - Theory and Applications" Borg, I.;
47+
Groenen P. Springer Series in Statistics (1997)
4248
"""
4349
# First approach for ties: ignore them. The multidimensional scaling won't
4450
# enforce that points with equal similarity be at equal distance.
@@ -268,6 +274,17 @@ def smacof(similarities, metric=True, n_components=2, init=None, n_init=8,
268274
stress: float
269275
The final value of the stress (sum of squared distance of the
270276
disparities and the distances for all constrained points)
277+
278+
Notes
279+
-----
280+
"Modern Multidimensional Scaling - Theory and Applications" Borg, I.;
281+
Groenen P. Springer Series in Statistics (1997)
282+
283+
"Nonmetric multidimensional scaling: a numerical method" Kruskal, J.
284+
Psychometrika, 29 (1964)
285+
286+
"Multidimensional scaling by optimizing goodness of fit to a nonmetric
287+
hypothesis" Kruskal, J. Psychometrika, 29, (1964)
271288
"""
272289

273290
random_state = check_random_state(random_state)

0 commit comments

Comments
 (0)