remove anti voters, extend post vote lifetime to 90 days, add minimum score threshold for super voters

This commit is contained in:
r888888888
2016-09-23 11:03:09 -07:00
parent c8c99e9b9c
commit 09ec2dfc08
5 changed files with 7 additions and 39 deletions

View File

@@ -1,6 +1,8 @@
require "set"
class PostVoteSimilarity
THRESHOLD = 0.08
class Element
attr_reader :user_id, :score
@@ -20,19 +22,6 @@ class PostVoteSimilarity
@user_id = user_id
end
# returns user ids with strong negative correlation
def calculate_negative(limit = 10)
posts0 = PostVote.negative_post_ids(user_id)
set = SortedSet.new
PostVote.positive_user_ids.each do |uid|
posts1 = PostVote.positive_post_ids(uid)
set.add(Element.new(uid, calculate_with_cosine(posts0, posts1)))
end
set.first(limit)
end
# returns user ids with strong positive correlation
def calculate_positive(limit = 10)
posts0 = PostVote.positive_post_ids(user_id)
@@ -40,7 +29,10 @@ class PostVoteSimilarity
PostVote.positive_user_ids.each do |uid|
posts1 = PostVote.positive_post_ids(uid)
set.add(Element.new(uid, calculate_with_cosine(posts0, posts1)))
score = calculate_with_cosine(posts0, posts1)
if score >= THRESHOLD
set.add(Element.new(uid, score))
end
end
set.first(limit)