8000 Strange output from sklearn.manifold.Isomap · Issue #14010 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Strange output from sklearn.manifold.Isomap #14010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bayerthomas opened this issue Jun 2, 2019 · 1 comment · Fixed by #20531
Closed

Strange output from sklearn.manifold.Isomap #14010

bayerthomas opened this issue Jun 2, 2019 · 1 comment · Fixed by #20531
Labels

Comments

@bayerthomas
Copy link

I have a strange output when i use the scikit-learn (0.20.3) Isomap algorithm on the benchmark data-set Banana. At one random state (2) the dist_matrix contains few rows (index: 8, 11, 39, 57, 61, ..) with geodesic distance 0 to most others points of the training data.
Is this maybe a bug in the Isomap module? When i use other random states, all distances between different points are greater than 0.

from sklearn.manifold import Isomap

# X_train after train_test_split with random_state 2
X_train = [[ 1.1542607e+00, -4.5106135e-01],
       [-1.2157535e+00, -9.6099647e-02],
       [-9.7382161e-01,  5.1107412e-01],
       [ 5.6583722e-01,  8.1532233e-02],
       [ 2.3538675e-01,  7.7208712e-01],
       [ 1.1185911e-01,  2.8538629e-02],
       [-1.0160842e+00, -2.2355465e-01],
       [-1.6681541e+00, -1.4982444e+00],
       [ 1.9880220e+00,  1.1805377e+00],
       [ 6.5890573e-01, -9.8507109e-01],
       [-1.6945212e+00, -1.2709820e+00],
       [ 1.9042611e+00,  1.2686443e+00],
       [-1.1444113e+00, -1.2651786e+00],
       [-6.1278851e-01,  7.7520496e-01],
       [ 3.3458258e-01,  1.3940556e+00],
       [-9.0228645e-01, -3.5998776e-01],
       [ 5.0117983e-01,  5.5262894e-02],
       [-1.3147157e+00,  1.7543885e-01],
       [ 4.3009734e-01, -6.5434225e-01],
       [ 4.0645050e-01, -7.0707511e-01],
       [-3.9996307e-01,  4.6270998e-03],
       [ 1.2558518e+00, -1.8072487e-01],
       [-2.5622126e-01, -1.1511599e-01],
       [-7.8079897e-01, -1.1323788e-01],
       [ 6.6116007e-01, -1.9896742e-01],
       [-1.3577622e+00, -8.4838872e-01],
       [-2.0214880e+00, -7.9178584e-01],
       [-7.4843792e-01, -3.3999385e-02],
       [-1.0501309e-01, -4.4245311e-01],
       [-2.5296481e-01, -4.0613947e-01],
       [-8.1475365e-01, -6.8173463e-01],
       [-2.2517489e+00, -1.9629961e+00],
       [ 5.5723302e-01, -1.0364337e+00],
       [-1.3377859e+00, -4.1871854e-01],
       [-1.2459550e+00, -6.5640920e-01],
       [-1.4617707e+00, -2.9782805e-01],
       [-1.3155062e+00, -8.8026281e-02],
       [-1.8430047e-01, -3.1361099e-02],
       [ 6.2708065e-01, -6.2879122e-02],
       [ 2.2929455e+00,  1.3169488e+00],
       [-7.5968412e-01, -6.9771843e-01],
       [-2.0000902e+00, -1.7247189e+00],
       [-2.3441774e-01, -6.5611103e-01],
       [-3.2705405e-01,  6.1158632e-01],
       [-1.8846858e+00, -9.7919796e-01],
       [ 3.8163246e-01,  1.7481798e-01],
       [-1.4515531e+00, -1.2900661e+00],
       [-1.5937211e+00, -1.3567949e+00],
       [-2.5456778e-01, -1.4199165e-01],
       [-1.9325768e+00, -9.2041396e-01],
       [-1.5649621e+00, -1.7189587e-01],
       [ 7.0395480e-01, -9.0577490e-01],
       [ 2.9803841e-01,  5.0916296e-01],
       [ 9.4061695e-01, -7.8898278e-01],
       [-1.2081759e+00, -4.0900789e-01],
       [ 3.5204309e-01,  3.3260985e-01],
       [ 3.6906011e-01,  4.9002706e-01],
       [ 2.5732852e+00,  9.8866753e-01],
       [ 8.9639363e-01, -1.2730643e+00],
       [-1.1782299e+00,  3.0232810e-02],
       [ 1.1479239e+00,  4.3611501e-02],
       [ 2.6428088e+00,  1.1447794e+00],
       [-1.7634102e+00, -1.1687146e+00],
       [-1.9973801e-01,  1.7355704e+00],
       [ 1.1633817e+00, -7.6826820e-01],
       [-6.7354391e-01, -6.2047333e-01],
       [ 8.1933944e-01,  4.6239189e-02],
       [-7.5682762e-01,  2.9839299e-01],
       [ 1.1479768e+00, -1.1370211e+00],
       [-9.1413855e-01,  4.2461675e-01],
       [-7.7597727e-01,  1.2704115e-01],
       [-1.0294006e-01, -4.1443743e-01],
       [-1.9767508e+00, -8.7982904e-01],
       [-1.3744919e+00, -2.0495643e-01],
       [-7.4923572e-01,  1.0089513e-02],
       [ 1.4579463e+00, -9.1017340e-01],
       [-3.1765663e-01,  3.1721543e-01],
       [-1.4658071e+00, -3.5837283e-02],
       [ 2.3332661e-01, -2.7477427e-01],
       [ 5.1932684e-04,  2.8219834e-01],
       [ 7.3679297e-02,  1.2377308e-01],
       [-2.9395697e-03,  5.1293875e-01],
       [-3.7680059e-01, -6.1696409e-01],
       [-1.8702841e+00, -5.5544412e-01],
       [-9.7349642e-01, -4.6972610e-02],
       [ 2.3457599e-01,  1.4837959e+00],
       [ 8.5433642e-01, -5.3748062e-01],
       [-4.1460169e-01,  2.5616249e-01],
       [ 5.7365125e-02, -1.3364810e-01],
       [ 7.3476092e-01,  1.6289128e+00],
       [-6.6023510e-01, -7.0822087e-02],
       [ 8.2381889e-01,  5.8665701e-01],
       [-9.0355235e-01, -2.0256554e-01],
       [ 2.4078246e+00,  1.2622464e+00],
       [ 2.2037454e+00,  1.2566866e+00],
       [-3.2979777e-01,  8.2927264e-02],
       [ 4.0382320e-01,  9.9854675e-03],
       [-3.9089456e-01,  1.8127464e-01],
       [-1.1278010e+00, -4.4281267e-01],
       [-1.0618835e+00, -5.4866363e-01],
       [-1.7978052e-01,  5.9472930e-01],
       [-1.5300572e+00, -1.2080648e+00],
       [-1.3126053e+00, -4.9829279e-01],
       [-1.7045924e+00, -5.5356329e-01],
       [ 1.2123938e+00, -1.2364485e+00],
       [ 4.3578818e-02,  1.2588576e-02],
       [ 7.3855163e-01,  1.3924935e-01],
       [-1.1747689e+00,  1.5636960e-01],
       [-1.7340755e+00, -2.4220624e-01]]

embedding = Isomap()
embedding.fit(X_train)
dist_matrix = embedding.dist_matrix_

print(dist_matrix[8])
@bayerthomas
Copy link
Author

Here is the output:
print(dist_matrix[8]) [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.12156752 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.3340454 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.61591166 0. 0. 0. 0.65576246 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.42768041 0.22876897 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]

Usually only at the same index (like dist_matrix[8][8) the distance is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0