Skip to content

Instantly share code, notes, and snippets.

View margaritageleta's full-sized avatar
👽
Addictive as recursion...

3omni margaritageleta

👽
Addictive as recursion...
View GitHub Profile
@belltailjp
belltailjp / cmdscale.py
Last active June 17, 2019 21:55
Multi-Dimensional Scaling (also as known as Principal Coordinate Analysis) by Python
import matplotlib.pyplot as plt
import numpy as np
from sklearn import manifold
cities = "Athens Barcelona Brussels Calais Cherbourg Cologne Copenhagen Geneva Gibraltar Hamburg HookOfHolland Lisbon Lyons Madrid Marseilles Milan Munich Paris Rome Stockholm Vienna".split(" ")
d = np.array([
# from eurodist dataset: https://rstudio-pubs-static.s3.amazonaws.com/221886_5c57ad0f5ff546e8af6386162f29fabc.html
[ 0, 3313, 2963, 3175, 3339, 2762, 3276, 2610, 4485, 2977, 3030, 4532, 2753, 3949, 2865, 2282, 2179, 3000, 817, 3927, 1991],
[3313, 0, 1318, 1326, 1294, 1498, 2218, 803, 1172, 2018, 1490, 1305, 645, 636, 521, 1014, 1365, 1033, 1460, 2868, 1802],
[2963, 1318, 0, 204, 583, 206, 966, 677, 2256, 597, 172, 2084, 690, 1558, 1011, 925, 747, 285, 1511, 1616, 1175],