From c2b74079e63fb43da6ab4ac699b4edb19e07d76d Mon Sep 17 00:00:00 2001 From: Scott Gigante Date: Fri, 4 May 2018 16:38:09 -0400 Subject: [PATCH] fix issue https://github.com/KrishnaswamyLab/PHATE/issues/20 --- Python/phate/mds.py | 10 ++++++---- Python/phate/phate.py | 22 +++++++++++----------- Python/phate/version.py | 2 +- Python/setup.py | 1 + 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Python/phate/mds.py b/Python/phate/mds.py index c255353..f77b7f1 100644 --- a/Python/phate/mds.py +++ b/Python/phate/mds.py @@ -94,13 +94,15 @@ def embed_MDS(X, ndim=2, how='metric', distance_metric='euclidean', n_jobs=1, se Y_cmds = cmdscale_fast(X_dist, ndim) # Then compute Metric MDS Y_mmds = MDS(n_components=ndim, metric=True, max_iter=3000, eps=1e-12, - dissimilarity="precomputed", random_state=seed, n_jobs=n_jobs, - n_init=1).fit_transform(X_dist, init=Y_cmds) + dissimilarity="precomputed", random_state=seed, + n_jobs=n_jobs, n_init=1).fit_transform(X_dist, + init=Y_cmds) # Nonmetric MDS from sklearn using metric MDS as an initialization Y = MDS(n_components=ndim, metric=False, max_iter=3000, eps=1e-12, dissimilarity="precomputed", random_state=seed, n_jobs=n_jobs, n_init=1).fit_transform(X_dist, init=Y_mmds) else: - raise ValueError( - "Allowable 'how' values for MDS: 'classic', 'metric', or 'nonmetric'. '%s' was passed." % (how)) + raise ValueError("Allowable 'how' values for MDS: 'classic', " + "'metric', or 'nonmetric'. " + "'{}' was passed.".format(how)) return Y diff --git a/Python/phate/phate.py b/Python/phate/phate.py index 11fd038..216afab 100644 --- a/Python/phate/phate.py +++ b/Python/phate/phate.py @@ -94,7 +94,7 @@ def calculate_kernel(data, k=15, a=10, alpha_decay=True, knn_dist='euclidean', random_state=random_state) data = pca.fit_transform(data) if verbose: - print("PCA complete in {:.2d} seconds".format( + print("PCA complete in {:.2f} seconds".format( time.time() - start)) if verbose: start = time.time() @@ -132,7 +132,7 @@ def calculate_kernel(data, k=15, a=10, alpha_decay=True, knn_dist='euclidean', kernel = knn.kneighbors_graph(data, mode='connectivity') if verbose: - print("KNN complete in {:.2d} seconds".format(time.time() - start)) + print("KNN complete in {:.2f} seconds".format(time.time() - start)) kernel = kernel + kernel.T # symmetrization return kernel @@ -184,7 +184,7 @@ def calculate_landmark_operator(kernel, n_landmark=2000, n_components=n_svd, random_state=random_state) if verbose: - print("SVD complete in {:.2d} seconds".format(time.time() - start)) + print("SVD complete in {:.2f} seconds".format(time.time() - start)) start = time.time() print("Calculating Kmeans...") kmeans = MiniBatchKMeans(n_landmark, @@ -306,8 +306,8 @@ def calculate_operator(data, k=15, a=10, alpha_decay=True, n_landmark=2000, kernel, n_landmark=n_landmark, random_state=random_state, verbose=verbose) if verbose: - print("Built graph and diffusion operator in %.2f seconds." % - (time.time() - tic)) + print("Built graph and diffusion operator in " + "{:.2f} seconds.".format(time.time() - tic)) else: if verbose: print("Using precomputed diffusion operator...") @@ -395,8 +395,8 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None, "'sqrt'. '%s' was passed." % (potential_method)) if verbose: - print("Calculated diffusion potential in %.2f seconds." % - (time.time() - tic)) + print("Calculated diffusion potential in " + "{:.2f} seconds.".format(time.time() - tic)) # if diffusion potential is precomputed (i.e. 'mds' or 'mds_dist' has # changed on PHATE object) else: @@ -405,7 +405,7 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None, tic = time.time() if verbose: - print("Embedding data using %s MDS..." % (mds)) + print("Embedding data using {} MDS...".format(mds)) if embedding is None: embedding = embed_MDS(diff_potential, ndim=n_components, how=mds, distance_metric=mds_dist, n_jobs=n_jobs, @@ -414,7 +414,7 @@ def embed_mds(diff_op, t=30, n_components=2, diff_potential=None, # return to ambient space embedding = landmark_transitions.dot(embedding) if verbose: - print("Embedded data in %.2f seconds." % (time.time() - tic)) + print("Embedded data in {:.2f} seconds.".format(time.time() - tic)) else: if verbose: print("Using precomputed embedding...") @@ -747,8 +747,8 @@ def fit_transform(self, X, **kwargs): self.fit(X) self.transform(**kwargs) if self.verbose: - print("Finished PHATE embedding in %.2f seconds.\n" % - (time.time() - start)) + print("Finished PHATE embedding in {:.2f} seconds.\n".format( + time.time() - start)) return self.embedding def von_neumann_entropy(self, t_max=100): diff --git a/Python/phate/version.py b/Python/phate/version.py index b5fdc75..d31c31e 100644 --- a/Python/phate/version.py +++ b/Python/phate/version.py @@ -1 +1 @@ -__version__ = "0.2.2" +__version__ = "0.2.3" diff --git a/Python/setup.py b/Python/setup.py index 46f6725..d5fef63 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -44,6 +44,7 @@ 'big-data', 'dimensionality-reduction', 'embedding', + 'manifold-learning', 'computational-biology'], classifiers=[ 'Development Status :: 5 - Production/Stable',