开发者

how to calculate the percentage of match / absolute value

开发者 https://www.devze.com 2023-02-14 12:11 出处:网络
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)

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 开发者_Go百科value 20 (the maxium number)! that's my problem!


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%


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%
0

精彩评论

暂无评论...
验证码 换一张
取 消