Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just wondering if someone could suggest a good algorithm in the collaborative filtering vein that I could use to suggest music choices based on top ten lists.

This is a personal project, I am a member of a private music blog where most of the users recently submitted "best of 2011" lists. The lists range in size (say 10-50 albums) and are not ranked. Have around 100 lists.

Basically hoping to give each user some recommendations based on the correlation of their list with everyone else's.

share|improve this question

migrated from Dec 30 '11 at 21:25

This question came from our site for professional and enthusiast programmers.

Quite simple really -

Firstly represent each user with a uid, and each track in the list as a song id. You will now have your user / item matrix representation.

For each user in your dataset run jaccard similarity. It's very simple, it just looks at intersections of songs between users.

Then take the X most similar users which can form the users nearest neighbourhood. After which you just do a weighted count for each song that exists. The weighting for each count is based on the similarity score. The songs with the highest scores are what you should recommend.

This approach doesn't require rankings or scores associated with each song.

share|improve this answer

There are a number of collaborative filtering methods you can research. As an alternative, I'm going to suggest something very pedestrian instead that should be easy to code and should give you reasonable results. Caveat: This is just off the top of my head, and may be very inferior to some of the more established methods out there, but it seems like a fun topic so I'll take a shot.

Since the lists are not ranked, you can compare each list to each other list. The number of common albums should be easily determined (assuming album names are not misspeled). Use that as a weight for each other album on everyone else's lists. So each album you don't have that appears on the list of someone with whom you share at least one album in common will appear in your recommendation list, weighted by the albums you have in common with that user. You will then aggregate the scores for each album across all other users.

So if you have 5 albums in common with User B, you would assign a weight of 5 to each album on that user's list that isn't on yours. Moving to User C, you would do the same. If User C has 3 common albums with you, then any albums on both User B and User C's list that aren't on yours now have a weight of 8.

You may want to increase the weight for lists where you share a lot of albums so those recommendations are even more valuable. In other words, a list with 10 common albums might get a weight of higher than 10, so it would count for more than 10 lists where you share a single album. This should be easy enough to tweak and test.

Once you have run through every other list, you can truncate your recommendation list to top 10 or something reasonable.

share|improve this answer
Thanks, I'll give this a whirl and report back. Probably do something to normalize the weights to account for the varying list lengths. – user976092 Dec 30 '11 at 3:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.