Byzantine Reality

Searching for Byzantine failures in the world around us

Programming Collective Intelligence

Every week (or so) I’ll hopefully get through a book and be able to recap it here, mostly as a motivation for me to read a book a week. This time we’ll start off with a book I read last week before I got this domain all squared away, Programming Collective Intelligence by Toby Segaran.

Somehow this is my first O’Reilly book, which inherently feels a little odd. For those of you not into the “book reading” thing, the O’Reilly books are all immediately recognizable from the animals on the cover (this one has penguins). That being said, let’s actually look at the book.

The book aims to teach Artificial Intelligence algorithms through the use of simple, real-world examples in Python. For the most part, I agree with his rationale for choosing Python: Python lets him keep his code examples as concise as possible to get the point across (that is, the algorithms). Although this works great for that purpose, the Python libraries he uses aren’t as portable as he suggests they are (I ran into numerous problems getting some of them to work on Mac OS X and Ubuntu Linux), so it’s hard to follow along in some of the chapters like I would have wanted to.

That detracts from the book a bit but isn’t a deal breaker. Most of the Python syntax he uses will be a breeze for Python programmers, but if you’re coming from anywhere else, take his advice and spend an hour or two beforehand reading the Python tutorial. If you’re not inclined to read, add code, test, and repeat, the code is all available on the author’s website, which can save you quite a bit of typing and if you’re not familiar with the Python-whitespace indentation, this may alleviate some suffering.

The book itself is incredibly readable and I love the use of these algorithms on real-world applications (e.g., finding recommendations for similar users on or using the eBay API) but my favorite parts of the book were definitely the parts on genetic algorithms and genetic programming. The example for the latter generates an AI for a simple game and allows you to compete against it to see how well it’s evolved. It requires a surprisingly small amount of code (<300 lines of code with comments) and uses a minimal amount of library support.

It’s aimed at a general audience; that is, a casual programmer who knows Python but is afraid of that crazy “math” stuff that’s possibly involved. Only one chapter really uses heavy math (linear algebra) and it’s spelled out well enough what it’s doing and why it’s needed.

Overall, it’s a book I’d definitely recommend. Hopefully down the line the support for some of the libraries improves so I can go back and try more of the examples out but I don’t hold it against the book (and author) too much. Check it out; it filled a huge gap in AI / machine learning knowledge that I had beforehand, and is accessible enough that I can go back to should I need anything really specific down the line.