Market Basket Analysis and Association Rules using R

Posted on Updated on

Market basket analysis provides great insights into purchasing behaviors of customers. Based on customer purchase data and association rules, we arrive at groups of related products which typically people buy together.

# Load the required libraries
install.packages("arules")
library(arules)
library(datasets)

# Load the data set
myData

MBA1

# Fetch the rules with support as 0.001 and confidence as 0.7
rules

MBA2

rules<-sort(rules, by="confidence", decreasing=TRUE)
options(digits=2)
inspect(rules[1:10])

MBA3

#Visualizing the results

install.packages("igraph")
install.packages("arulesViz")
library(arulesViz)
library(tcltk)
rulesImp

MBA4

References:

1. Arules Package: http://cran.at.r-project.org/web/packages/arules/arules.pdf

2. ArulesViz Package: http://cran.r-project.org/web/packages/arulesViz/vignettes/arulesViz.pdf

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s