K-Means clustering algorithm in code flow canvas
October 13, 2024
K-Means clustering algorithm in code flow canvas
In the above video I show the k-means clustering algorithm build in code flow canvas.
A dataset of 100 random points is generated and the k-means algorithm is used to cluster these points in 5 clusters and runs for max 5 iterations, although these values are customisable.
The flow uses some escape hatches to prevent the flow becoming too big although in the future I want to see if I can put more of the logic that is currently in the escape hatces in the flow (probably as sub flows which I call compositions in code flow canvas).
The visualisation of the clusters is implemented using SVG also with some custom code. The code-editor that is used is the monaco editor (which is the core of vs-code). The editor is not a dependency of code flow canvas but can be injected from the outside.
The timeline slider can be used to inspect the state of the flow at different points in time, this helps to see the clusters converge to their final form.