SlideShare a Scribd company logo
1 of 30
Presented by: Derek Kane
 Association Rules
 Basic Terminology
 Support
 Confidence
 Lift
 Apriori Algorithm
 Practical Examples
 Grocery Shopping Basket Analysis
 Voting Patterns in the House of Representatives
 A series of methodologies for discovering
interesting relationships between variables in a
database.
 The outcome of this technique, in simple terms, is
a set of rules that can be understood as “if this,
then that”.
 An example of an association rule would be:
 If a person buys Peanut Butter and Bread then
they will also purchase Jelly.
Applications
 Product recommendation
 Digital Media recommendations
 Politics
 Medical diagnosis
 Content optimisation
 Bioinformatics
 Web mining
 Scientific data analysis
 Example: The analysis of earth science data may reveal interesting connections
among the ocean, land, and atmospheric processes. This may help scientists to
better understand how these systems interact with one another.
 For example, maybe people who buy flour and casting sugar, also tend to buy
eggs (because a high proportion of them are planning on baking a cake).
 A retailer can use this information to inform:
 Store layout (put products that co-occur together close to one another, to
improve the customer shopping experience).
 Marketing (e.g. target customers who buy flour with offers on eggs, to
encourage them to spend more on their shopping basket).
 Retailers can use these type of rules to identify new opportunities for cross
selling/upselling their products to their customers.
 Asked engineers and scientists around the world
to solve what might have seemed like a simple
problem: improve Netflix's ability to predict what
movies users would like by a modest 10%.
 From $5 million revenue in 1999 reached $3.2
billion revenue in 2011 as a result of becoming
an analytics competitor.
 By analyzing customer behavior and buying
patterns created a recommendation engine
which optimizes both customer tastes and
inventory condition.
 A rule is typically written in the following format: { i1, i2 } => { ik }
 The { i1, i2 } represents the left hand side, LHS, of the rule and the { ik }
represents the right hand side, RHS.
 This statement can be read as “if a user buys an item in the item set on the left
hand side, then the user will likely buy the item on the right hand side too”.
 A more human readable example is:
{coffee, sugar} => {milk}
 If a customer buys coffee and sugar, then they are also likely to buy milk.
 Before we can begin to employ association rules, we must first understand three
important ratios; the support, confidence and lift.
 Support: The fraction of which our item set occurs in our dataset.
 Confidence: Probability that a rule is correct for a new transaction with items on the
left.
 Lift: The ratio by which by the confidence of a rule exceeds the expected confidence.
 The support of an item or item set is the fraction of transactions in our data set
that contain that item or item set.
 Ex. A grocer has 15 transactions in total. Of which, Peanut Butter => Jelly appears
6 times. The support for this rule is 6 / 15 or 0.40.
 In general, it is nice to identify rules that have a high support, as these will be
applicable to a large number of transactions.
 Support is an important measure because a rule that has a low support may occur
simply by chance. A low support rule may also be uninteresting from a business
perspective because it may not be profitable to promote items that are seldom
bought together. For these reasons, support is often used to eliminate
uninteresting rules.
 For super market retailers, this is likely to involve basic products that are popular
across an entire user base (e.g. bread, milk). A printer cartridge retailer, for
example, may not have products with a high support, because each customer only
buys cartridges that are specific to his / her own printer.
 The confidence of a rule is the likelihood that it is true for a new transaction that
contains the items on the LHS of the rule. (I.e. it is the probability that the
transaction also contains the item(s) on the RHS.) Formally:
 Confidence(X -> Y) = Support(X ꓴ Y) / Support (X)
 Confidence(Peanut Butter => Jelly) = 0.26 / 0.40 = 0.65
 This means that for 65% of the transactions that contain Peanut Butter and Jelly,
the rule is correct.
 Confidence measures the reliability of the inference made by a given rule. For a
given rule X -> Y, the higher the confidence the more likely it is for Y to be present
in transactions that contain X.
 Association analysis results should be interpreted with caution. The inference
made by an association rule does not necessarily imply causality. Instead, it
suggests a strong co-occurance relationship between the items in the antecedent
and consequent of the rule.
 The lift of a rule is the ratio of the support of the items on the LHS of the rule co-
