Created
July 23, 2013 12:59
-
-
Save mwacc/6062181 to your computer and use it in GitHub Desktop.
Basket Analytic (Frequent Pattern Mining) example "in action" :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install the R package arules if required | |
#install.packages("arules"); | |
#load the arules package | |
library("arules"); | |
# read the transaction file as a Transaction class | |
txn = read.transactions(file="d:\\work\\R\\items.csv", rm.duplicates= FALSE, format="basket",sep=","); | |
#To visualize the item frequency in txn file | |
itemFrequencyPlot(txn); | |
# Run the apriori algorithm | |
basket_rules <- apriori(txn,parameter = list(sup = 0.2, conf = 0.9,target="rules")); | |
# Check the generated rules using inspect | |
inspect(basket_rules); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment