Jump to ratings and reviews
Rate this book

Clojure for Machine Learning

Rate this book
Clojure for Machine Learning is an introduction to machine learning techniques and algorithms. This book demonstrates how you can apply these techniques to real-world problems using the Clojure programming language.

It explores many machine learning techniques and also describes how to use Clojure to build machine learning systems. This book starts off by introducing the simple machine learning problems of regression and classification. It also describes how you can implement these machine learning techniques in Clojure. The book also demonstrates several Clojure libraries, which can be useful in solving machine learning problems.

Clojure for Machine Learning familiarizes you with several pragmatic machine learning techniques. By the end of this book, you will be fully aware of the Clojure libraries that can be used to solve a given machine learning problem.

292 pages, Paperback

First published January 1, 2014

5 people are currently reading
53 people want to read

About the author

Akhil Wali

3 books

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
2 (9%)
4 stars
6 (28%)
3 stars
12 (57%)
2 stars
1 (4%)
1 star
0 (0%)
Displaying 1 - 9 of 9 reviews
Profile Image for Jake McCrary.
424 reviews25 followers
May 24, 2014
Review originally posted on my blog.


I was recently given a review copy of Clojure for Machine Learning. I have an academic familiarity with machine learning techniques and presented on a few at speakerconf 2012. I haven’t explored machine learning in Clojure since preparing that talk and was excited to read a book on the topic.

The book gives a shallow introduction to many different topics. It does so through a bit of mathematics and much more code. Depending on the section, the code examples implement the algorithm being discussed, show you how to use a specific library, or do both.

An aspect I particularly enjoy about the code examples is that they always start by showing what dependencies should be added to your project.clj file. This is done even if the library has been used in a previous chapter. Because of this every example can stand on its own.

