Skip to content
Browse files

DOC: added references to papers and licence - fixed the MDS example

  • Loading branch information...
1 parent 0ee486f commit e2e545f4e70862e095665b1ef67224177bab572a @NelleV NelleV committed with GaelVaroquaux May 29, 2012
Showing with 21 additions and 4 deletions.
  1. +4 −4 examples/manifold/plot_mds.py
  2. +17 −0 sklearn/manifold/mds.py
View
8 examples/manifold/plot_mds.py
@@ -32,12 +32,12 @@
noise[np.arange(noise.shape[0]), np.arange(noise.shape[0])] = 0
similarities += noise
-mds = manifold.MDS(n_components=2, max_iter=3000, n_jobs=2,
+mds = manifold.MDS(n_components=2, max_iter=3000,
eps=1e-9)
pos = mds.fit(similarities).positions_
nmds = manifold.MDS(n_components=2, metric=False,
- max_iter=3000, n_jobs=2,
+ max_iter=3000,
eps=1e-9)
npos = mds.fit(similarities).positions_
@@ -52,9 +52,9 @@
fig = plt.figure(1)
ax = plt.axes([0., 0., 1., 1.])
-plt.scatter(X_true[:, 0] + 0.2, X_true[:, 1] + 0.2, c='r', s=10)
+plt.scatter(X_true[:, 0], X_true[:, 1], c='r', s=10)
plt.scatter(pos[:, 0] + 0.2, pos[:, 1] + 0.2, s=10, c='g')
-plt.scatter(pos[:, 0] - 0.2, pos[:, 1] - 0.2, s=10, c='b')
+plt.scatter(npos[:, 0] - 0.2, npos[:, 1] - 0.2, s=10, c='b')
plt.legend(('True position', 'MDS', 'NMDS'))
similarities = similarities.max() / similarities * 100
View
17 sklearn/manifold/mds.py
@@ -3,6 +3,7 @@
"""
# author: Nelle Varoquaux <nelle.varoquaux@gmail.com>
+# Licence: BSD
import numpy as np
@@ -39,6 +40,11 @@ def pool_adjacent_violators(distances, similarities, max_iter=300,
Returns
-------
distances: ndarray, shape (n, 1)
+
+ Notes
+ -----
+ "Modern Multidimensional Scaling - Theory and Applications" Borg, I.;
+ Groenen P. Springer Series in Statistics (1997)
"""
# First approach for ties: ignore them. The multidimensional scaling won't
# 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,
stress: float
The final value of the stress (sum of squared distance of the
disparities and the distances for all constrained points)
+
+ Notes
+ -----
+ "Modern Multidimensional Scaling - Theory and Applications" Borg, I.;
+ Groenen P. Springer Series in Statistics (1997)
+
+ "Nonmetric multidimensional scaling: a numerical method" Kruskal, J.
+ Psychometrika, 29 (1964)
+
+ "Multidimensional scaling by optimizing goodness of fit to a nonmetric
+ hypothesis" Kruskal, J. Psychometrika, 29, (1964)
"""
random_state = check_random_state(random_state)

0 comments on commit e2e545f

Please sign in to comment.
Something went wrong with that request. Please try again.