I had a little search, but did not find anything similar to what I am trying to achieve.
Basically, I am trying to find a similarity between the habits for voting between two users.
I have a table that stores every single voice that stores:
voteID
itemID (the item the vote is attached to)
userID (the user who voted)
direction (whether the user voted the post up, or down)
I am going to calculate the similarity between, say, users A and B by discovering two things:
- The number of votes that they have in common . That is, the number of times they voted at one post (the direction at this stage does not matter).
- How many times have they voted in the same direction, by common vote .
(Then just calculate # 2 as a percentage of # 1 to achieve a rough similarity score).
My question is: how do I find the intersection between the user votes? (that is, how can I correctly calculate point # 1 without looping around each vote is extremely inefficient.) If they were in different tables, I would suggest INNER JOIN ... but this obviously will not work in the same table (or will ?).
We will be very grateful for any ideas.
source
share