Sub topic 5
Predicting likes, comments, shares, and hides
This chapter assumes you know how to use social media apps, understand probability as a number from 0 to 1, and can read short Python code. You do not need to know how to train a machine-learning model.
What the prediction model does
A feed ranker usually does not ask one question, such as “Will this person like the post?” It estimates several possible actions:
- A like or other positive reaction
- A comment
- A share or repost
- A click, view, or long reading session
- A hide, unfollow, report, or quick exit
Each estimate is a probability. For example, a model might estimate that a user has a 0.35 probability of liking a post and a 0.04 probability of commenting on it.
A model makes these estimates for a particular user, post, and context. An impression is one occasion when the post is shown to the user. The training data records what happened after many past impressions.
The model might use features such as:
- The user's past interactions with similar topics
- Whether the user follows the author
- The author's relationship to the user
- The post's language, topic, format, and age
- Whether the user is currently on a mobile device
- How much time the user usually spends in the app
- Recent actions, such as hiding several posts about a topic
The model should predict actions separately. A post can attract many views but few comments. Another post can receive few likes but many reports. Combining these outcomes too early hides important differences.
A small prediction example
Real platforms use trained models and far more features. This example shows the shape of the calculation. A sigmoid function converts a weighted sum into a number between 0 and 1.
import math
def probability(bias, weights, features):
total = bias
for name, weight in weights.items():
total += weight * features.get(name, 0.0)
return 1 / (1 + math.exp(-total))
features = {
"follows_author": 1.0,
"topic_interest": 0.8,
"post_age": -0.2,
"recent_hides": 0.0,
}
like_probability = probability(
bias=-1.0,
weights={
"follows_author": 1.2,
"topic_interest": 1.5,
"post_age": 0.4,
"recent_hides": -1.0,
},
features=features,
)
hide_probability = probability(
bias=-2.0,
weights={
"follows_author": -0.6,
"topic_interest": -1.0,
"post_age": 0.1,
"recent_hides": 1.4,
},
features=features,
)
print(f"like={like_probability:.3f}")
print(f"hide={hide_probability:.3f}")The weights are illustrative. A positive weight raises the model's estimate when its feature increases. A negative weight lowers it. Separate models can use different features and weights. For instance, comment prediction may depend strongly on conversation history, while hide prediction may depend more on previous negative feedback.
Common errors and limits
A prediction is not a fact about the user. It is an estimate based on incomplete evidence. Several problems can make it unreliable:
- Biased labels: A visible like is easier to record than silent satisfaction or dissatisfaction.
- Delayed actions: A user may share a post hours after seeing it, so the system must choose an observation window.
- Conflicting actions: A user may like a post and report it. Each outcome needs its own label.
- Popularity bias: Models trained on popular posts may learn to favor popularity rather than quality.
- Changing behavior: A user's interests, device, or social relationships can change.
- Feedback from the feed: If a post is never shown, the system cannot observe whether the user would have liked it.
A ranking system should also avoid treating every predicted action as equally valuable. A hide or report may be a strong negative signal, while a brief view may be weak evidence. The next stage combines predictions with product goals, safety rules, and freshness.
Exercise
Why might a feed use separate models for likes and hides instead of one “engagement” model?
Show answer
Likes and hides represent different outcomes. Separate models preserve that distinction so later scoring and safety rules can reward or penalize them differently.