You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that as the centroids change later in the algorithm, the underlying data array is also changed. This is undesirable for two reasons: mutating the data array which is passed in could have downstream effects, and even if the data array isn't used subsequently, it makes the algorithm incorrect.
Assuming I'm not missing something here (very possible, as I am not a JS developer), data[idx].slice() would be the fix I would suggest.
The text was updated successfully, but these errors were encountered:
The algorithm is "working as intended", in the sense of doing the things "as fast as possible". Performing this action will reduce considerably its performance, so I'm looking for a solution that resolve the issue for those that doesn't want its data mutated.
On this line, a data point is assigned to the centroids array by reference:
skmeans/main.js
Line 60 in 17aaa1b
This means that as the centroids change later in the algorithm, the underlying data array is also changed. This is undesirable for two reasons: mutating the data array which is passed in could have downstream effects, and even if the data array isn't used subsequently, it makes the algorithm incorrect.
Assuming I'm not missing something here (very possible, as I am not a JS developer),
data[idx].slice()
would be the fix I would suggest.The text was updated successfully, but these errors were encountered: