Giter VIP home page Giter VIP logo

market-basket-analysis-using-sql's Introduction

market-basket-analysis-using-SQL

Hello,

You might ask why did you implement market basket analysis in SQL when we can do this in R or Python with ready libraries?

My answer: I was not allowed to use other tools. I had to schedule this script after weekly dataload and we use only SQL agent job for scheduling. So I decided to do this within SQL environment based on business needs. It was a good challenge and eventually everyone was very happy with the output. Note: this script might have deviated from classic market basket analysis based on what business analysts wanted to see.

Definitions: Key metrics for association rules:

  1. Support: Percentage of orders that contain the item set. It is a measure of how frequently the collection of items occur together as a percentage of all transactions. For instance, there are 11 orders in total(by different customers) and {bread, butter} occurs together in 3 of them. So, Support(Bread, Butter)=3/11.

  2. Confidence: Given two items, X and Y, confidence measures the percentage of times that item Y is purchased, given that item X was purchased. This is expressed as: Confidence(Y|X) = Freq(X, Y)/Freq(X) This does not tell there is a relationship between two items. The next matric is the one that can tell about it.

  3. Lift: Lift(X, Y) = Support(X,Y)/[Support(X) * Support (Y)] . Lift is the ratio of confidence to the expected confidence. It tells how much our confidence has increased that B will be purchased given that A was purchased.

    Lift=1 implies that there is no relationship between X and Y. Lift > 1 implies that there is a positive relationship between X and Y. Lift < 1 implies that there is a negative relationship between X and Y.

market-basket-analysis-using-sql's People

Contributors

bunyodjon avatar

Watchers

James Cloos avatar  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.