MNT accelerate example plot_lle_digits.py#21736
Conversation
…g plt.text with plt.scatter with Markers created from TeX symbols
glemaitre
left a comment
There was a problem hiding this comment.
I don't know if there is a way to accelerate even more the example by tweaking MDS, t-SNE, and NCA to accelerate them.
examples/manifold/plot_lle_digits.py
Outdated
| def plot_embedding(X, title, ax): | ||
| X = MinMaxScaler().fit_transform(X) | ||
|
|
||
| for t in np.unique(y): |
There was a problem hiding this comment.
I would propose the same renaming than in the previous example that I reviewed.
examples/manifold/plot_lle_digits.py
Outdated
| # of the original data. We will store the projected data as well as the computational | ||
| # time needed to perform each projection. | ||
| from time import time | ||
| from time import perf_counter |
|
Added n_iter=500, n_iter_without_progress=150, n_jobs=-1 to TSNE , n_jobs=-1 to MDS and changed init="random" to init="pca" in NCA. |
| for digit in digits.target_names: | ||
| ax.scatter( | ||
| *X[y == digit].T, | ||
| marker=f"${digit}$", | ||
| s=60, | ||
| color=plt.cm.Dark2(digit), | ||
| alpha=0.7, | ||
| ) |
There was a problem hiding this comment.
Does this addition (and the deletion bellow) change the rendering of this example?
examples/manifold/plot_lle_digits.py
Outdated
| n_neighbors=n_neighbors, n_components=2, method="ltsa" | ||
| ), | ||
| "MDS embedding": MDS(n_components=2, n_init=1, max_iter=100), | ||
| "MDS embedding": MDS(n_components=2, n_init=1, max_iter=100, n_jobs=-1), |
There was a problem hiding this comment.
Have you tried changing max_iter, here?
There was a problem hiding this comment.
max_iter bellow 100 is not converging and there's room to go to 125.
n_jobs is helping reduce runtime for MDS. for n_jobs=2 it is about 0.25 percent.
with max_iter =125 and n_jobs=2 it takes 3.9 +/- 0.2 seconds.
|
Let's use only |
|
Previous commit failed because of a signature test in matplotlib. So removed the param (zorder) from the initial call and set it later. |




Changing matplotlib.text with matplotlib.scatter and Markers created from TeX symbols improves runtime by almost 25 seconds.
Also changed time.time with time.perf_counter.
Reference Issues/PRs
#21598
What does this implement/fix? Explain your changes.
Any other comments?