0

I have a dataset and I divided it into 2 datasets RANDOMLY A and B, where A is 70% of the main dataset and B is 30%... Then I applied Apriori algorithm on the both A and B separately, generating its rules.. I want to compare rules from dataset A to rules of dataset B example:

A has the following rules [(sex=0,age=1),(sex=1,age=1,money=0),(sex=0,age=2,money=2)]
B has the following rules [(sex=0,age=1,money=1),(sex=0,age=1,money=0),(sex=1,age=1,money=0)]
A(sex=0,age=1) => B(sex=0,age=1,money=1) returns TRUE
A(sex=1,age=1,money=0) => B(sex=1,age=1,money=0)) returns TRUE
A(sex=0,age=2,money=2) => B(sex=1,age=1,money=0) returns FALSE````
camille
  • 16,432
  • 18
  • 38
  • 60
  • 3
    It would be helpful if you post reproducible data, the R code you've tried so far, and the desired output... https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1 – Bill O'Brien Sep 13 '19 at 17:37

1 Answers1

0

The functions that you need to do this are is.subset or is.superset. It can be used to compare two sets. Here is the example from the man page and you can easily modify it to compare two sets of itemsets or sets of rules.

data("Adult")
set <- eclat(Adult, parameter = list(supp = 0.8))

### find the supersets of each itemset in set
is.superset(set, set) 

If you supply a reproducible example, then you can get more specific help.

Michael Hahsler
  • 2,965
  • 1
  • 12
  • 16