algorithm
popularity decay
website posts
ranking system
data analysis

Popularity decay algorithm for popular website posts

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

In the digital age, the visibility of content often correlates with its popularity. Websites and social media platforms continually strive to present users with engaging and current content. However, as posts accumulate, managing their visibility becomes complex. Enter the popularity decay algorithm—a crucial method to prioritize content by both popularity and time-sensitivity. This algorithm ensures that users are exposed to not only the most popular but also the most relevant content.

Core Concept

The popularity decay algorithm modifies the numerical score that determines a post's visibility by applying a decay function over time. The core assumption is that the popularity of an item fades as it ages, thus older posts must be significantly more popular than newer ones to achieve the same visibility.

Mathematical Representation of Popularity Decay

Let's consider a basic function to represent this concept:

P(t)=P_0×eλtP(t) = P\_0 \times e^{-\lambda t}

Where: • P(t)P(t) is the popularity score at time tt. • P0P_0 is the initial popularity score. • λ\lambda is the decay constant. • ee represents the base of the natural logarithm.

The decay constant λ\lambda determines the rate at which popularity decays over time. A higher value of λ\lambda signifies faster decay, making the post less visible as it ages.

Implementing Popularity Decay in Algorithms

Step-by-Step Example

We'll illustrate the implementation through a simplified example:

  1. Initial Scoring: A post is assigned an initial score based on upvotes, comments, and shares.
  2. Decay Application: The score decreases exponentially with time.
  3. Visibility Ranking: Posts are ranked in a feed based on their calculated score P(t)P(t).

Consider the scenario where a post receives an initial score P0=150P_0 = 150 at time t=0t=0. If λ=0.1\lambda = 0.1, the score after 10 hours will be:

P(10)=150×e0.1×1055.37P(10) = 150 \times e^{-0.1 \times 10} \approx 55.37

This reduction emphasizes newer posts while still allowing exceptionally popular older content to remain visible.

Comparative Table

Below is a hypothetical comparison of two posts with different initial scores and decay observations:

| Post | Initial Score $ P_0 $ | Decay Constant $\lambda$ | Score after 10 hrs P(10)P(10) | | | ---------- | ----------------------------- | --------------------------------- | ----------------------------------- | | Post A | 150 | 0.1 | 55.37 | | Post B | 200 | 0.1 | 73.83 |

As the table indicates, "Post B" retains a higher influence due to its superior initial engagement despite the same rate of decay.

Additional Considerations

Selection of Decay Constant

The choice of λ\lambda is crucial and depends on: • Content Frequency: Platforms with frequent posts might use a higher λ\lambda. • Engagement Dynamics: Slow engagement platforms might benefit from a lower decay rate. • Content Type: News articles might decay faster compared to timeless tutorials.

Popularity Boosters

To maintain dynamic engagement, platforms might include: • Re-boosting: A surge in interactions resets or adjusts the decay. • Content Typology: Allow different decay rates for varied content types.

Each of these methods influences how content is dynamically prioritized and helps retain user interest effectively.

Conclusion

The popularity decay algorithm ensures content relevancy by systematically decreasing visibility as content ages. As digital spaces become increasingly saturated, such algorithms are vital in crafting an engaging user experience. By expertly balancing the interplay between immediate popularity and time dynamics, platforms manage to deliver relevant content to users efficiently. Deploying such algorithms with appropriate metrics and variations can significantly enhance user engagement and satisfaction.


Related reading
Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.