Sample Weighting in Machine Learning: From YouTube Playback Duration to Game Recommendation Optimization
This article explains why and how sample weighting is used in machine learning, illustrates YouTube's conversion of video watch time into sample weights to align with its commercial goals, and describes practical weighted‑logistic‑regression techniques applied to improve game recommendation systems.
In machine learning we often need to weight samples to emphasize certain data, a purpose similar to over‑/under‑sampling, and this article introduces sample weighting, shows how YouTube converts playback duration into sample weights to meet its business objectives, and presents a game‑recommendation use case.
Why weight samples? Three perspectives are considered:
Business needs – give higher weight to samples that matter more for revenue, e.g., large orders in e‑commerce or high‑value purchases in games.
Data perspective – strengthen learning for under‑represented classes when the data distribution is imbalanced.
Model perspective – adjust sample importance for algorithms such as AdaBoost that focus on mis‑classified instances.
Weighting can be achieved by either duplicating positive samples according to their weight and training a standard logistic regression, or by modifying the gradient during training so that the loss is multiplied by the sample weight (weighted LR). Using a 10× weight example, the first method repeats a sample ten times, updating the gradient ten times, while the second method applies a single 10× gradient update.
Although the two approaches differ in implementation, their results are similar; the gradient‑weight method is much faster in practice.
YouTube's use of playback time as sample weight
YouTube's 2016 paper "Deep Neural Networks for YouTube Recommendations" shows that the platform optimizes for user watch time because ad revenue is proportional to it. The problem is not a simple click‑through‑rate prediction; regression is unsuitable because it can predict negative watch times. Instead, YouTube trains a weighted logistic regression where the output directly models expected watch time.
The weighted logistic regression can be expressed as:
and after algebraic transformation the model predicts the expected watch time, i.e., the probability of a video being watched multiplied by its duration. Experiments show that using watch‑time weighting reduces loss from 38.7% to 34.6% (a 4.1% improvement) on a 1024→512→256 network.
Weighted optimization in game recommendation
In game recommendation the business goal is to maximize revenue from in‑game items, so the optimization target is the expected revenue rather than purchase rate. Similar to YouTube, each positive sample is weighted proportionally to the user’s spend on that item (price × quantity), not merely the price or quantity alone.
Unlike YouTube, the probability p of a user selecting a specific game item is not near zero, so the denominator w·p in the weighting formula is not negligible, which can cause instability (e.g., w·p > 1 leading to negative predictions). To mitigate this, the impact of w can be reduced by taking its square root or logarithm, with stronger reduction for items with fewer occurrences. This adjustment yields a more stable model with better performance than using raw spend‑based weights.
Conclusion
Applying sample weights according to business objectives can significantly improve recommendation models across domains; many machine‑learning libraries support a sample‑weight parameter, so practitioners should experiment with weighting to discover potential gains.
NetEase LeiHuo UX Big Data Technology
The NetEase LeiHuo UX Data Team creates practical data‑modeling solutions for gaming, offering comprehensive analysis and insights to enhance user experience and enable precise marketing for development and operations. This account shares industry trends and cutting‑edge data knowledge with students and data professionals, aiming to advance the ecosystem together with enthusiasts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.