Ashish Jha
2007-Oct-17 06:46 UTC
[R] How to save association rules generated by arules package
Hi,
I have been able to generate association rules for Market Basket Analysis
using the following codes:
****************************************************************************
*******************************************
library("arules")
rules <- read.csv("write1.csv",na.strings=c(".",
"NA", "", "?"),header=TRUE)
transactions <- as(split(rules$Item, rules$ID), "transactions")
getrules <- apriori(transactions, parameter = list(support=0.100,
confidence=0.100))
summary(getrules)
inspect(SORT(getrules, by="confidence")[1:10])
****************************************************************************
*******************************************
I am working on a dummy data write now. Following are the rules that inspect
function is showing:
****************************************************************************
***************************************
lhs rhs support confidence lift
1 {Foam} => {Razor} 0.1000000 1 6.000000
2 {Foam} => {Toy} 0.1000000 1 6.000000
3 {Foam} => {Chocolate} 0.1000000 1 4.285714
4 {Razor} => {Chocolate} 0.1666667 1 4.285714
5 {Toy} => {Chocolate} 0.1666667 1 4.285714
6 {Ketchup} => {Maggi} 0.3666667 1 2.500000
7 {Butter} => {Milk} 0.4000000 1 2.500000
8 {Milk} => {Butter} 0.4000000 1 2.500000
9 {Butter} => {Bread} 0.4000000 1 2.500000
10 {Bread} => {Butter} 0.4000000 1 2.500000
****************************************************************************
***********************************************
How do I save these rules in to some other device e.g. Notepad/Document/PPT
etc. I want to be able to save it somewhere in a file and then use it for
presentation.
Thanks and regards,
Ashish Jha
+91-80-6695 0606
www.zymesolutions.com <http://www.zymesolutions.com/>
[[alternative HTML version deleted]]
I am not sure if this is what you want but to re-direct the results to a file see ?sink good luck AA. ----- Original Message ----- From: "Ashish Jha" <ajha at zymesolutions.com> To: <r-help at stat.math.ethz.ch> Sent: Wednesday, October 17, 2007 2:46 AM Subject: [R] How to save association rules generated by arules package> Hi, > > > > I have been able to generate association rules for Market Basket Analysis > using the following codes: > > > > **************************************************************************** > ******************************************* > > library("arules") > > rules <- read.csv("write1.csv",na.strings=c(".", "NA", "", > "?"),header=TRUE) > > transactions <- as(split(rules$Item, rules$ID), "transactions") > > getrules <- apriori(transactions, parameter = list(support=0.100, > confidence=0.100)) > > > > summary(getrules) > > > > inspect(SORT(getrules, by="confidence")[1:10]) > > > > **************************************************************************** > ******************************************* > > I am working on a dummy data write now. Following are the rules that > inspect > function is showing: > > > > **************************************************************************** > *************************************** > > lhs rhs support confidence lift > > 1 {Foam} => {Razor} 0.1000000 1 6.000000 > > 2 {Foam} => {Toy} 0.1000000 1 6.000000 > > 3 {Foam} => {Chocolate} 0.1000000 1 4.285714 > > 4 {Razor} => {Chocolate} 0.1666667 1 4.285714 > > 5 {Toy} => {Chocolate} 0.1666667 1 4.285714 > > 6 {Ketchup} => {Maggi} 0.3666667 1 2.500000 > > 7 {Butter} => {Milk} 0.4000000 1 2.500000 > > 8 {Milk} => {Butter} 0.4000000 1 2.500000 > > 9 {Butter} => {Bread} 0.4000000 1 2.500000 > > 10 {Bread} => {Butter} 0.4000000 1 2.500000 > > **************************************************************************** > *********************************************** > > How do I save these rules in to some other device e.g. > Notepad/Document/PPT > etc. I want to be able to save it somewhere in a file and then use it for > presentation. > > > > Thanks and regards, > > > > Ashish Jha > +91-80-6695 0606 > > www.zymesolutions.com <http://www.zymesolutions.com/> > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.