pavlin-policar / openTSNE

Extensible, parallel implementations of t-SNE
https://opentsne.rtfd.io
BSD 3-Clause "New" or "Revised" License
1.47k stars 162 forks source link

Minor suggestions regarding verbose=1 #116

Closed dkobak closed 4 years ago

dkobak commented 4 years ago

I've just tried running openTSNE with verbose=1 and got this output:

/home/dkobak/anaconda3/envs/sonic/lib/python3.7/site-packages/sklearn/base.py:197: FutureWarning: From version 0.24, get_params will raise an AttributeError if a parameter cannot be retrieved as an instance attribute. Previously it would return None.
  FutureWarning)

--------------------------------------------------------------------------------
TSNE(callbacks=None, callbacks_every_iters=50, early_exaggeration=12,
     early_exaggeration_iter=250, exaggeration=None, final_momentum=0.8,
     initial_momentum=0.5, initialization='pca', ints_in_interval=1,
     learning_rate='auto', max_grad_norm=None, metric='euclidean',
     metric_params=None, min_num_intervals=50, n_components=2,
     n_interpolation_points=3, n_iter=500, n_jobs=-1,
     negative_gradient_method='fft', neighbors=None, perplexity=30,
     random_state=None, theta=0.5, verbose=1)
--------------------------------------------------------------------------------
===> Finding 90 nearest neighbors using auto search with euclidean metric...
   --> Time elapsed: 12.09 seconds
===> Calcualting affinity matrix...
   --> Time elapsed: 3.74 seconds
===> Running optimization with exaggeration=12 for 250 iterations...
Iteration   50, KL divergence 6.6167, 50 iterations in 3.2834 sec
Iteration  100, KL divergence 6.0356, 50 iterations in 3.4434 sec
Iteration  150, KL divergence 5.8738, 50 iterations in 3.5125 sec
Iteration  200, KL divergence 5.7969, 50 iterations in 3.6084 sec
Iteration  250, KL divergence 5.7529, 50 iterations in 3.6935 sec
   --> Time elapsed: 17.54 seconds
===> Running optimization with exaggeration=1 for 500 iterations...
Iteration   50, KL divergence 4.3295, 50 iterations in 3.7348 sec
Iteration  100, KL divergence 3.8001, 50 iterations in 3.7836 sec
Iteration  150, KL divergence 3.5264, 50 iterations in 4.9140 sec
Iteration  200, KL divergence 3.3481, 50 iterations in 7.0534 sec
Iteration  250, KL divergence 3.2212, 50 iterations in 9.2550 sec
Iteration  300, KL divergence 3.1279, 50 iterations in 12.2864 sec
Iteration  350, KL divergence 3.0582, 50 iterations in 13.1943 sec
Iteration  400, KL divergence 3.0055, 50 iterations in 17.1829 sec
Iteration  450, KL divergence 2.9648, 50 iterations in 18.8599 sec
Iteration  500, KL divergence 2.9319, 50 iterations in 24.3503 sec
   --> Time elapsed: 114.62 seconds

I think it looks great overall, but several small things caught my attention: first, there is some warning from sklearn. Second, "Finding 90 nearest neighbors using auto search" sounds a little unhelpful; it would be better it it said "Finding 90 nearest neighbors using annoy search". For this, the verbose=1 should probably be passed into build_knn_index() and it should print the message after the method is resolved. Third, there is a typo in "Calcualting affinity matrix".

Also, you might a separate ===> entry for initialization. At least with spectral it can take some time, but I guess pca on a large dataset can also take some non-negligible time.

pavlin-policar commented 4 years ago

First, there is some warning from sklearn.

This is likely due to the call to repr, and should be fixed on their end.

Second, "Finding 90 nearest neighbors using auto search" sounds a little unhelpful; it would be better it said "Finding 90 nearest neighbors using annoy search".

I agree, but it makes the code a little messier. But it's probably worth it.

Third, there is a typo in "Calcualting affinity matrix". ... Also, you might a separate ===> entry for initialization. At least with spectral it can take some time, but I guess pca on a large dataset can also take some non-negligible time.

I actually wanted to include exactly this in the spectral commit for both PCA and spectral init methods but forgot to push the commit. By the time I noticed, I had already merged to master, so it was too late.

Will fix 2. and 3. tomorrow.

dkobak commented 4 years ago

===> Running optimization with exaggeration=1, lr=1666.6666666666667 for 500 iterations...

You might want to print the learning rate as {:.1f} or something.

pavlin-policar commented 4 years ago

Yes, good idea.

dkobak commented 4 years ago

Another thing: verbose=1 prints neighbors=None (see above) instead of the actual value of neighbors.