Twitter Recommendation Engine

I’ve been working on a little Python script1 using the Twitter API that can recommend people for me to follow.  Here’s the basic idea:

  1. Get the list of people that I currently follow.
  2. Get a list of people who follow them. (I currently truncate this list at 100 followers per person to try to keep any one person from being too over represented, and to keep the run-time down.)  This list represents “people like me” because they have the same interest.
  3. For all of the people like me, look up who they follow (again limited per person for the sake of time).
  4. Score2, sort, and print these “votes.”  These are the recommendations.

So far, it works pretty well.  About half of the top 40 results are people that I already follow, and the others do look like people that I’d be interested in following (some of which I have followed periodically).  Here’s what it came up with so far (*’s are the suggested new people to follow):

John Resig
A Googler
Barack Obama *
Twitter
CNN Breaking News
Kevin Rose
why the lucky stiff
Eric A. Meyer
Tim O’Reilly
wefollow *
Leo Laporte
Jeff LaMarche
Twephanie
Scott Hanselman
Jeff Atwood *
Felicia Day
The Onion *
Asa Dotzler
Jonathan Coulton
KevinSmith *
MacHeist *
Evan Williams *
Garrett Lisi
Wil Wheaton *
Stephen Fry *
Al Gore *
drhorrible
RainnWilson
Aaron Boodman
woot.com *
DHH *
Day in the Cloud
Dave Mark
zefrank
Michael Arrington *
Mike Massimino *
Christopher Blizzard
John Gruber *
Pete Cashmore *
Neil Gaiman


I can also tweak the code so that it just looks at the followers of just one person instead of all of the people I follow to get more targeted results.  For example,

Followers of John Resig (jQuery) might like:

Eric A. Meyer
Jeff Atwood
Joel Spolsky
Molly E. Holzschlag
Elijah Manor
Rasmus Lerdorf
Jason Fried
wefollow
Scott Hanselman
Tim O’Reilly

Followers of Chris Blizzard (Mozilla) might like:

Mike Beltzner
Mike Shaver
John Lilly
MitchellBaker
Joe Drew
Mike Connor
Gen Kanai
J Nightingale
Barack Obama
A Googler

Etc…

Currently, my script takes about an hour to generate a list of suggestions based on a single person, but most of that time is just sleeping so that it doesn’t slam the Twitter API.  I really wish this was something that was built in to Twitter.  It wouldn’t need to list similar people for everyone, maybe just popular members.  It could then combine these similar people list based on who you’re following to give you a quick set of suggestions.


1 – I’m not planning on publishing this script. It’s pretty basic and I think anyone that could get it working for them would have more fun writing their own version. If for some reason, you really want a copy, let me know.

2 – The scoring doesn’t have to be linear (one follow = one vote). I’m using something like 1 / number_of_follows to as the value of the vote. That way, people who distribute their attention by following a lot of others have less of a vote than people with a more limited list. There’s still room for improvement here.

One Response to “Twitter Recommendation Engine”

  1. a broken thought » Blog Archive » Twitter Recommendation Engine: Part 2 Says:

    […] summer I built a little recommendation engine for people to follow on Twitter.  I’ve been meaning to build a new one since Twitter added […]

Leave a Reply