saehm / DruidJS

A JavaScript Library for Dimensionality Reduction
107 stars 9 forks source link

Bugfix in UMAP algorithm #29

Closed johkehrer closed 1 year ago

johkehrer commented 2 years ago

Dear Rene, first of all, thank you for this very nice library that provides so many DR methods. We at Siemens are currently using it in one of our internal research projects for creating an interactive 3D scatterplot showing projected values.

I think I found a few bugs in the UMAP implementation. When accessing the rho and non_zero_dist arrays, I think one has to use the 'value' property to access the correct value (see lines 91, 140, 151, 171, for example). Also, I think it's not necessary to write values using set_entry in lines 363-364 and 384-385, since the Matrix' row function already returns a TypedArray on the ArrayBuffer that contains the original matrices values (instead of a copy).

Also I changed the 'dot' function to directly work on the values of Matrix B (instead of copying them to a new array using the col-Method). I found this beneficial, especially when dealing with larger datasets.

I would be happy, if you could merge some of these changes into the main branch. Best regards Johannes Kehrer (from Siemens AG in Munich)

saehm commented 1 year ago

Hey :)

Thank you very much for all those commits, and sorry for responding so late.

Best, Rene