Coder Social home page Coder Social logo

Comments (14)

mhahsler avatar mhahsler commented on May 23, 2024

I cannot reproduce the error on either the CRAN version or the development version.

library(arules)
data(Groceries)
rules <- apriori(Groceries, 
   parameter=list(support=0.001, confidence=0.8))
x <- 'milk'
rules <- subset(rules, subset = (lhs %pin% as.character(x)) & lift > 1)
rules

set of 63 rules 

Please send me the data and the exact code that produces the error.

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

The data set is proprietary but I can probably provide you a rules object that fails. Would that work?

from arules.

mhahsler avatar mhahsler commented on May 23, 2024

Yes, it would be great if you can modify my code from above so that it fails.

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

I tried duplicating with a dataset I could share and failed, however it fails consistently with the private data set. It failed under versions 1.4-1, 1.4-2, and 1.4-2-1. I can provide a failed rules object and will continue to try and replicate from scratch with a public dataset. Is 'standardGeneric' the appropriate class for 'lhs' (or possibly the rules file in general) or should it be something else?

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

interestingly if I remove the (lhs %pin% as.character(x)) & portion of the subset, I receive the error "object 'lift' not found".

from arules.

mhahsler avatar mhahsler commented on May 23, 2024

I am pretty sure that this is your problem:

rules <- 10
subset(rules, subset = (lhs %pin% as.character(x)) & lift > 1)
Show Traceback

Rerun with Debug
Error in (function (classes, fdef, mtable)  : 
unable to find an inherited method for function ‘%pin%’ for signature ‘"standardGeneric", "character"’ 

In other words, rules does not contain rules and R unfortunately says this not in a very readable way.

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

It's possible. I'm honestly confused and suspect it could be a complication of how it is run. However when I remove the subset line and run I receive full output. Here is the plot output for plot(rules, method="grouped", measure="confidence")): https://s3.amazonaws.com/gabe1/arulesVis.png so I'm confident the rules file is some sort of rules file.

The execution path is private module -> function -> %do% -> function -> rmarkdown:render -> rmarkdown file -> sub-rmarkdown file (incorporated into the main file using knit_expand).

The rmarkdown::render() is called with envir=env.new(). Still, is it possible subset simply doesn't know how to deal with 'lift' and 'lhs' due to the way it is called?

from arules.

mhahsler avatar mhahsler commented on May 23, 2024

This is strange. Does everything also look ok if you say inspect(rules)?

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

inspect(rules) looks normal:

##    lhs                                 rhs                                                       support confidence     lift
## 1  {}                               => {victim.employee_count.Unknown}                         0.2534307  0.2534307 1.000000
## 2  {}                               => {attribute.confidentiality.data.variety.Personal}       0.3153787  0.3153787 1.000000
## 3  {}                               => {attribute.confidentiality.data.variety.Unknown}        0.3827941  0.3827941 1.000000
## 4  {}                               => {actor.external.variety.Unknown}                        0.4337762  0.4337762 1.000000
## 5  {}                               => {asset.variety.Unknown}                                 0.4582470  0.4582470 1.000000
## 6  {}                               => {asset.assets.variety.Unknown}                          0.4582470  0.4582470 1.000000
## 7  {}                               => {actor.internal.variety.Unknown}                        0.4863627  0.4863627 1.000000
## 8  {}                               => {attribute.confidentiality.data_disclosure.Potentially} 0.5349928  0.5349928 1.000000
## 9  {}                               => {victim.employee_count.Large}                           0.7320986  0.7320986 1.000000
## 10 {}                               => {victim.industry2.92}                                   0.7357903  0.7357903 1.000000
## 11 {}                               => {victim.orgsize.Large}                                  0.7384539  0.7384539 1.000000
## 12 {asset.assets.variety.P - Other} => {pattern.Everything Else}                               0.1335846  0.8854016 6.396792
## 13 {asset.assets.variety.P - Other} => {action.social.variety.Phishing}                        0.1487095  0.9856494 6.607947
## 14 {asset.assets.variety.P - Other} => {action.social.vector.Email}                            0.1486939  0.9855461 6.515403
## 15 {asset.assets.variety.P - Other} => {asset.variety.Person}                                  0.1508746  1.0000000 6.497874
## 16 {asset.assets.variety.P - Other} => {attribute.integrity.variety.Alter behavior}            0.1508590  0.9998968 6.480151
## 17 {asset.assets.variety.P - Other} => {actor.external.variety.Unknown}                        0.1360769  0.9019203 2.079229
## 18 {asset.assets.variety.P - Other} => {victim.employee_count.Large}                           0.1265752  0.8389428 1.145942
## 19 {asset.assets.variety.P - Other} => {victim.industry2.92}                                   0.1270736  0.8422465 1.144683
## 20 {asset.assets.variety.P - Other} => {victim.orgsize.Large}                                  0.1267465  0.8400785 1.137618

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

The only odd thing is the 1<->1 mapping. I can't remember if that's an artifact of how I ran apriori or an anomaly.

Clearly I peg asset.assets.variety.P - Other to the LHS, but i'm surprised I don't see groups.

from arules.

mhahsler avatar mhahsler commented on May 23, 2024

did you put the inspect right before the subset in the original code that creates the error (the markdown file)?

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

The inspect is immediately after the subset, however the subset is commented out. (It would get rid of the empty LHS's if it were working.)

from arules.

mhahsler avatar mhahsler commented on May 23, 2024

This is really strange. Try to replace the subset with this:

 rules[lhs(rules) %pin% as.character(x) & quality(rules)$lift>1]

Also, do you load a package that overwrites %pin%?

from arules.

gdbassett avatar gdbassett commented on May 23, 2024

It's possible that %pin% is being overwritten as I load a bunch of stuff, however I tried removing it and still received an error that 'lift' didn't exist. I also directly defined %pin% (%pin%` <- arules::`%pin% ) and still received the error.

Technically I used rules <- rules[lhs(rules) %pin% as.character(x) & quality(rules)$lift>1], but that worked. Received no errors and received the filtered output:

##   lhs                                 rhs                                            support confidence     lift
## 1 {asset.assets.variety.P - Other} => {pattern.Everything Else}                    0.1335846  0.8854016 6.396792
## 2 {asset.assets.variety.P - Other} => {action.social.variety.Phishing}             0.1487095  0.9856494 6.607947
## 3 {asset.assets.variety.P - Other} => {action.social.vector.Email}                 0.1486939  0.9855461 6.515403
## 4 {asset.assets.variety.P - Other} => {asset.variety.Person}                       0.1508746  1.0000000 6.497874
## 5 {asset.assets.variety.P - Other} => {attribute.integrity.variety.Alter behavior} 0.1508590  0.9998968 6.480151
## 6 {asset.assets.variety.P - Other} => {actor.external.variety.Unknown}             0.1360769  0.9019203 2.079229
## 7 {asset.assets.variety.P - Other} => {victim.employee_count.Large}                0.1265752  0.8389428 1.145942
## 8 {asset.assets.variety.P - Other} => {victim.industry2.92}                        0.1270736  0.8422465 1.144683
## 9 {asset.assets.variety.P - Other} => {victim.orgsize.Large}                       0.1267465  0.8400785 1.137618

from arules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.