occuring with items on the RHS divided by probability that the LHS and RHS co-
occur if the two are independent.
 Lift (X -> Y) = Support(X ꓴ Y) / ( Support (Y) * Support (X) )
 Lift (Peanut Butter => Jelly) = 0.26 / (0.46 * 0.40) = 1.4
 If lift is greater than 1, it suggests that the presence of the items on the LHS has
increased the probability that the items on the right hand side will occur on this
transaction.
 If the lift is below 1, it suggests that the presence of the items on the LHS make the
probability that the items on the RHS will be part of the transaction lower.
 If the lift, is 1 it indicates that the items on the left and right are independent.
 When we perform market basket analysis, then, we are looking for rules with a lift
of more than one and preferably with a higher level of support.
 The Apriori algorithm is perhaps the best known algorithm to mine association rules.
 Apriori Theorem: “If an itemset is frequent, then all of its subsets must be also be frequent.”
 It uses a breadth first strategy to count the support of item sets and uses a candidate
generation function which exploits the downward closure property of support (anti-
monotonicity).
 The approach follows a 2 step process:
 First, minimum support is applied to find all frequent itemsets in the database.
 Second, these frequent itemsets and the minimum confidence constraint are used to form
rules.
 Finding all frequent itemsets in a database is difficult since it involves searching for
all item combinations. The set of possible item combinations is the power set over
I and has the size of 2n-1.
 The downward-closure property of support allows for efficient search and guarantees that for
a frequent itemset, all of its subsets are also frequent. Additionally, for an infrequent itemset, all
of its supersets must also be infrequent.
 Imagine 10000 receipts sitting on your
table. Each receipt represents a transaction
with items that were purchased. The
receipt is a representation of stuff that
went into a customer’s basket – and
therefore ‘Market Basket Analysis’.
 That is exactly what the Groceries Data Set
contains: a collection of receipts with each
line representing 1 receipt and the items
purchased. Each line is called a transaction
and each column in a row represents an
item.
 For each transaction, there can be only
distinct Item(s) without repeating entries.
This allows for us to create a binary (0,1)
representation whether a particular item
was purchased under a specific
transaction.
 The dataset will need to first be flipped across the horizontal axis in to a cross tabulation.
Notice that the “Items” are now the column headings. This preparation ensures that the
dataset can be read properly into the apriori market basket algorithm.
 The market basket analysis algorithm requires setting a threshold for detecting patterns in
the dataset.
 For this example, we specified a support value of 0.001 (due to the high volume of
receipts and large product offering) and a confidence level of 0.70.
 Additionally, we set the length of the rule not to exceed three elements. This
ensures that the we will have a maximum of 2 items on the LHS and that the
assessment will produce more meaningful insights at a tertiary glance.
 Different businesses will have distribution of items by transaction that look very
different, and so very different support and confidence parameters may be
applicable.
 To determine what works best, organizations need to experiment with different
parameters: as you reduce them, the number of rules generated will increase,
which will give us more to work with.
 However, we will need to sift through the rules more carefully to identify those
that will be more impactful for your business.
 There is no stead fast rule on where to begin so experiment with loose
parameters and go from there.
 To showcase how we can leverage this insight further lets focus in on 3 specific items of
interest:
 Yogurt
 Tropical Fruit
 Bottled Beer.
 We can run the algorithm (with the same thresholds) and specify that these terms are
used as criterion for the RHS of the ruleset generation.
 Now as criterion for the LHS of the ruleset generation.
 Before we use the data to make any kind
of business decision, it is important that
we take a step back and remember
something important:
 The output of the analysis reflects how
frequently items co-occur in transactions.
This is a function both of the strength of
association between the items, and the
way the business has presented them to
the customer.
 To say that in a different way: items might
co-occur not because they are “naturally”
connected, but because we, the people in
charge of the organization, have
presented them together.
 The market basket results can be used to drive targeted marketing campaigns.
 For each patron, we pick a handful of products based on products they have bought
to date which have both a high uplift and a high margin, and send them a e.g.
personalized email or display ads etc.
 How we use the analysis has significant implications for the analysis itself: if we are
feeding the analysis into a machine-driven process for delivering recommendations,
we are much more interested in generating an expansive set of rules.
 If, however, we are experimenting with targeted marketing for the first time, it makes
