Remove super voters.

This commit is contained in:
evazion
2020-02-23 17:46:13 -06:00
parent 1591df0351
commit ce11485fe0
17 changed files with 18 additions and 267 deletions

View File

@@ -11,7 +11,6 @@ module DanbooruMaintenance
safely { PostDisapproval.prune! }
safely { PostDisapproval.dmail_messages! }
safely { regenerate_post_counts! }
safely { SuperVoter.init! }
safely { TokenBucket.prune! }
safely { TagChangeRequestPruner.warn_all }
safely { TagChangeRequestPruner.reject_all }

View File

@@ -1,60 +0,0 @@
require "set"
class PostVoteSimilarity
THRESHOLD = 0.05
class Element
attr_reader :user_id, :score
def initialize(user_id, score)
@user_id = user_id
@score = score
end
def <=>(other)
score <=> other.score
end
end
attr_reader :user_id
def initialize(user_id)
@user_id = user_id
end
# returns user ids with strong positive correlation
def calculate_positive(limit = 10)
posts0 = PostVote.positive_post_ids(user_id)
set = []
PostVote.positive_user_ids.each do |uid|
posts1 = PostVote.positive_post_ids(uid)
score = calculate_with_jaccard(posts0, posts1)
if score >= THRESHOLD
set << Element.new(uid, score)
end
end
set.sort.reverse.first(limit)
end
def calculate_with_jaccard(posts0, posts1)
a = (posts0 & posts1).size
div = posts0.size + posts1.size - a
if div == 0
0
else
a / div.to_f
end
end
def calculate_with_cosine(posts0, posts1)
a = (posts0 & posts1).size
div = Math.sqrt(posts0.size * posts1.size)
if div == 0
0
else
a / div
end
end
end