Sub topic 6
Turning Predictions into One Score
A feed ranker often predicts several possible actions for each post. This chapter assumes that you understand probability as a number from 0 to 1 and can read short Python code. The important step here is combining those predictions into one value so posts can be ordered.
Why one score is useful
A model might estimate that a person has:
- A 0.30 probability of liking a post
- A 0.02 probability of commenting
- A 0.01 probability of hiding it
These predictions measure different actions. The system still needs one ranking value. A weighted score is a number made by multiplying each prediction by a chosen importance, then adding the results.
Weights express the product goal. A comment may be more valuable than a like because it indicates deeper participation. A hide may be harmful, so its weight is negative.
| Predicted action | Probability | Example weight | Contribution |
|---|---|---|---|
| Like | 0.30 | 1.0 | 0.30 |
| Comment | 0.02 | 4.0 | 0.08 |
| Hide | 0.01 | -10.0 | -0.10 |
The total predicted value is 0.30 + 0.08 - 0.10 = 0.28. This is not a percentage and does not mean that the user will produce exactly 0.28 actions. It is a value for comparing posts.
Adding freshness
A post's value can decline as it becomes older. One simple approach is exponential decay, where the score is multiplied by a factor that falls at a fixed rate.
For example, a half-life of six hours means the freshness factor is:
- 1.0 when the post is new
- 0.5 after six hours
- 0.25 after twelve hours
- 0.125 after eighteen hours
The final score is:
engagement value × freshness factor
A highly engaging older post may still outrank a weak recent post. Freshness is one factor, not an automatic winner.
from dataclasses import dataclass
@dataclass
class Post:
id: str
author: str
age_hours: float
p_like: float
p_comment: float
p_hide: float
# Illustrative weights, not any real platform's values.
WEIGHTS = {"like": 1.0, "comment": 4.0, "hide": -10.0}
def score(post: Post) -> float:
value = (
WEIGHTS["like"] * post.p_like
+ WEIGHTS["comment"] * post.p_comment
+ WEIGHTS["hide"] * post.p_hide
)
freshness = 0.5 ** (post.age_hours / 6) # halves every 6 hours
return value * freshness
posts = [
Post("a", "ana", 1, 0.30, 0.02, 0.01),
Post("b", "ben", 12, 0.60, 0.10, 0.01),
Post("c", "cy", 2, 0.10, 0.01, 0.05),
]
for post in sorted(posts, key=score, reverse=True):
print(post.id, round(score(post), 3))The sorted call places the greatest score first. The weights and six-hour half-life are illustrative. A real system would learn or tune them using historical data, experiments, and product policy.
Choosing weights carefully
Weights create trade-offs. Increasing the comment weight favors discussion, but it may also favor controversial posts that provoke replies. Making the hide penalty larger suppresses posts that appear risky, but an inaccurate hide prediction can remove useful content.
Predictions should also be reasonably calibrated. A calibrated probability of 0.20 means that about 20 percent of similar impressions should produce that action over time. If one model consistently predicts higher values than another, raw probabilities may not be safe to combine without adjustment.
A single score can hide important choices. Teams should inspect:
- Which behaviors receive positive or negative value
- Whether the score favors short-term reactions over long-term satisfaction
- Whether different groups receive systematically different content
- How often safety or quality rules override the score
Exercise
A post has an engagement value of 0.40 and is 12 hours old. The freshness factor halves every 6 hours. What is its final score?
Show answer
The freshness factor is 0.25 after two six-hour periods, so the final score is 0.40 × 0.25 = 0.10.