Saturday 11 March 2017

Assign values to numbers based on their coincidence with other numbers within multiple arrays

I'm creating a community app that allows its users to vote on posts similarly to sites like Reddit. I'd like to gather data that allows me to establish users' level of bias, and I'd like some direction on the implementation.

I'm approaching this problem like this:

1) Suppose each user represents a unique number, and each thread's list of users who have upvoted and users who have downvoted represent arrays respectively:

thread1 = {
    upvotes: [1, 3, 4, 10]
    downvotes: [2, 5, 8, 9]
}

2) When specific numbers tend to coincide in multiple arrays, those numbers can be said to be aligned.

//Strong alignments: 1,10; 2,8
//Weak alignments: 1,3; 3,10; 7,10; 2,5; 5,8
thread1 = {
    upvotes: [1, 3, 4, 10]
    downvotes: [2, 5, 8, 9]
}
thread2 = {
    upvotes: [1, 3, 7, 10]
    downvotes: [2, 6, 8, 9]
}
thread3 = {
    upvotes: [1, 4, 7, 10] 
    downvotes: [2, 5, 8]
}

3) Conversely, downvoting provides me with data on numbers that are maligned with each other by comparing a given thread's upvote array with its downvote array.

//Strong malignments: 1,2; 1,8; 10,2; 10,8
//Weak malignments: 1,5; 1,9; 3,2; 3,8; 7,8; 10,9
thread1 = {
    upvotes: [1, 3, 4, 10]
    downvotes: [2, 5, 8, 9]
}
thread2 = {
    upvotes: [1, 3, 7, 10]
    downvotes: [2, 6, 8, 9]
}
thread3 = {
    upvotes: [1, 4, 7, 10] 
    downvotes: [2, 5, 8]
}

I'd like to assign members to a numerical point on a spectrum between 0 and 1 based on their alignments and malignments. So, for example, if user1 becomes predictable in her voting in that when we see user3, user6 and user9 upvote a thread we can consistently guess that user1 will eventually upvote that same thread, then we can say that user1 is strongly aligned and therefore has earned a place pretty close to 0--for example, .123.

I should clarify that we know the user1 is closer to 0 and not to 1 based on her consistent malignment with user2, user4 and user12, whose downvotes typically predict an upvote from user1. In this way the assignment of 0 and 1 are arbitrary but fixed once established.

How might you implement a program that processes arrays of numbers in a way that assigns users an 'alignment' value base on their coincidence with other numbers? Solutions in Javascript or even Typescript are preferred, but this question is generally language agnostic as this process will not be integrated with the application itself. Pseudo-code is welcome.



via J. Adam Connor

No comments:

Post a Comment