Declare winner in update points worker (#11974)

* Declare winner in update points worker

* Remove tests

* Fix finalized_points style issue
This commit is contained in:
Ben Halpern 2020-12-21 12:59:54 -05:00 committed by GitHub
parent 3dae3ff797
commit 5cd947336b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 49 deletions

View file

@ -35,7 +35,7 @@ module Follows
tags = articles.pluck(:cached_tag_list).compact.flat_map { |list| list.split(", ") }
occurrences = tags.count(tag.name)
bonus = inverse_popularity_bonus(tag)
finalized_points(occurrences, bonus, user)
finalized_points(occurrences, bonus)
end
def adjust_other_tag_follows_of_user(user_id)
@ -64,22 +64,8 @@ module Follows
top_100_tag_names.index(tag.name) || (top_100_tag_names.size * 1.5)
end
def finalized_points(occurrences, bonus, user)
test_variant = field_test(:follow_implicit_points, participant: user)
case test_variant
when "no_implicit_score"
0
when "half_weight_after_log"
Math.log(occurrences + bonus + 1) * 0.5
when "double_weight_after_log"
Math.log(occurrences + bonus + 1) * 2.0
when "double_bonus_before_log"
Math.log(occurrences + (bonus * 2) + 1)
when "without_weighting_bonus"
Math.log(occurrences + 1)
else # base - Our current "default" implementation
Math.log(occurrences + bonus + 1) # + 1 in all cases is to avoid log(0) => -infinity
end
def finalized_points(occurrences, bonus)
Math.log(occurrences + bonus + 1) # + 1 in all cases is to avoid log(0) => -infinity
end
def cached_app_wide_top_tag_names

View file

@ -1,9 +1,22 @@
experiments:
follow_implicit_points: # Points given for implicit tag weights
# Implemented here: app/workers/follows/update_points_worker.rb
# TEST FINISHED
# Hypotheses: Weighting tags based on implied preference will lead
# to more repeat engagement.
# Recommended duration: 4 weeks (ending at start of January)
# OUTCOME:
# It was observed that "base" has been consistently ahead in comments and
# "four hours of article reads in day" by 10% to 20% over no_implicit_score
# but over time this began regressing towards the mean and seeming more random.
# In inspecting the ways we are measuring goals here, anything with a low barrier
# will eventually be reached (aka leave one reaction) by most users, so over time
# these goals demonstrate less value.
# So this test is being cut off on the observation of a clear winner early on
# with the note that we need tests which can map better to the duration of the test.
# This experiment is no longer running in production, but can remain configured here
# while there are no other experiments running.
variants:
- base
- no_implicit_score

View file

@ -82,36 +82,5 @@ RSpec.describe Follows::UpdatePointsWorker, type: :worker do
expect(follow.reload.points).to be > original_points # should be higher because tag is now less popular
end
context "with field tests in place" do
# regressions testing a few field test scenarios
it "returns zero if no_implicit_score field test" do
create(:field_test_membership,
experiment: :follow_implicit_points, variant: "no_implicit_score", participant_id: user.id)
follow = Follow.last
follow.update_column(:explicit_points, 2.2)
worker.perform(reaction.reactable_id, reaction.user_id)
follow.reload
expect(follow.implicit_points).to eq 0
end
it "returns double if double_weight_after_log field test" do
create(:field_test_membership,
experiment: :follow_implicit_points, variant: "double_weight_after_log", participant_id: user.id)
follow = Follow.last
worker.perform(reaction.reactable_id, reaction.user_id)
follow.reload
expect(follow.implicit_points).to be_within(0.9).of(2)
end
it "returns double if half_weight_after_log field test" do
create(:field_test_membership,
experiment: :follow_implicit_points, variant: "half_weight_after_log", participant_id: user.id)
follow = Follow.last
worker.perform(reaction.reactable_id, reaction.user_id)
follow.reload
expect(follow.implicit_points).to be_within(0.7).of(0.5)
end
end
end
end