-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed
Labels
Description
Describe the bug
I am running metric and nonmetric MDS on the Digits dataset, and obtain nonsense results with metric=False. At the same time, my understanding is that non-metric MDS is more flexible and should not yield worse results compared to metric MDS. Is my understanding wrong, or does it suggest some problems with the non-metric MDS implementation?
Steps/Code to Reproduce
%matplotlib notebook
import pylab as plt
import numpy as np
from sklearn.datasets import load_digits
from sklearn.manifold import MDS
digits = load_digits()
X, y = digits.data, digits.target
Z1 = MDS(n_components=2, n_init=1, random_state=42).fit_transform(X)
Z2 = MDS(n_components=2, n_init=1, random_state=42, metric=False).fit_transform(X)
titles = ['Metric MDS', 'Non-metric MDS']
fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(6, 3), layout='constrained')
for i,Z in enumerate([Z1, Z2]):
ax = axs.ravel()[i]
ax.set_aspect('equal', 'datalim')
ind = np.random.permutation(X.shape[0])
ax.scatter(*Z[ind].T, s=3, color=plt.cm.Dark2(y)[ind])
ax.set_xticks([])
ax.set_yticks([])
for sp in ax.spines:
ax.spines[sp].set_visible(False)
ax.set_title(titles[i])
fig.savefig('digits-embed-mds-nonmetric.png', dpi=300)Expected Results
Non-metric MDS giving something sensible.
Actual Results
Versions
System:
python: 3.7.9 (default, Aug 31 2020, 12:42:55) [GCC 7.3.0]
executable: /home/dmitry/anaconda3/bin/python
machine: Linux-5.15.0-76-generic-x86_64-with-debian-bullseye-sid
Python dependencies:
pip: 22.3.1
setuptools: 65.6.3
sklearn: 0.24.1
numpy: 1.21.5
scipy: 1.7.3
Cython: 0.29.32
pandas: 1.3.5
matplotlib: 3.5.2
joblib: 1.1.1
threadpoolctl: 2.2.0
Built with OpenMP: TrueMetadata
Metadata
Assignees
Labels
Type
Projects
Status
Done
