Learning Machines: k-means From Scratch

Posted on
learning_machines itpnyu machine_learning

This week I wrote a k-means clustering implementation using only numpy and the Python standard library.

Above is is a visualization I made of my implementation running. The frames were made with matplotlib and stitched together with imageio.

Jupyter Notebook

You can find my implementation, usage examples, and how I made the viz below.

It ended up being a bit messy since I dove in without a full idea of how I would implement the algorithm. The class methods do not behave consistently. Some functions return values, while other modify instance attributes.