“It’s always about timing. If it’s too soon, no one understands. If it’s too late, everyone’s forgotten.”

— Anna Wintour

What is Trends? Trends is an analysis of collecting information and attempting to spot a pattern. How can one capture trends- In an e-commerce setup like 1mg, an item or product is trending when it is interacted with(purchased, clicked, add to cart, viewed, searched, etc.) more often than usual.

For your easy read, we are going to structure this blog in the following parts: Part 1: In this part, we will discuss the objective of showing trending items and products to the users by answering the following questions:

This will help us understand what ‘Trends’ really are. Part 2: In this part, we will discuss the strategy/algorithms involved. Part 3: In this part, we will discuss the drawbacks of our strategy. Part 4: In this part, we will discuss the challenges we faced while working on ‘Trends’. Part 5: In this part, we will share concluding remarks.

I. Understanding Trends Ideology

If we ruminate, here are the people we are trying to show the trends to:• Customers: Users can utilize Trends in multiple ways-One is staying aware of growing occurrences of conditions or diseases so that they can take preventive measures. Another could be that these trends could help them gain knowledge about the conditions or diseases.• Sellers: Trends could be sudden spikes that are difficult to assess based on past demand. Therefore, If demand for a particular item is growing it will help concerned sellers/vendors can be prepared with adequate stock.

There are some additional benefits of showing trending products:

In order to have a clear understanding of trends, it is important to note the difference between trending products and top-selling products.

To get a better understanding of trends, it is important to get the difference between trending products and top-selling products. The table below lists some common differences which make these two ideologies come up with different products altogether.

II. Strategy/ Algorithm: Rolling-Zscore

Strategy to find Trending Products? To find the trendiness of a product one can take indicators such as Add To Cart, Product Page Views, Product Sales, etc., or can develop a weighted function of these indicators. To keep things simple and highly accurate, we take product sales as an indicator to define the trendiness of a product.

Trending is equivalent to an anomaly detection where there is a sudden change from the usual pattern.

Methodology: Rolling-Zscore/ Moving-Zscore: Indicates the change in the current week’s sales from past w weeks’ mean sales by a number of standard deviations in the window of size w.

Rolling Z-Score

where the (Xi) moving means and moving standard deviation (Si) is

Formula: Moving Means and Std.

After calculation of Rolling-Zscore, we sort items on basis of rolling-zscore and pickup top-k (for us we have kept k=30) items from the list.

Rolling-Zscore is simple to implement and works in real time with low computation costs. It is a good indicator to find which product is oversold or overbought. This strategy also gives good exposure to products that had low sales in the past, resulting in improvement in the diversification of products on our platform.

Top All India Trending Products for the 3rd week of March 2020.

Dummy ZScore Data for the 3rd week of March

This strategy of Rolling-ZScore gives us trending products that are relevant and explainable to the COVID-19 scenario.

Trending List 3rd week March | During COVID-19

Trending List of 4th week of March 2020 | During COVID-19

Let us try to unwrap the reasons why these products are showing up in the trending category:

III. Drawbacks of using Rolling-Zscore

Rolling-Zscore helps us easily identify products for which sales were previously low but there is a significant jump in the current time.

Rolling-Zscore fails to give exposure to our top-selling products such as Shelcal (Vitamin D Tablet) or Neurobion Forte ( MutliVitmamin Tablet). These products would never be able to come in the trending products category even if their current sales are higher than past sales because their relative ranking as per their Z Score would be lesser than other products due to a much higher denominator.

IV. Challenges faced

V. Conclusion

Today, we show this trending list in two spaces: on the homepage and on the search bar (app only). With this strategy of Rolling-Zscore, we are able to find top-50 most trending products from more than 2 lakh products in just 3 minutes, allowing us with real-time trend analysis at a low computation cost.

I hope you enjoyed my blog and learned something new. Want to discuss it further? Connect with me here.


MyNewsletter on LinkedIn is now read by more than 4500+ subscribers. If you are building an AI or a data product or service, you are invited to become a sponsor of one of the future newsletter issues. Feel free to reach out to [email protected] for more details on sponsorships.

I am nominated for the HackerNoon 2022 Noonies, Vote for me:

HackerNoon Contributor of the Year - Data||

Data Science Demon


Also published here.


Connect 1:1 Meeting here: https://topmate.io/shaurya

I am open to Consults you can reach out to me on LinkedIn.

Data Science Book Recommendations:

[1] The Book of Why

[2] Naked Statistics