def get_scaled_vectors(vectors, user_seed=None, n_components=12, normalize=True, progress=progress): if user_seed: seed = np.random.RandomState(seed=user_seed) else: seed = np.random.RandomState() # FIXME: Make this optional: from sklearn.metrics.pairwise import euclidean_distances as d vectors = get_normalized_vectors( np.array(vectors)) if normalize else np.array(vectors) # compute similarities based on d progress.update('Computing similarity matrix') similarities = d(vectors) progress.update('Scaling using %d components' % n_components) mds = manifold.MDS(n_components=n_components, max_iter=300, eps=1e-10, random_state=seed, dissimilarity="precomputed", n_jobs=1) progress.update('Fitting') scaled_vectors = mds.fit(similarities).embedding_ return scaled_vectors
def get_scaled_vectors(vectors, user_seed = None, n_components = 12, normalize=True, progress = progress): if user_seed: seed = np.random.RandomState(seed=user_seed) else: seed = np.random.RandomState() # FIXME: Make this optional: from sklearn.metrics.pairwise import euclidean_distances as d vectors = get_normalized_vectors(np.array(vectors)) if normalize else np.array(vectors) # compute similarities based on d progress.update('Computing similarity matrix') similarities = d(vectors) progress.update('Scaling using %d components' % n_components) mds = manifold.MDS(n_components=n_components, max_iter=300, eps=1e-10, random_state=seed, dissimilarity="precomputed", n_jobs=1) progress.update('Fitting') scaled_vectors = mds.fit(similarities).embedding_ return scaled_vectors