much more sense to pick a handful of particularly high value rules, and action just
them, before working out whether to invest in the effort of building out that capability
to manage a much wider and more complicated rule set.
 There are a number of ways we can use the data to drive site organization:
 Large clusters of co-occuring items should probably be placed in their own category /
theme.
 Item pairs that commonly co-occur should be placed close together within broader
categories on the website. This is especially important where one item in a pair is very
popular, and the other item is very high margin.
 Long lists of rules (including ones with low support and confidence) can be used to put
recommendations at the bottom of product pages and on product cart pages. The only
thing that matters for these rules is that the lift is greater than one. (And that we pick those
rules that are applicable for each product with the high lift where the product recommended
has a high margin.)
 In the event that doing the above (3) drives significant uplift in profit, it would strengthen the
case to invest in a recommendation system, that uses a similar algorithm in an operational
context to power automatic recommendation engine on your website.
 We will apply the results of
association analysis to the voting
records of members of the United
States House of Representatives. The
data is obtained from the 1984
Congressional Voting Records
Database, which is available at the
UCI machine learning data
repository.
 Each transaction contains
information about party affiliation
along with his or her voting record
on 16 key issues.
Observations:
 A vote in favor of the Physician Pay Freeze indicates a Republican (95%
confidence), a vote against indicates a Democrat (99% confidence).
 The voting patterns are relatively clear in this example with a high degree of
support and confidence. We can see which party favors a specific law without
knowing the contents of the legislation itself.
 Reside in Wayne, Illinois
 Active Semi-Professional Classical Musician
(Bassoon).
 Married my wife on 10/10/10 and been
together for 10 years.
 Pet Yorkshire Terrier / Toy Poodle named
Brunzie.
 Pet Maine Coons’ named Maximus Power and
Nemesis Gul du Cat.
 Enjoy Cooking, Hiking, Cycling, Kayaking, and
Astronomy.
 Self proclaimed Data Nerd and Technology
Lover.
Data Science - Part VI - Market Basket and Product Recommendation Engines

More Related Content

What's hot

Exploratory data analysis with Python
Exploratory data analysis with PythonExploratory data analysis with Python
Exploratory data analysis with PythonDavis David
 
Basics of Statistical decision theory
Basics of Statistical decision theoryBasics of Statistical decision theory
Basics of Statistical decision theoryKindson The Genius
 
Market basketanalysis using r
Market basketanalysis using rMarket basketanalysis using r
Market basketanalysis using rYogesh Khandelwal
 
Text Analytics Presentation
Text Analytics PresentationText Analytics Presentation
Text Analytics PresentationSkylar Ritchie
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine LearningKnoldus Inc.
 
CART – Classification & Regression Trees
CART – Classification & Regression TreesCART – Classification & Regression Trees
CART – Classification & Regression TreesHemant Chetwani
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...Sebastian Raschka
 
Confusion Matrix
Confusion MatrixConfusion Matrix
Confusion MatrixRajat Gupta
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_ASrimatre K
 
Decision Tree and Bayesian Classification
Decision Tree and Bayesian ClassificationDecision Tree and Bayesian Classification
Decision Tree and Bayesian ClassificationKomal Kotak
 
The fundamentals of Machine Learning
The fundamentals of Machine LearningThe fundamentals of Machine Learning
The fundamentals of Machine LearningHichem Felouat
 
Tips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitionsTips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitionsDarius Barušauskas
 
Binary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningBinary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningPaxcel Technologies
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception HandlingMegha V
 
Data Science - Part VIII - Artifical Neural Network
Data Science - Part VIII -  Artifical Neural NetworkData Science - Part VIII -  Artifical Neural Network
Data Science - Part VIII - Artifical Neural NetworkDerek Kane
 
DATA WRANGLING presentation.pptx
DATA WRANGLING presentation.pptxDATA WRANGLING presentation.pptx
DATA WRANGLING presentation.pptxAbdullahAbbasi55
 

What's hot (20)

Exploratory data analysis with Python
Exploratory data analysis with PythonExploratory data analysis with Python
Exploratory data analysis with Python
 
Basics of Statistical decision theory
Basics of Statistical decision theoryBasics of Statistical decision theory
Basics of Statistical decision theory
 
