My Python Code for the Netflix Prize (github.com)
I competed alone in the Netflix Prize in college under the team name "Hi!". I've never seen anybody release their code, and I'm getting back into machine learning now, and realized that some folks might want to take a gander at a competitive machine learning codeset.
It's implemented mostly in Python, with Cython for the real speed-sensitive parts (everything in file "svd.pyx" did the heavy lifting, and got me up the leaderboard).
I hope that some folks will find this useful.
30 comments
[ 3.1 ms ] story [ 34.5 ms ] thread@viraj_shah I spent about 6 months working on the project before I had to stop to concentrate on my schoolwork (I was a senior in collge at the time). I think it would have been impossible to do this for myself without Cython. If it were to happen today, I would probably be writing in PyCuda, or with Numba, and it would be much, much, MUCH more succinct.
https://github.com/nogwater/NetflixPrizeD
The algorithm is based on Simon Funk's blog post here: http://sifter.org/~simon/journal/20061211.html
For me, the best part was squeezing the data and indexes into memory. :)
http://code.google.com/p/wikipedia-netflix/wiki/WikipediaNet...
It includes Wikipedia parsing stuff and a fairly fast C++ implementation of the very cool BellKor kNN algorithm.
Yet that seems to be the sort of jockeying and tweaking these problems (seen now in Kaggle contests) seem to require. Is there an art or science then to the subsequent blending? Does one develop a better intuition for the problem at that point, or am I entirely missing the point of most ensemble methods (predictiveness over parsimonious understanding)?
You could regard this as an application of the "Smoothed expectation theorem", Saying E[X] = E[E[X|Y]]. That is, if you are trying to compute the expectation of something, you can make it depend on anything else, and compute the inner expectation with respect to that. Might seem trivial or useless, but it is wildly applicable and often significantly simplifies computations.
One of the practical implications is that if you're not sure about something (underlying model, specific parameters), just apply some prior distribution and compute the expectation over that -- it is essentially guaranteed* to provide a better result than trying to pick the correct setup.
Although I'm not sure what the interpretation here would be.
* - so long as the entropy of your prior is not more wrong than the entropy of your hyper-parameters. This is often the case.
The links are very often unrelated: "unlike in the movie X", "who by then had already became famous playing X in movie Z", etc. Instead of using the entire article, I only used links from the very first sentence. (" X is an Italian 1984 drama starring Z, etc...") These links could be connected to categories.
The problem I didn't expect was that the "hierarchy" of the categories is a mess. Seems easy in concept: "comedy-drama films" is a subcategory of both "comedy films" and "drama films", so you can use all the parent categories. In practice you get to completely unrelated categories in a few steps. The biggest challenge was cleaning this mess up algorithmically. Once that was done, I had a very nice taxonomy of the movies.
The result didn't come close anywhere to the top contestants, but it was a very interesting learning experience.
ratings[ratings<1.0] = 1.0
in
https://github.com/alexbw/Netflix-Prize/blob/master/src/pred...
Is it specific to NumPy? Or perhaps a Python trick I haven't seen before?
http://blogs.mathworks.com/steve/2008/01/28/logical-indexing...
http://www.scipy.org/Cookbook/Indexing#head-86055279f6592d36...
the beauty of self-publishing
Here's my implementation of a recommender algorithm in C if someone is interested : https://github.com/GHamrouni/Recommender
From pep 8: "Use 4 spaces per indentation level."