I'm trying to figure out a way to match users based on specific personality traits. Each trait will have its own category.

I figure in my user table I'll add a column for each category:

id    name    cat1    cat2    cat3
1     Sean    ?       ?       ?
2     Other   ?       ?       ?

Let's say I ask each user 3 questions in each category. For each question, you can answer one of the following: No, Maybe, Yes How would I calculate one number based off the answers in those 3 questions that would hold a value I can compare other users to?

I was thinking having some sort of weight. Like:

No    -> 0
Maybe -> 1
Yes   -> 2

Then doing some sort of meaningful calculation. I want to end up with something like this so I can query the users and find who matches close:

id    name    cat1    cat2    cat3
1     Sean    4       5       1
2     Other   1       2       5

In the situation above, the users don't really match. I'd want to match with someone with a +1 or -1 of my score in each category.

I'm not a math guy so I'm just looking for some ideas to get me started.

  • So why doesn't the solution you've tried work? Also, how do you get from (0,1,2) -> 4? What does that imply? If a category indicates a personality trait, why isn't it Boolean? Does the number represent a fuzzy membership? If so, what is the scale (4/5 seems really low)? I think the problem needs to be fleshed out a bit more before approaching the solution. – Steven Evers Nov 6 '13 at 17:54
  • @SteveEvers My example wasn't suppose to actually calculate. I was just looking for some ideas to point me in the right direction. The 4 would have been calculated based on adding the weight of the 3 questions in a specific category. – SeanWM Nov 6 '13 at 18:01

I'd use Euclidean Distance, but that's just me.

If you had only 2 categories you could call them X and Y. Then your problem would be simply a matter of computing the distance between two points.

If you had 3 categories, (X, Y, Z) then you'd need to calculate the distance in 3 dimensions.

According to Wikipedia the general formula is Euclidean Distance formula

A match is "close" if the distance between the two is small.

You should be able to compute distance as

dist = sqrt( (user1.cat1 - user2.cat1)^2 + (user1.cat2 - user2.cat2)^2 ...)
  • Thanks! And how do you suppose I actually get the group values for cat1, cat2, etc. Any ideas? – SeanWM Nov 6 '13 at 18:04
  • @SeanWM - There's not enough info in this question to answer how you'd collect the group values for cat1 etc. You may want to post that as a new question. – Dan Pichelman Nov 6 '13 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.