Apriori algorithm
Apriori algorithmApriori algorithm
Apriori algorithm
 
Market basketanalysis using r
Market basketanalysis using rMarket basketanalysis using r
Market basketanalysis using r
 
Text Analytics Presentation
Text Analytics PresentationText Analytics Presentation
Text Analytics Presentation
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine Learning
 
Machine Learning with R
Machine Learning with RMachine Learning with R
Machine Learning with R
 
CART – Classification & Regression Trees
CART – Classification & Regression TreesCART – Classification & Regression Trees
CART – Classification & Regression Trees
 
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...An Introduction to Supervised Machine Learning and Pattern Classification: Th...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Confusion Matrix
Confusion MatrixConfusion Matrix
Confusion Matrix
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_A
 
Decision Tree and Bayesian Classification
Decision Tree and Bayesian ClassificationDecision Tree and Bayesian Classification
Decision Tree and Bayesian Classification
 
The fundamentals of Machine Learning
The fundamentals of Machine LearningThe fundamentals of Machine Learning
The fundamentals of Machine Learning
 
Tips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitionsTips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitions
 
Binary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningBinary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine Learning
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
 
Data Science - Part VIII - Artifical Neural Network
Data Science - Part VIII -  Artifical Neural NetworkData Science - Part VIII -  Artifical Neural Network
Data Science - Part VIII - Artifical Neural Network
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
DATA WRANGLING presentation.pptx
DATA WRANGLING presentation.pptxDATA WRANGLING presentation.pptx
DATA WRANGLING presentation.pptx
 

Similar to Data Science - Part VI - Market Basket and Product Recommendation Engines

Business intelligence
Business intelligenceBusiness intelligence
Business intelligenceGeo Marian
 
6. Association Rule.pdf
6. Association Rule.pdf6. Association Rule.pdf
6. Association Rule.pdfJyoti Yadav
 
Market Basket Analysis of bakery Shop
Market Basket Analysis of bakery ShopMarket Basket Analysis of bakery Shop
Market Basket Analysis of bakery ShopVarunSahdev2
 
What goes with what (Market Basket Analysis)
What goes with what (Market Basket Analysis)What goes with what (Market Basket Analysis)
What goes with what (Market Basket Analysis)Kumar P
 
big data seminar.pptx
big data seminar.pptxbig data seminar.pptx
big data seminar.pptxAmenahAbbood
 
2023 Supervised_Learning_Association_Rules
2023 Supervised_Learning_Association_Rules2023 Supervised_Learning_Association_Rules
2023 Supervised_Learning_Association_RulesFEG
 
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...Smarten Augmented Analytics
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Scienceresearchinventy
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Scienceresearchinventy
 
Market Basket Analysis
Market Basket AnalysisMarket Basket Analysis
Market Basket AnalysisNarayan Vyas
 
Association and Classification Algorithm
Association and Classification AlgorithmAssociation and Classification Algorithm
Association and Classification AlgorithmMedicaps University
 
Products Frequently Bought Together in Stores Using classificat...
Products Frequently Bought Together in Stores               Using classificat...Products Frequently Bought Together in Stores               Using classificat...
Products Frequently Bought Together in Stores Using classificat...hibaziyad99
 
5Association AnalysisBasic Concepts an.docx
 5Association AnalysisBasic Concepts an.docx 5Association AnalysisBasic Concepts an.docx
5Association AnalysisBasic Concepts an.docxShiraPrater50
 
Data Mining Apriori Algorithm Implementation using R
Data Mining Apriori Algorithm Implementation using RData Mining Apriori Algorithm Implementation using R
Data Mining Apriori Algorithm Implementation using RIRJET Journal
 
Cluster2
Cluster2Cluster2
Cluster2work
 

Similar to Data Science - Part VI - Market Basket and Product Recommendation Engines (20)

Unit 4_ML.pptx
Unit 4_ML.pptxUnit 4_ML.pptx
Unit 4_ML.pptx
 
Business intelligence
Business intelligenceBusiness intelligence
Business intelligence
 
BAS 250 Lecture 4
BAS 250 Lecture 4BAS 250 Lecture 4
BAS 250 Lecture 4
 
