Re: Re: Find_by

Peter Hickman
Tue, 02 Feb 2010 09:45:06 -0000

Mm. The problem here is that your problem has little if anything to do with
Rails or Ruby even.

You have a database with a list of users and some additional data (such as
favourite movie) that, hopefully, lives in a another table.

What you want to find is the common interests / favourites between two
users. For a given user, 1234, you could iterate over all their favourites
building a list of other users who have similar interests.

So for user 1234 we find a list of other users who have the same location
and allocate them a score of 1 (so it''s just a hash with the user id as
the
key and a value).

We then find out which users in that list also like the same film and add
one to that users score, repeating this for all user 1234s favourites and
other pertinent data.

Then we pick, for example, the top five highest scoring users and suggest
them as possible friends.

The trouble is that this is potentially very expensive. If you have a lot of
users the number of people that live in London will be very large. So you
will have to compare a lot of data which is slow and expensive. On Facebook
I listed five of my favourite musicians, I had to add three of them myself,
no one else had ever listed them or probably even knew of them. Of the two
that were already on Facebook one was pretty unknown (Mystified) and the
final one was Interpol. So matching friends based on my musical choices will
result in either one match, the only other Mystified fan on Facebook
(assuming that he lives on the same continent as me) or thousands of
Interpol fans. Hardly a success.

Then there is the problem of spelling, how many ways are there to spell
Avatar (ok there is only one correct way but that doesn''t matter). And
how
about Shrek 2, if I list my favourite movies as Shrek 2 will I get matched
to people who liked Shrek (likely to be a good match), or how about people
who entered ''Shrek Two'' or ''Shrek II''.

How about Oceans 11, do I mean the 1960 version or the 2001 version. These
are in effect two different films.

Then you will have to run this in near real time because people change their
minds about what they like so you cannot easily precompute a list of
possible friends too far in advance of needing it.

Once you have sorted out an algorithm that can result in a good match and
managed to implement it efficiently then how you plug it into a Rails
application will have already been solved.

Your problem is the matching algorithm, ignore Rails for the moment and
focus on that.

Better yet, THE WORLD DOES NOT NEED YET ANOTHER DATING
SITE!!!!!!!!!!!!!!!!!!!!

Unless you are a contractor and getting paid to do it :)