Capturing Trends in HealthCare at 1mg (E-pharmacy Unicorn)

Written by shauryauppal | Published 2022/09/09
Tech Story Tags: healthcare | datascience | analytics | data-science | machine-learning | ai-trends | recommendation-systems | data-analytics | web-monetization

TLDRAn item or product is trending when it is interacted with(purchased, clicked, add to cart, viewed, searched, etc.) more often than usual. Trending products will help sellers/vendors be prepared with adequate stock. It is difficult for brands introducing new products to enhance visibility for their catalog against the market that is swarmed with popularly purchased and highly viewed goods. A trending list will also bring.competition to the market. Brands could improve product visibility by coming up with different attractive offers to increase demand.via the TL;DR App

“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:

  • Who is the target audience?
  • What is the difference between trending products and top-selling products?

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:

  • It is difficult for brands that are introducing new products to enhance visibility for their catalog against the market that is swarmed with popularly purchased and highly viewed goods. A trending list will also bring competition to the market. Brands could improve product visibility by coming up with different attractive offers to increase demand.

  • Diversity is one of the objectives of any E-Commerce Recommendation Engine. Changing seasons makes different products relevant and instead of developing rules to identify relevant products for various seasons, trends could be used to come up with interesting recommendations and thereby bring diversity through seasonality. For example Masks, Giloy, Sanitizer, Tulsi Drop, etc. are currently trending among people to fight Coronavirus.

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 of 3rd week of March 2020

Trending List 3rd week March | During COVID-19

  • Trending List of 4th week of March 2020

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:

  • Giloy Tablets, Amruth, Tinospora Cordifolia Mother Tincture Q, and Tulasi drop help people to boost their immunity.
  • Thermometer sales rise because it enables people to check their body temperature.
  • Crocin and Paracetamol Tablets sales rise up because of cold-flu (weather change).
  • Hand Wash and Alcohol Swab help people to protect themselves from bacteria and viruses.

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

  • The basic idea behind trendiness is the rate of change in sales of a product in a given time frame. It may often happen that due to stock unavailability of product it past week's mean sales are very low and when the product becomes available a sudden sales jump is observed and the z-score catches it as trending. To tackle such scenarios a proper statistical justified threshold has to be set on rolling-mean sales.

  • The setting of a correct window w size is very important. It also depends on the product call, regarding how long you would like to show a product as a trending one. Example: During the starting weeks of May, we captured prickly heat powder as trending but by the end of May the product no longer remains trending as it transits to the category of top-seller product. To capture plateau one has to tinker with the window size.

    • To capture the short-term trend: compare 3 days to 5 days of sales with the past 10 days means sales.
    • To capture the mid-size term trend: compare 1 week’s sales with the past 3 to 4 weeks’ mean sales.
    • To capture a long-term trend: compare 1 month’s sales with the past 3 to 4 months’ mean sales.

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 shauryauppal97@gmail.com 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


Written by shauryauppal | Data Scientist | Applied Scientist | Research Consultant | Startup Builder
Published by HackerNoon on 2022/09/09