6. Association Rule.pdf
6. Association Rule.pdf6. Association Rule.pdf
6. Association Rule.pdf
 
Market Basket Analysis of bakery Shop
Market Basket Analysis of bakery ShopMarket Basket Analysis of bakery Shop
Market Basket Analysis of bakery Shop
 
What goes with what (Market Basket Analysis)
What goes with what (Market Basket Analysis)What goes with what (Market Basket Analysis)
What goes with what (Market Basket Analysis)
 
big data seminar.pptx
big data seminar.pptxbig data seminar.pptx
big data seminar.pptx
 
2023 Supervised_Learning_Association_Rules
2023 Supervised_Learning_Association_Rules2023 Supervised_Learning_Association_Rules
2023 Supervised_Learning_Association_Rules
 
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...
What is FP Growth Analysis and How Can a Business Use Frequent Pattern Mining...
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Science
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Science
 
Recommender system
Recommender systemRecommender system
Recommender system
 
Market Basket Analysis
Market Basket AnalysisMarket Basket Analysis
Market Basket Analysis
 
Association and Classification Algorithm
Association and Classification AlgorithmAssociation and Classification Algorithm
Association and Classification Algorithm
 
Products Frequently Bought Together in Stores Using classificat...
Products Frequently Bought Together in Stores               Using classificat...Products Frequently Bought Together in Stores               Using classificat...
Products Frequently Bought Together in Stores Using classificat...
 
5Association AnalysisBasic Concepts an.docx
 5Association AnalysisBasic Concepts an.docx 5Association AnalysisBasic Concepts an.docx
5Association AnalysisBasic Concepts an.docx
 
Data Mining Apriori Algorithm Implementation using R
Data Mining Apriori Algorithm Implementation using RData Mining Apriori Algorithm Implementation using R
Data Mining Apriori Algorithm Implementation using R
 
Cluster2
Cluster2Cluster2
Cluster2
 
Assignment #3 10.19.14
Assignment #3 10.19.14Assignment #3 10.19.14
Assignment #3 10.19.14
 
N0342080084
N0342080084N0342080084
N0342080084
 

More from Derek Kane

Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingDerek Kane
 
Data Science - Part XVI - Fourier Analysis
Data Science - Part XVI - Fourier AnalysisData Science - Part XVI - Fourier Analysis
Data Science - Part XVI - Fourier AnalysisDerek Kane
 
Data Science - Part XV - MARS, Logistic Regression, & Survival Analysis
Data Science -  Part XV - MARS, Logistic Regression, & Survival AnalysisData Science -  Part XV - MARS, Logistic Regression, & Survival Analysis
Data Science - Part XV - MARS, Logistic Regression, & Survival AnalysisDerek Kane
 
Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsDerek Kane
 
Data Science - Part XIII - Hidden Markov Models
Data Science - Part XIII - Hidden Markov ModelsData Science - Part XIII - Hidden Markov Models
Data Science - Part XIII - Hidden Markov ModelsDerek Kane
 
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsData Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsDerek Kane
 
Data Science - Part X - Time Series Forecasting
Data Science - Part X - Time Series ForecastingData Science - Part X - Time Series Forecasting
Data Science - Part X - Time Series ForecastingDerek Kane
 
Data Science - Part IX - Support Vector Machine
Data Science - Part IX -  Support Vector MachineData Science - Part IX -  Support Vector Machine
Data Science - Part IX - Support Vector MachineDerek Kane
 
Data Science - Part VII - Cluster Analysis
Data Science - Part VII -  Cluster AnalysisData Science - Part VII -  Cluster Analysis
Data Science - Part VII - Cluster AnalysisDerek Kane
 
Data Science - Part V - Decision Trees & Random Forests
Data Science - Part V - Decision Trees & Random Forests Data Science - Part V - Decision Trees & Random Forests
Data Science - Part V - Decision Trees & Random Forests Derek Kane
 
Data Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVAData Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVADerek Kane
 
Data Science - Part III - EDA & Model Selection
Data Science - Part III - EDA & Model SelectionData Science - Part III - EDA & Model Selection
Data Science - Part III - EDA & Model SelectionDerek Kane
 
Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studioDerek Kane
 
