apriori

Returns the frequent itemsets and the minimum support value. You can also retrieve certain L sets.

Syntax

predict = apriori(data, minimum_support)

predict = apriori(data, minimum_support, options)

Inputs

data
The transactional data, pre-processed using one_hot_encode.
Type: Boolean
Dimension: matrix
minimum_support
Threshold value for the itemsets to be allowed.
Type: integer
Dimension: scalar
options (optional)
Type: struct
extract
The L set to be extracted. (default: 0, for all)
Type: integer
Dimension: scalar

Outputs

predict
Contains the frequent itemsets, the size of each large set and the support counts.
Type: struct
items
The frequent items.
Type: Boolean
Dimension: matrix
size
The size of each large set.
Type: integer
Dimension: vector
support
The support counts.
Type: double
Dimension: vector

Example

cdata = [1, 5, 7, 8 ; 1, 6, 9, 7; 9, 7, 3, 2; 2, 5, 7, 4; 5, 3, 7, 6];
bdata = one_hot_encode(cdata);
options = struct;
options.extract = 2;
predict = apriori(bdata, 0.1, options)

predict = struct [
  items: [Matrix] 23 x 9
  1  0  0  0  1  0  0  0  0
  1  0  0  0  0  1  0  0  0
  1  0  0  0  0  0  1  0  0
  1  0  0  0  0  0  0  1  0
  1  0  0  0  0  0  0  0  1
  0  1  1  0  0  0  0  0  0
  0  1  0  1  0  0  0  0  0
  0  1  0  0  1  0  0  0  0
  0  1  0  0  0  0  1  0  0
  0  1  0  0  0  0  0  0  1
  0  0  1  0  1  0  0  0  0
  0  0  1  0  0  1  0  0  0
  0  0  1  0  0  0  1  0  0
  0  0  1  0  0  0  0  0  1
  0  0  0  1  1  0  0  0  0
  0  0  0  1  0  0  1  0  0
  0  0  0  0  1  1  0  0  0
  0  0  0  0  1  0  1  0  0
  0  0  0  0  1  0  0  1  0
  0  0  0  0  0  1  1  0  0
  0  0  0  0  0  1  0  0  1
  0  0  0  0  0  0  1  1  0
  0  0  0  0  0  0  1  0  1
  size: 23
  support: [Matrix] 23 x 1
  0.20000
  0.20000
  0.40000
  0.20000
  0.20000
  0.20000
  0.20000
  0.20000
  0.40000
  0.20000
  0.20000
  0.20000
  0.40000
  0.20000
  0.20000
  0.20000
  0.20000
  0.60000
  0.20000
  0.40000
  0.20000
  0.20000
  0.40000
]