Git Product home page Git Product logo

trending's Introduction

Trending

How to determine trending items

The code spots the trending items for a given time period. Below I explain that how trendiness is determined.

Trendiness: Item is a trending item when it is mentioned (purchased, cliked, viewed,etc) more often than usual.

Algorithm: rolling z-score

This is the standard algorithm to find trending items and is simple to implement:

z=(x-\mu)/\sigma,

where \mu is the history mean and \sigma is the standard deviation of the history data. In the following code, for every point, the above formula is re-applied with a decay factor so that the oldest points carry the less factor value.

When a z-score is used, the higher or lower the z-score the more abnormal the trend, so for example if the z-score is highly positive then the trend is abnormally rising, while if it is highly negative it is abnormally falling. Hence, the z-score for all the candidate trends the highest top_n z-scores will relate to the most abnormally increasing z-scores.

Note: * You can user this trending method with a sliding window, for instance last 10-day transaction, if you wish to use the recent transaction and not take much historical data into account. This can be done by cutting down on the transaction time of the original data.

Dependencies

  • math
  • seasonal
  • mathplotlib
  • pandas
  • numpy
  • datetime

Author:

Ali Nadaf, PhD
Data Scientist
<[email protected]>

References:

  1. https://vincent.is/finding-trending-things/
  2. https://www.isixsigma.com/tools-templates/statistical-analysis/improved-forecasting-moving-averages-and-z-scores/

trending's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.