A few years ago I read a book on artificial intelligence algorithms (Artificial Intelligence for Humans) and had it on my todo list to implement a couple of the algorithms.
There’s lots of implementations out there already in Go, but I’ve always found that writing an implementation makes sure I understand how something really works and why existing implementations are designed the way they are, or what problems to look out for.
So far, I’ve implemented KMeans clustering and a few distance metrics to use: Chebyshev (Chessboard), Euclidean and Manhattan.
Here’s some example code which produces the PNG graph above.
The code is up at https://github.com/a-h/ml
I’ll be adding more functions when I feel like it.