Skip to content
My take at converting the python code from the O'Reilly book by Toby Segaran to my language of choice
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is my attemt to port the code examples from “Programming Collective Intelligence” by Toby Segaran from O’Reilly to ruby.

I try not to stupidly port the stuff, but also try to use ruby idioms and best practices wherevever possible.


  • [19.04.2008] – Did some housekeeping. First of all, to make the code as accessible as possible, I converted the python shell stuff into unit tests. I also tried to set up a clever way to load monkey patches such as my Array.sum stuff. YMMV.
  • [19.04.2008] – Implemented the ranking stuff aka top_matches and recommendations
  • [27.04.2008] – Fixed another minor data error, implemented the transformation for the product finder (investigated API’s for ruby. That IS a MESS.)


  • Chapter 2
    • Euclidean Distance Score – finished
    • Pearson-Coefficient – finished
    • Ranking aka top_matches – finished
    • Recommendations – finished (recommendations with sim_distance somehow returns different values (but in correct order) – need to investigate)
    • Finding Products (transforming) – finished


(a short collection of errors I encountered on my way through the book – if not stated otherwise, they are also present in the official oreilly errata collection.)

  • Chapter 2
    • Both example code AND result from the euclidean distance score are broken. The code in the book contains syntax errors (and the given similarity score for Lisa Rose and Gene Seymour is wrong). The example code from the website misses out the final sqrt() on the sums, but delivers, tadaa, the wrong result contained in the book.
Something went wrong with that request. Please try again.