haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
5.97k stars 1.13k forks source link

Ability to stop TSNE, possibly other time-heavy computations #740

Closed Nightenom closed 1 year ago

Nightenom commented 1 year ago

Is your feature request related to a problem? Please describe. Hi (currently doing some uni semestral work), running t-SNE with high amount of iterations (eg. 5k) may take a very long time, especially with medium to big data (mine is 10k 10-dims points) on not high-end PCs. My app provides way to stop such computation, which must be unfortunately handled by Thread#stop(), because the current code provides no progress listener nor checks for Thread#isInterrupted().

Describe the solution you'd like Ideally provide listener with iterations granularity - sth like each X iterations call supplied Consumer<Integer>. This approach provides fine control to executor, which may also check for thread interruptions. Might also use Predicate<Integer> and throw InterruptedException

Describe alternatives you've considered Or at least check for Thread#isInterrupted() periodically.

Additional context ~None~, except having a nice day :) Actually, there is also no way to control stream parallelism

haifengl commented 1 year ago

The update() method takes iterations parameter. Instead of stopping the computation, you may set a small value for iterations. If the results are not good enough, you can call update() again until the visualization looks good.