Something that can almost always be improved about Clojure examples is that namespaces should be referenced using the require form with a namespace alias. Even if that require requires a namespace with a terrible alias, such as (require '[example :as e]), it makes the example code easier to understand. Being able to read e/a-func instead of a-func makes it more explicit as to where that function is located and aides understanding.

Even with my limited machine learning background I didn’t learn anything new but I was introduced to some Clojure libraries and enjoyed seeing Clojure implementations of machine learning techniques.

If you enjoy Clojure and the table of contents excites you then you’ll most likely find this book interesting. If you want to maximize your learning I’d recommend taking an online course in machine learning. It will be a larger time investment but you’ll leave with a deeper understanding.
Profile Image for Tomasz Nurkiewicz.
Author 1 book47 followers
June 29, 2014
Clojure for Machine learning, together with Clojure Data Analysis Cookbook, are two compelling books for people interested in data mining and reasoning. It is also worth mentioning that the amount of publications not dedicated to Clojure itself but how to effectively use it in real world problems is growing. Therefore Clojure for Machine Learning is not a suitable book for newcomers to the language. It will probably not be a good starting point for people completely new to machine learning as well. However basic Clojure knowledge and rough understanding of core concepts in machine learning will be enough to enjoy this book.

Book goes through pretty much all standard machine learning topics, including: linear regression, various classification algorithms, clustering, artificial neural networks and support vector machines. Author also briefly covers large scale machine learning on top off Hadoop and Map Reduce. Too bad other more modern BigData solutions were not represented. This book starts with a brief introduction to matrices and linear algebra. Not being an expert in the field I spotted few embarrassing mistakes. E.g. "For matrix A of size m x n and B of size p x q [...] if n = p, the product of A and B is a new matrix of size n x q" – in this notation the size of A times B is m x q, not n x q. Few pages later formula for calculating inversion of 2x2 matrix is broken (incorrectly transposed). For a book filled with math I would expect reviewers or proof readers to double checks easily available formulas.

Please keep in mind that Clojure for Machine learning is not a best choice to learn Clojure, it expects you to know basic constructs. Moreover Clojure code was not always perfectly idiomatic. Using + 1 rather than inc function, nesting of functions instead of composing or threading (-> macro) them, abuse of atoms to introduce mutability or using reduce instead of conceptually simpler apply + to add up vector of numbers. In one place we see sorting just to take first element – where simply taking minimum would be enough, cutting running time from O(nlogn) to O(n). However author does a good job explaining the code and in general it is quite pleasant to read. Many examples are written on top of ml-clj library, sometimes spiced with Incanter for visualization. But when the algorithm is not very complex, author implements it from scratch in plain Clojure. I found that really enjoyable.

I was reading an e-book on a dated Kindle Keyboard. The experience was rather good, however math formulas were stored in bitmap format and not scaled properly, thus when inlined in text they were much bigger than ordinary font, resulting in lots of empty space between lines. This is just cosmetics, maybe related to my device. Also one or two times the book references colours on pictures, which doesn’t work well on a black and white e-book reader.

Despite few issues, I found this book rather complete and moderately easy to read, taking subject into account. If you want to discover machine learning and have no prior Clojure knowledge, start from learning Clojure first. But if you happen to use Clojure already and need to improve your understanding or find good reference, definitely check out Clojure for machine learning. You can tell an author is an expert in the field and different aspects are explained well. You will not find many complete recipes, but a solid foundation instead.

Disclaimer: I received a free copy of this book from Packt Publishing and was asked for a review.
Profile Image for Niel Malhotra.
1 review
August 30, 2016
The publishers of Clojure for Machine Learning offered to give me the book if I would post a review.

It does exactly what the title says. It tells you how to run all the well known machine learning algorithms using clojure, along with a section on running these algorithms on multiple servers. That being said, it's rather dry and reads like a textbook. Maybe I'm spoiled by the O'Reily or Headfirst books, but I'd like a book to be engaging as well as informative.

I have one more complaint about this book. My biggest question about using clojure for machine learning is "Why should I use clojure for machine learning?". Since the vast majority of machine learning is done in python or R, there would have to be a very good reason for me to use clojure in real-life machine learning. The book completely ignores this very obvious question. It mentions, briefly, why clojure is a good programming language, but not what makes it especially useful for machine learning.

Those two major complaints aside, clojure for machine learning is a useful book. After having read it, I can use clojure for any basic machine learning task. Still, some information on why I should use clojure for machine learning and some effort to make the material more engaging would have turned a good book into a great one.
1 review
June 27, 2014
I've got a review copy of the book and have read the first three chapters. (Oh time!)

In short, the book provides a good bird-eye view of the intersection of Clojure and Machine Learning, useful for people coming from both sides. It introduces a number of important methods and shows how to implement/use them in Clojure but does not – and cannot – provide deep understanding. If you are new to M.L. and really like to understand things like me, you want to get a proper textbook(s) to learn more about the methods and the math behind them and read it in parallel. If you know M.L. but are relatively new to Clojure, you want to skip all the M.L. parts you know and study the code examples and the tools used in them. To read it, you need only elementary knowledge of Clojure and need to be comfortable with math (if you haven’t worked with matrices, statistics, or derivation and equations scare you, you will have a hard time with some of the methods). You will learn how to implement some M.L. methods using Clojure – but without deep understanding and without knowledge of their limitations and issues and without a good overview of alternatives and the ability to pick the best one for a particular case.

The main topics are matrices, linear regression, data categorization (f.ex. Bayesian classification, k-nearest neighbors, decision trees), neural networks, selection and evaluation of data, support vector machines, data clustering, anomaly detection and recommendation, big data. Some of the tools being used are Incanter, clj-ml (primarily a wrapper of Weka), Enclog (neural networks), BigML (facade for ML cloud services).

Some impressions from the first chapters (ch 1 – 2 take 1/3 of the book):

* I miss the big picture – f.ex. what kinds of regression methods are there, how to know which is appropriate? How to choose which of the 3-4 categorization methods to use in a given case? Again, a good textbook on M.L. would complement this pragmatically oriented book well.
* As mentioned, the book demonstrates what is possible but does not provide enough explanation and math theory to be able to really understand some of the more complex methods. You won’t be able to go and start deriving and optimizing good regression models just based on this text.
* Ch1 introduces matrices which are later used f.ex. to compute the parameters of an Ordinary Least Squares regression model. It mentions a number of concepts without elaborating their meaning such as eigen-vector and determinant.
* It would be nice if the author pointed regularly to good online/offline resources where the curious reader can learn more about the math, concepts, and methods being introduced.

Tip: You might want to check out the Stanford Machine Learning online course at Coursera, which also draws from numerous case studies and applications.

Regarding my qualification, I am a medium-experienced Clojure developer and have briefly encountered some M.L. (regression etc. for quantitive sociological research and neural networks) at the university a decade ago, together with the related, now mostly forgotten, math such as matrices and derivation.

Disclaimer: I have been unconditionally provided with a free copy of the e-book prior to reveiwing it.
Profile Image for Louis.
226 reviews30 followers
August 30, 2014
For a book that is about for , there are two approaches. One is to assume basic competence in the language and teach the task, the other is to assume that the reader has basic competence in the task and teach how to do it in a language. This book assumes knowledge of Clojure and tries to teach machine learning. But I find that it does just enough to be dangerous. It has a series of methods but does not provide discussion on why you would choose once class of method over another, and it completely skips model evaluation. What this creates is someone who has a good idea of the mathematics and implementation of methods, but not when to use it or if it actually did what was intended.

This makes me slightly different than the ideal audience of this book. I am learning Clojure and have only started using it for data analysis in real life. However, I have used Python and R for data analysis for several years now, and I have use both of them (and trained students to help me using both) for different machine learning projects (and I use R for teaching a course in data science).

Each chapter in Clojure for Machine Learning takes a look of a class of machine learning algorithms and takes several looks at it. Generally, Wali looks at the mathematics and theory of the algorithm, then a simple implementation in Clojure, then some examples of using existing library implementations on a problem. The mathematical treatment seems nice, but it would not compare to an actual text on machine learning/data mining. And while seeing an implementation in Clojure has some value, I would have liked to have seen more humility in doing so (i.e. some recognition that there are limitations of an implementation that can actually fit into a book of this size with everything else that needs to be done).

Two things that bother me about this after I finished was realizing that for each class of algorithms, the book only covers one or two methods. Which is fine, but it does not even acknowledge that there is a greater world. And as there is no discussion on how to perform model evaluation, an enthusiastic reader may reach the conclusion that they know what they are doing when implementing them against a data set and problem. Essentially, the enthusiastic reader knows enough to be dangerous and does not know what he does not know. If I were to suggest this book to someone, it would have to go with a severe caveat that what you know after this is how to set up a machine learning problem. More research has to be done to determine what actually needs to be done (the libraries used are much broader than what is covered) and then, learn from somewhere else how to evaluate or tune the methods used.

In the end, I would treat this as a book of examples or cases of Clojure being used in machine learning. There is room in the world for a book on Clojure for machine learning, but this is not it.
Profile Image for Alex Ott.
Author 3 books207 followers
July 1, 2014
Disclaimer: I got this book from Packt Publishing, but I planned to read it anyway...

Real rating is between 3 & 4 - 3 mostly for the not so good formatting - I'd read the mobi version of the book, and expected that referenced external resources/papers will be hyperlinked as in the most of the books (from Manning & O'Reilly, for example), providing the easy way to access them.

