
Implementing a Video Trending Score Algorithm
Introduction Not all popular videos are trending. A video with 100 million views that got them over 5 years isn't trending. A video with 500,000 views that got them in the last 6 hours is. The difference is velocity , and building a proper trending score algorithm is essential for any video platform. Here's how I built it for ViralVidVault . The Formula Our trending score combines three time-decayed factors: trending_score = ( velocity_score * 0.4 ) + ( engagement_score * 0.35 ) + ( recency_score * 0.25 ) Each component is normalized to 0-100 before weighting. Implementation <?php class TrendingScorer { private const VELOCITY_WEIGHT = 0.40 ; private const ENGAGEMENT_WEIGHT = 0.35 ; private const RECENCY_WEIGHT = 0.25 ; // Half-life in hours for time decay private const HALF_LIFE_HOURS = 12 ; public function score ( array $video , array $previousMetrics = []): float { $velocity = $this -> velocityScore ( $video , $previousMetrics ); $engagement = $this -> engagementScore ( $video ); $re
Continue reading on Dev.to Tutorial
Opens in a new tab
