mhahsler / arules

Mining Association Rules and Frequent Itemsets with R
http://mhahsler.github.io/arules
GNU General Public License v3.0
194 stars 42 forks source link

Informative output of apriori cannot be disabled with suppressMessages #12

Closed kliegr closed 8 years ago

kliegr commented 8 years ago

Arules outputs many diagnostic messages such as Parameter specification and Algorithmic control.

These messages cannot be suppressed with the suppressMessages() function. The gist of the problem might be described in this stackoverflow entry.

As a side note, the warning "You chose a very low absolute support count of 0. You might run out of memory! Increase minimum support." can be supressed with suppressWarnings().

Working suppressMessages() would be nice when apriori is invoked programmatically, from other packages.

mhahsler commented 8 years ago

Progress reporting can be suppressed using verbose=FALSE as a control argument.

rules <- apriori(Adult, parameter = list(supp = 0.5, conf = 0.9, target = "rules"), control=list(verbose = FALSE))
kliegr commented 8 years ago

Thanks, I overlooked this flag.

lovetoken commented 7 years ago

I have additional questions. How to silent the output when arules::inspect() inspect() is not control argument control=list(verbose = FALSE).

The result doesn't silent message even though execute the assignment like this code

> data("Adult")
> rules <- apriori(Adult, control = list(verbose = F))
> res <- inspect(rules[1:10])
     lhs                          rhs                              support confidence      lift
[1]  {}                        => {race=White}                   0.8550428  0.8550428 1.0000000
[2]  {}                        => {native-country=United-States} 0.8974243  0.8974243 1.0000000
[3]  {}                        => {capital-gain=None}            0.9173867  0.9173867 1.0000000
[4]  {}                        => {capital-loss=None}            0.9532779  0.9532779 1.0000000
[5]  {relationship=Unmarried}  => {capital-loss=None}            0.1019819  0.9719024 1.0195373
[6]  {occupation=Sales}        => {race=White}                   0.1005282  0.8920785 1.0433144
[7]  {occupation=Sales}        => {native-country=United-States} 0.1039679  0.9226017 1.0280552
[8]  {occupation=Sales}        => {capital-gain=None}            0.1030670  0.9146076 0.9969706
[9]  {occupation=Sales}        => {capital-loss=None}            0.1068343  0.9480378 0.9945030
[10] {occupation=Adm-clerical} => {native-country=United-States} 0.1052373  0.9160577 1.0207632
mhahsler commented 7 years ago

I am confused about the purpose of silencing inspect. The whole point if inspect is to show results on the screen (like print). You probably want to do something like this:

 res <- as(rules, "data.frame") 
lovetoken commented 7 years ago

Oh. I got it Thanks advice :)