The book's content itself is ok, and organization is similar to the Programming Collective Intelligence: Building Smart Web 2.0 Applications or Machine Learning in Action - there is some amount of the theory (with links to external resources/papers) and after that - how to implement this task in Clojure, or how to use existing wrapper for Java library.

The book starts by covering basic matrix operations using the core.matrix, and after that describes most popular ML tasks/algorithms - linear regression, data categorization (providing naive bayes implementation), neural networks, SVMs, clustering & anomaly detection. It also shows how to perform cross-validation of the models using the spam classifier as an example.

The book is easy to follow - you need to know relatively small subset of the Clojure (but you need to know it already!), and basic understanding of the ML tasks. In some cases, book provides complete implementations using the Incanter, core.matrix & built-in Clojure functions, and in some cases (neural networks, SVMs, etc.) it uses wrappers for existing libraries like Weka, liblinear, etc. Code style sometime not consistent, and could be improved, but in general is ok.

I could recommend this book if you're interested in implementing ML tasks in Clojure - you can get some pieces of code from it. But don't expect that you get deep understanding of the theory behind ML - you need to take some other books.
Profile Image for Leonid Beschastny.
1 review
December 26, 2014
Clojure for Machine Learning is a perfect solution for Clojure programmers who want to learn Machine Learning techniques.

Clojure experience is recommended to understand the book, but it's not required. Author explains some Clojure basics and includes detailed instructions for running all examples. But since all examples are written in Clojure, reader should be at least familiar with functional paradigm.

The main focus of the book is explanation of core Machine Learning techniques, so it includes built-from-scratch implementations of basic Machine Learning algorithms with detailed explanations.

Apart from built-from-scratch implementations, all chapters contain good examples of using open source Clojure libraries like core.matrix, Incanter, clj-ml and Enclog.

I'm not sure if this book will be useful for people already familiar with Machine Learning. On the one hand, it covers all popular Machine Learning solutions for Clojure. On the other hand, it's focused on explaining Machine Learning basics.
Profile Image for Julio Biason.
199 reviews28 followers
May 2, 2017
If I ever read a book with a misleading title, that would be it.

Not because there is no Clojure in it, but the amount of Clojure used is minimal compared to the whole.

Also, not because there is no Machine Learning in it, but the book goes as deep as explaining the algorithms behind each common machine learning technique, without explaining when you should use it. There is ample discussion about the mathematical context of each method, but it explains absolutely nothing about machine learning itself -- it's purely a bunch of mathematical equations that could be use to extract some pattern, but it's hardly "machine learning" at this point.

(Also: Neural networks as "unsupervised learning"?!?)

So, good book on the math behind some machine learning equations, very bad clojure, very bad machine learning.
Displaying 1 - 9 of 9 reviews

Can't find what you're looking for?

Get help and learn more about the design.