Clojure for Machine Learning by Akhil Wali
Publisher: Packt Publishing
I have to be right in the target audience for this book. I do most of my coding in Clojure. And the work I do at Empear, with Clojure, utilizes several machine learning algorithms to spot patterns in how large software systems evolve. While I do enjoy coding in Clojure, every now and then I long for Python with its strong machine learning tooling and libraries. I hoped Clojure for Machine Learning would close that gap for me. Unfortunately the book don't deliver on that promise. Sure, I got some useful pointers to libraries and techniques that I probably need, but my overall impression is that the book doesn't dig deep enough.
Clojure for Machine Learning assumes that you have written Clojure code and knows the language fairly well. That's an excellent decision given the growing body of introductory Clojure books. Instead of spending valuable space on yet another language introduction, the author can now focus the full book on its topic (yes, you'd expect that to be that norm, but it's not always the case). So Clojure for Machine Learning dives right into how you work with matrices, which is fundamental to many of the algorithms that follow. After that we dive into traditional statistic methods like linear regression, Bayesian classification, and the k-nearest neighbors algorithm as we learn to classify data. The rest of the chapters each covers a family of machine learning algorithms: neural networks, support vector machines, K-means clustering. In short, everything you'd expect.
That brings us to the style of the book. Let me put it this way: the delivery could have been better. Much better. The author starts each chapter by a general discussion of an algorithm (or often families of algorithms). He proceeds to present the math and moves on to implementing it in Clojure. The good thing is that the author breaks down each algorithm in smaller steps and walks us through the implementation. And this is where the negatives start. Although there's plenty of text describing the algorithms and implementations, the text focuses on the mechanical steps, the what, rather than the why. I found this to be the single most problematic aspect of the book. It's definitely possible to follow along and start to apply the algorithms on your own problems. But without a deeper understanding of why we chose one algorithm over another or why we do the choices we do in the actual implementation, I doubt that the end result will be satisfactory.
So the machine learning part is comprehensive in scope, albeit too shallow to be of real value. What about the Clojure aspect of the book? Well, there's nothing special with the combination of machine learning and Clojure. The author implements some algorithms from scratch without any third-party libraries, but most chapters build on existing libraries and you get introduced to the most important ML libraries for Clojure, like clj-ml and enclog. I found the sample code easy to follow and it did provide a base for my own explorations of those libraries. So the samples serve their purpose, but they're far from as useful as they could have been. For example, when introducing Artifical Neural Netorks (ANN), the author trains a neural net to model an XOR gate. It's a classic example for an ANN since XOR is nonlinear, which means we cannot use traditional methods like linear regression. The problem is that you'll find exactly the same example in the documentation for enclog (the library used to implement ANN). Disappointing, and a missed opportunity for the book to provide more value.
Machine learning is hard, no doubt about it. A book like this could provide so much more value if it attempted to explain the trade-offs and reasoning that a skilled data analyst do. Unfortunately, Clojure for Machine Learning doesn't even attempt to. This is made worse by the writing style. It's dry. Perhaps not in the way that assembly manuals from the well-known Swedish furniture company are dry, the ML topic is too interesting for that, but nonetheless uninspiring. The book would have been so much better, had it included more motivating examples expressed in a personal way.
This review may well come of as a bit more negative than I meant it to be. I did learn some new stuff from Clojure for Machine Learning. It's just that I was expecting so much more when a book covers the intersection between two really exciting areas. Instead I was left with the feeling that I didn't learn enough about either of those.
Reviewed March 2016