1

hard to explain...let me try:

I built a script that compare two users' interests (hobbies)

let's assume userA have 44 hobbies, and 13 in common with userB (who has 19 hobbies) so in pseudo code (where % is my formula):

    func %(userA,userB) = 13

...etc..comparing other users

    func %(userA, userC) = 2
    func %(userA, userD) = 7

given that users' hobbies have no limit, can be 100, 20 or infinite...

how can i calculate and show the percentage of "compatibility" between userA and rest of the world?

because my thought was, if i knew the 20 i the max numebr of hobbies, i do a simple equation (bewteen user A and B)

percent = 13 / 20 * 100 so between userA and userB i can display "you match 65%"

but my problem i dont know the value 20 (the maxium number)! that's my problem!

easwee
  • 15,757
  • 24
  • 60
  • 83
Francesco
  • 24,839
  • 29
  • 105
  • 152

2 Answers2

2

You're close.

In your example, User A compatibility percentage with User B = 13 / 19 (total User B hobbies) = 68.4 %

User B compatibility percentage with User A = 13 / 44 (total User A hobbies) = 29.5%

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • oh right...i see, basically the max value (20 in my example) is gonna be replace everytime byt the userB's tot number of hobbies...what if userB has less hobbies than userA? – Francesco Mar 03 '11 at 20:06
  • @camelCase: You get the total number of hobbies (the divisor) from the other person. In your example, A uses B's total, and B uses A's total. – Gilbert Le Blanc Mar 03 '11 at 20:08
  • yes, i got that part...it works...but iw onder what happen in this other case: when a userA who has 100 hobbies, userB has 50, userC has 25. all of them have the same 10 interests in common: that means though that the userC with less hobbies will be have a higher percentage because he has less items...am i wrong? – Francesco Mar 03 '11 at 20:19
  • @camelCase: Yes, userA and userB will have a higher compatibility percentage with userC, than userC's compatibility percentage with either userA or userB. The optimizing strategy for your users would be to have one and only one hobby. Remember, your userA has 100 interests he wants to share. If he only has 10 interests in common with userC, then userC is a poor match for userA, even though userA is a better match for userC. – Gilbert Le Blanc Mar 03 '11 at 20:26
  • 1
    @camelCase: I think what you want is to divide INTERSECTION(A, B) by UNION(A, B). If A=44, B=19, and HobbiesInCommon=13, then the union of A and B is 50 (assuming my math is right.) The score for A->B is the same as the score for B->A = 13/50 = 26%. – oosterwal Mar 03 '11 at 20:35
  • 1
    @camelCase: On the other hand, if you're looking for a directional ATTRACTION indicator where A->B is not necessarily the same as B->A, then you would divide INTERSECTION(A, B) by A to see how attracted A is to B, or divide INTERSECTION(A, B) by B to see how attracted B is to A. The former is 13/44=29.5% and the latter is 13/19=68.4%. B is more attracted to A than A is attracted to B. – oosterwal Mar 03 '11 at 20:42
2

I think first you need to calculate the total number of unique hobbies, which in your case is between 44+19 (all different) and 19 (all common) = TOTAL. Then you need to know the number of common hobbies 13 = COMMON. Then, matching factor will be:

COMPATIBILITY = COMMON_HOBBIES/TOTAL_HOBBIES *100%
pmod
  • 10,450
  • 1
  • 37
  • 50