Created
April 8, 2022 07:22
-
-
Save adrianlzt/dc78fcd9a9e791e8f1e4abe4ac23afd5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env pytho2 | |
| # -*- coding: utf-8 -2- | |
| # vim:fenc=utf-8 | |
| # | |
| # Copyright © 2022 adrian <adrian@arco> | |
| # | |
| # Distributed under terms of the MIT license. | |
| """ | |
| Representamos en 2d y 3d un número de puntos que entre ellos siempre están | |
| a distancia 1. | |
| """ | |
| import numpy as np | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from mpl_toolkits.mplot3d import Axes3D | |
| from sklearn import manifold | |
| mds2 = manifold.MDS(n_components=2, max_iter=3000, eps=1e-9, dissimilarity="precomputed", n_jobs=1) | |
| mds3 = manifold.MDS(n_components=3, max_iter=3000, eps=1e-9, dissimilarity="precomputed", n_jobs=1) | |
| # similarity matrix | |
| sm3 = np.ones([3,3]) | |
| sm4 = np.ones([4,4]) | |
| sm5 = np.ones([5,5]) | |
| sm6 = np.ones([6,6]) | |
| sm7 = np.ones([7,7]) | |
| sm8 = np.ones([8,8]) | |
| sm3mds2 = mds2.fit(sm3).embedding_ | |
| sm4mds2 = mds2.fit(sm4).embedding_ | |
| sm5mds2 = mds2.fit(sm5).embedding_ | |
| sm6mds2 = mds2.fit(sm6).embedding_ | |
| sm7mds2 = mds2.fit(sm7).embedding_ | |
| sm8mds2 = mds2.fit(sm8).embedding_ | |
| sm3mds3 = mds3.fit(sm3).embedding_ | |
| sm4mds3 = mds3.fit(sm4).embedding_ | |
| sm5mds3 = mds3.fit(sm5).embedding_ | |
| sm6mds3 = mds3.fit(sm6).embedding_ | |
| sm7mds3 = mds3.fit(sm7).embedding_ | |
| sm8mds3 = mds3.fit(sm8).embedding_ | |
| fig2 = plt.figure() | |
| fig2ax1 = fig2.add_subplot(2,3,1) | |
| fig2ax2 = fig2.add_subplot(2,3,2) | |
| fig2ax3 = fig2.add_subplot(2,3,3) | |
| fig2ax4 = fig2.add_subplot(2,3,4) | |
| fig2ax5 = fig2.add_subplot(2,3,5) | |
| fig2ax6 = fig2.add_subplot(2,3,6) | |
| fig2ax1.scatter(sm3mds2[:,0], sm3mds2[:,1]) | |
| fig2ax2.scatter(sm4mds2[:,0], sm4mds2[:,1]) | |
| fig2ax3.scatter(sm5mds2[:,0], sm5mds2[:,1]) | |
| fig2ax4.scatter(sm6mds2[:,0], sm6mds2[:,1]) | |
| fig2ax5.scatter(sm7mds2[:,0], sm7mds2[:,1]) | |
| fig2ax6.scatter(sm8mds2[:,0], sm8mds2[:,1]) | |
| plt.show() | |
| fig3 = plt.figure() | |
| fig3ax1 = fig3.add_subplot(2,3,1, projection='3d') | |
| fig3ax2 = fig3.add_subplot(2,3,2, projection='3d') | |
| fig3ax3 = fig3.add_subplot(2,3,3, projection='3d') | |
| fig3ax4 = fig3.add_subplot(2,3,4, projection='3d') | |
| fig3ax5 = fig3.add_subplot(2,3,5, projection='3d') | |
| fig3ax6 = fig3.add_subplot(2,3,6, projection='3d') | |
| fig3ax1.scatter(sm3mds3[:,0], sm3mds3[:,1], sm3mds3[:,2]) | |
| fig3ax2.scatter(sm4mds3[:,0], sm4mds3[:,1], sm4mds3[:,2]) | |
| fig3ax3.scatter(sm5mds3[:,0], sm5mds3[:,1], sm5mds3[:,2]) | |
| fig3ax4.scatter(sm6mds3[:,0], sm6mds3[:,1], sm6mds3[:,2]) | |
| fig3ax5.scatter(sm7mds3[:,0], sm7mds3[:,1], sm7mds3[:,2]) | |
| fig3ax6.scatter(sm8mds3[:,0], sm8mds3[:,1], sm8mds3[:,2]) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment