Presentation on theme: "A Brief Tour of R’s arules package July 2012"— Presentation transcript:
1 A Brief Tour of R’s arules package July 2012 Stu Rodgers1
2 Package arulesMining frequent itemsets and association rules is a popular and well researched approach for discovering interesting relationships between variables in large databases.provides a basic infrastructure for creating and manipulating input data sets and for analyzing the resulting itemsets and rules.> library(arules)Loading required package: MatrixLoading required package: latticeAttaching package: ‘Matrix’The following object(s) are masked from ‘package:base’:detAttaching package: ‘arules’%in%Warning message:package ‘arules’ was built under R version
3 Data in arules> data()Data sets in package ‘arules’: Adult Adult Data Set AdultUCI Adult Data Set Epub Epub Data Set Groceries Groceries Data Set Income Income Data Set IncomeESL Income Data Set ...
4 Using arules > data("Epub") > ls()  "Epub" > summary(Epub) transactions as itemMatrix in sparse format with15729 rows (elements/itemsets/transactions) and936 columns (items) and a density ofmost frequent items:doc_11d doc_813 doc_4c6 doc_955 doc_698 (Other)element (itemset/transaction) length distribution:sizesNotes – Epub contains downloads of documents from the Electronic Publication platform of the Vienna University of Economics and Business available via from January 2003 to December 2008.
5 Using arules> summary(Epub) -- continued Min. 1st Qu. Median Mean 3rd Qu. Max includes extended item information - examples: labels 1 doc_11d 2 doc_13d 3 doc_14c includes extended transaction information - examples: transactionID TimeStamp session_ :59: session_ :46: session_479a :50:38
6 Using arules> year <- strftime(as.POSIXlt(transactionInfo(Epub)[["TimeStamp"]]), "%Y")> table(year)year> Epub2003 <- Epub[year == "2003"]> length(Epub2003) 987> image(Epub2003)Notesstrftime - converts between strings and POSIXlt class objectsPOSIXlt - objects for representing calendar dates and times (to nearest second)"%Y" – 4 digit year
8 Using arules> data(“AdultUCI")> dim(AdultUCI)> R demo ...Notes – AdultUCI - UCI machine learning repository (Asuncion and Newman 2007) of U.S. census bureau database. Contains attributes like age, work class, education, etc. In the original applications of the data, the attributes were used to predict the income level of individuals.
Your consent to our cookies if you continue to use this website.