Data Science - Part I - Sustaining Predictive Analytics Capabilities
Data Science - Part I - Sustaining Predictive Analytics CapabilitiesData Science - Part I - Sustaining Predictive Analytics Capabilities
Data Science - Part I - Sustaining Predictive Analytics CapabilitiesDerek Kane
 

More from Derek Kane (14)

Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image Processing
 
Data Science - Part XVI - Fourier Analysis
Data Science - Part XVI - Fourier AnalysisData Science - Part XVI - Fourier Analysis
Data Science - Part XVI - Fourier Analysis
 
Data Science - Part XV - MARS, Logistic Regression, & Survival Analysis
Data Science -  Part XV - MARS, Logistic Regression, & Survival AnalysisData Science -  Part XV - MARS, Logistic Regression, & Survival Analysis
Data Science - Part XV - MARS, Logistic Regression, & Survival Analysis
 
Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic Algorithms
 
Data Science - Part XIII - Hidden Markov Models
Data Science - Part XIII - Hidden Markov ModelsData Science - Part XIII - Hidden Markov Models
Data Science - Part XIII - Hidden Markov Models
 
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsData Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
 
Data Science - Part X - Time Series Forecasting
Data Science - Part X - Time Series ForecastingData Science - Part X - Time Series Forecasting
Data Science - Part X - Time Series Forecasting
 
Data Science - Part IX - Support Vector Machine
Data Science - Part IX -  Support Vector MachineData Science - Part IX -  Support Vector Machine
Data Science - Part IX - Support Vector Machine
 
Data Science - Part VII - Cluster Analysis
Data Science - Part VII -  Cluster AnalysisData Science - Part VII -  Cluster Analysis
Data Science - Part VII - Cluster Analysis
 
Data Science - Part V - Decision Trees & Random Forests
Data Science - Part V - Decision Trees & Random Forests Data Science - Part V - Decision Trees & Random Forests
Data Science - Part V - Decision Trees & Random Forests
 
Data Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVAData Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVA
 
Data Science - Part III - EDA & Model Selection
Data Science - Part III - EDA & Model SelectionData Science - Part III - EDA & Model Selection
Data Science - Part III - EDA & Model Selection
 
Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studio
 
Data Science - Part I - Sustaining Predictive Analytics Capabilities
Data Science - Part I - Sustaining Predictive Analytics CapabilitiesData Science - Part I - Sustaining Predictive Analytics Capabilities
Data Science - Part I - Sustaining Predictive Analytics Capabilities
 

Recently uploaded

Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 

Recently uploaded (20)

Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 

Data Science - Part VI - Market Basket and Product Recommendation Engines

  • 2.  Association Rules  Basic Terminology  Support  Confidence  Lift  Apriori Algorithm  Practical Examples  Grocery Shopping Basket Analysis  Voting Patterns in the House of Representatives
  • 3.  A series of methodologies for discovering interesting relationships between variables in a database.  The outcome of this technique, in simple terms, is a set of rules that can be understood as “if this, then that”.  An example of an association rule would be:  If a person buys Peanut Butter and Bread then they will also purchase Jelly.
  • 4. Applications  Product recommendation  Digital Media recommendations  Politics  Medical diagnosis  Content optimisation  Bioinformatics  Web mining  Scientific data analysis  Example: The analysis of earth science data may reveal interesting connections among the ocean, land, and atmospheric processes. This may help scientists to better understand how these systems interact with one another.
  • 5.  For example, maybe people who buy flour and casting sugar, also tend to buy eggs (because a high proportion of them are planning on baking a cake).  A retailer can use this information to inform:  Store layout (put products that co-occur together close to one another, to improve the customer shopping experience).  Marketing (e.g. target customers who buy flour with offers on eggs, to encourage them to spend more on their shopping basket).  Retailers can use these type of rules to identify new opportunities for cross selling/upselling their products to their customers.
  • 6.  Asked engineers and scientists around the world to solve what might have seemed like a simple problem: improve Netflix's ability to predict what movies users would like by a modest 10%.  From $5 million revenue in 1999 reached $3.2 billion revenue in 2011 as a result of becoming an analytics competitor.  By analyzing customer behavior and buying patterns created a recommendation engine which optimizes both customer tastes and inventory condition.
  • 7.  A rule is typically written in the following format: { i1, i2 } => { ik }  The { i1, i2 } represents the left hand side, LHS, of the rule and the { ik } represents the right hand side, RHS.  This statement can be read as “if a user buys an item in the item set on the left hand side, then the user will likely buy the item on the right hand side too”.  A more human readable example is: {coffee, sugar} => {milk}  If a customer buys coffee and sugar, then they are also likely to buy milk.
  • 8.  Before we can begin to employ association rules, we must first understand three important ratios; the support, confidence and lift.  Support: The fraction of which our item set occurs in our dataset.  Confidence: Probability that a rule is correct for a new transaction with items on the left.  Lift: The ratio by which by the confidence of a rule exceeds the expected confidence.
  • 9.  The support of an item or item set is the fraction of transactions in our data set that contain that item or item set.  Ex. A grocer has 15 transactions in total. Of which, Peanut Butter => Jelly appears 6 times. The support for this rule is 6 / 15 or 0.40.  In general, it is nice to identify rules that have a high support, as these will be applicable to a large number of transactions.  Support is an important measure because a rule that has a low support may occur simply by chance. A low support rule may also be uninteresting from a business perspective because it may not be profitable to promote items that are seldom bought together. For these reasons, support is often used to eliminate uninteresting rules.  For super market retailers, this is likely to involve basic products that are popular across an entire user base (e.g. bread, milk). A printer cartridge retailer, for example, may not have products with a high support, because each customer only buys cartridges that are specific to his / her own printer.
  • 10.  The confidence of a rule is the likelihood that it is true for a new transaction that contains the items on the LHS of the rule. (I.e. it is the probability that the transaction also contains the item(s) on the RHS.) Formally:  Confidence(X -> Y) = Support(X ꓴ Y) / Support (X)  Confidence(Peanut Butter => Jelly) = 0.26 / 0.40 = 0.65  This means that for 65% of the transactions that contain Peanut Butter and Jelly, the rule is correct.  Confidence measures the reliability of the inference made by a given rule. For a given rule X -> Y, the higher the confidence the more likely it is for Y to be present in transactions that contain X.  Association analysis results should be interpreted with caution. The inference made by an association rule does not necessarily imply causality. Instead, it suggests a strong co-occurance relationship between the items in the antecedent and consequent of the rule.
  • 11.  The lift of a rule is the ratio of the support of the items on the LHS of the rule co- occuring with items on the RHS divided by probability that the LHS and RHS co- occur if the two are independent.  Lift (X -> Y) = Support(X ꓴ Y) / ( Support (Y) * Support (X) )  Lift (Peanut Butter => Jelly) = 0.26 / (0.46 * 0.40) = 1.4  If lift is greater than 1, it suggests that the presence of the items on the LHS has increased the probability that the items on the right hand side will occur on this transaction.  If the lift is below 1, it suggests that the presence of the items on the LHS make the probability that the items on the RHS will be part of the transaction lower.  If the lift, is 1 it indicates that the items on the left and right are independent.  When we perform market basket analysis, then, we are looking for rules with a lift of more than one and preferably with a higher level of support.
  • 12.  The Apriori algorithm is perhaps the best known algorithm to mine association rules.  Apriori Theorem: “If an itemset is frequent, then all of its subsets must be also be frequent.”  It uses a breadth first strategy to count the support of item sets and uses a candidate generation function which exploits the downward closure property of support (anti- monotonicity).  The approach follows a 2 step process:  First, minimum support is applied to find all frequent itemsets in the database.  Second, these frequent itemsets and the minimum confidence constraint are used to form rules.
  • 13.  Finding all frequent itemsets in a database is difficult since it involves searching for all item combinations. The set of possible item combinations is the power set over I and has the size of 2n-1.
  • 14.  The downward-closure property of support allows for efficient search and guarantees that for a frequent itemset, all of its subsets are also frequent. Additionally, for an infrequent itemset, all of its supersets must also be infrequent.
  • 15.
  • 16.  Imagine 10000 receipts sitting on your table. Each receipt represents a transaction with items that were purchased. The receipt is a representation of stuff that went into a customer’s basket – and therefore ‘Market Basket Analysis’.  That is exactly what the Groceries Data Set contains: a collection of receipts with each line representing 1 receipt and the items purchased. Each line is called a transaction and each column in a row represents an item.  For each transaction, there can be only distinct Item(s) without repeating entries. This allows for us to create a binary (0,1) representation whether a particular item was purchased under a specific transaction.
  • 17.  The dataset will need to first be flipped across the horizontal axis in to a cross tabulation. Notice that the “Items” are now the column headings. This preparation ensures that the dataset can be read properly into the apriori market basket algorithm.
  • 18.
  • 19.  The market basket analysis algorithm requires setting a threshold for detecting patterns in the dataset.  For this example, we specified a support value of 0.001 (due to the high volume of receipts and large product offering) and a confidence level of 0.70.  Additionally, we set the length of the rule not to exceed three elements. This ensures that the we will have a maximum of 2 items on the LHS and that the assessment will produce more meaningful insights at a tertiary glance.
  • 20.  Different businesses will have distribution of items by transaction that look very different, and so very different support and confidence parameters may be applicable.  To determine what works best, organizations need to experiment with different parameters: as you reduce them, the number of rules generated will increase, which will give us more to work with.  However, we will need to sift through the rules more carefully to identify those that will be more impactful for your business.  There is no stead fast rule on where to begin so experiment with loose parameters and go from there.
  • 21.  To showcase how we can leverage this insight further lets focus in on 3 specific items of interest:  Yogurt  Tropical Fruit  Bottled Beer.  We can run the algorithm (with the same thresholds) and specify that these terms are used as criterion for the RHS of the ruleset generation.
  • 22.  Now as criterion for the LHS of the ruleset generation.
  • 23.  Before we use the data to make any kind of business decision, it is important that we take a step back and remember something important:  The output of the analysis reflects how frequently items co-occur in transactions. This is a function both of the strength of association between the items, and the way the business has presented them to the customer.  To say that in a different way: items might co-occur not because they are “naturally” connected, but because we, the people in charge of the organization, have presented them together.
  • 24.  The market basket results can be used to drive targeted marketing campaigns.  For each patron, we pick a handful of products based on products they have bought to date which have both a high uplift and a high margin, and send them a e.g. personalized email or display ads etc.  How we use the analysis has significant implications for the analysis itself: if we are feeding the analysis into a machine-driven process for delivering recommendations, we are much more interested in generating an expansive set of rules.  If, however, we are experimenting with targeted marketing for the first time, it makes much more sense to pick a handful of particularly high value rules, and action just them, before working out whether to invest in the effort of building out that capability to manage a much wider and more complicated rule set.
  • 25.  There are a number of ways we can use the data to drive site organization:  Large clusters of co-occuring items should probably be placed in their own category / theme.  Item pairs that commonly co-occur should be placed close together within broader categories on the website. This is especially important where one item in a pair is very popular, and the other item is very high margin.  Long lists of rules (including ones with low support and confidence) can be used to put recommendations at the bottom of product pages and on product cart pages. The only thing that matters for these rules is that the lift is greater than one. (And that we pick those rules that are applicable for each product with the high lift where the product recommended has a high margin.)  In the event that doing the above (3) drives significant uplift in profit, it would strengthen the case to invest in a recommendation system, that uses a similar algorithm in an operational context to power automatic recommendation engine on your website.
  • 26.
  • 27.  We will apply the results of association analysis to the voting records of members of the United States House of Representatives. The data is obtained from the 1984 Congressional Voting Records Database, which is available at the UCI machine learning data repository.  Each transaction contains information about party affiliation along with his or her voting record on 16 key issues.
  • 28. Observations:  A vote in favor of the Physician Pay Freeze indicates a Republican (95% confidence), a vote against indicates a Democrat (99% confidence).  The voting patterns are relatively clear in this example with a high degree of support and confidence. We can see which party favors a specific law without knowing the contents of the legislation itself.
  • 29.  Reside in Wayne, Illinois  Active Semi-Professional Classical Musician (Bassoon).  Married my wife on 10/10/10 and been together for 10 years.  Pet Yorkshire Terrier / Toy Poodle named Brunzie.  Pet Maine Coons’ named Maximus Power and Nemesis Gul du Cat.  Enjoy Cooking, Hiking, Cycling, Kayaking, and Astronomy.  Self proclaimed Data Nerd and Technology Lover.