Because we've written the k-means algorithm to handle any arbitrary number of dimensions, we can also test it with 3D data (or 10D, or 100D or any number of dimensions that you require). While this algorithm will work for more than three dimensions, we have no way of visually plotting the higher dimensions and therefore can't visually check the results—so we'll test with 3D data and move on.
Open up data.js and add the following to the middle of the file—anywhere preceding the export default line is OK:
const example_3d3k = [
[1, 1, 1],
[1, 2, 1],
[2, 1, 2],
[2, 2, 3],
[2, 4, 3],
[5, 4, 5],
[5, 3, 4],
[6, 2, 6],
[5, 3, 6],
[6, 4, 7],
[9, 1, 4],
[10, 2, 5],
[9, 2, 5],
[9, 2, 4],
[10, 3, 3]
];
And then modify the export line to look like this (add the example_3d3k variable to the...