In [1]:
# chargement du package
library(arules)

# récupération des données Groceries
data(Groceries)

# visualisation des premières valeurs
head(as(Groceries,"data.frame"))
Loading required package: Matrix

Attaching package: ‘arules’

The following objects are masked from ‘package:base’:

    abbreviate, write

Out[1]:
                                                                  items
1              {citrus fruit,semi-finished bread,margarine,ready soups}
2                                        {tropical fruit,yogurt,coffee}
3                                                          {whole milk}
4                         {pip fruit,yogurt,cream cheese ,meat spreads}
5 {other vegetables,whole milk,condensed milk,long life bakery product}
6                      {whole milk,butter,yogurt,rice,abrasive cleaner}
In [2]:
# extraction des règles
rules <- apriori(
  Groceries,
  parameter = list(
    supp = 0.01,
    conf = 0.5,
    target = "rules"
  )
)
Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen
        0.5    0.1    1 none FALSE            TRUE       5    0.01      1
 maxlen target  ext
     10  rules TRUE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 98 

set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
sorting and recoding items ... [88 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 2 3 4 done [0.00s].
writing ... [15 rule(s)] done [0.00s].
creating S4 object  ... done [0.00s].
In [3]:
# affichage
inspect(rules)
     lhs                                       rhs                support   
[1]  {curd, yogurt}                         => {whole milk}       0.01006609
[2]  {other vegetables, butter}             => {whole milk}       0.01148958
[3]  {other vegetables, domestic eggs}      => {whole milk}       0.01230300
[4]  {yogurt, whipped/sour cream}           => {whole milk}       0.01087951
[5]  {other vegetables, whipped/sour cream} => {whole milk}       0.01464159
[6]  {pip fruit, other vegetables}          => {whole milk}       0.01352313
[7]  {citrus fruit, root vegetables}        => {other vegetables} 0.01037112
[8]  {tropical fruit, root vegetables}      => {other vegetables} 0.01230300
[9]  {tropical fruit, root vegetables}      => {whole milk}       0.01199797
[10] {tropical fruit, yogurt}               => {whole milk}       0.01514997
[11] {root vegetables, yogurt}              => {other vegetables} 0.01291307
[12] {root vegetables, yogurt}              => {whole milk}       0.01453991
[13] {root vegetables, rolls/buns}          => {other vegetables} 0.01220132
[14] {root vegetables, rolls/buns}          => {whole milk}       0.01270971
[15] {other vegetables, yogurt}             => {whole milk}       0.02226741
     confidence coverage   lift     count
[1]  0.5823529  0.01728521 2.279125  99  
[2]  0.5736041  0.02003050 2.244885 113  
[3]  0.5525114  0.02226741 2.162336 121  
[4]  0.5245098  0.02074225 2.052747 107  
[5]  0.5070423  0.02887646 1.984385 144  
[6]  0.5175097  0.02613116 2.025351 133  
[7]  0.5862069  0.01769192 3.029608 102  
[8]  0.5845411  0.02104728 3.020999 121  
[9]  0.5700483  0.02104728 2.230969 118  
[10] 0.5173611  0.02928317 2.024770 149  
[11] 0.5000000  0.02582613 2.584078 127  
[12] 0.5629921  0.02582613 2.203354 143  
[13] 0.5020921  0.02430097 2.594890 120  
[14] 0.5230126  0.02430097 2.046888 125  
[15] 0.5128806  0.04341637 2.007235 219