Changeset 600
 Timestamp:
 08/28/16 15:04:25 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

mdsandtrees/mds_plot.py
r599 r600 77 77 def compute_mds(distance_matrix, dim): 78 78 embed, evals = cmdscale(distance_matrix) 79 79 80 variances = [np.var(embed[:,i]) for i in range(len(embed[0]))] 80 embed = np.asarray([embed[:,i] for i in range(dim)]).T 81 82 percent_variances = [sum(variances[:i+1])/sum(variances) for i in range(dim)] 81 percent_variances = [sum(variances[:i+1])/sum(variances) for i in range(len(variances))] 83 82 for i,pv in enumerate(percent_variances): 84 83 print(i+1,"dimension:",pv) 84 85 dim = min(dim, len(embed[0])) 86 embed = np.asarray([embed[:,i] for i in range(dim)]).T 85 87 86 88 return embed
Note: See TracChangeset
for help on using the changeset viewer.