hanaml.KORD is a R wrapper for SAP HANA PAL KORD.

hanaml.KORD(
  data,
  used.cols = NULL,
  k = NULL,
  max.antecedent = NULL,
  min.support = NULL,
  min.confidence = NULL,
  min.coverage = NULL,
  measure = NULL,
  epsilon = NULL,
  max.consequent = NULL,
  min.measure = NULL
)

Arguments

data

DataFrame
DataFrame containting the data.

used.cols

list of characters, optional
Specified the columns in data that specify transaction IDs and item IDs. For example, consider that the transaction ID column for data is "CUSTOMER", while the item ID column for data is "ITEM", then the correct way to set up this parameter is:

used.cols = list("transaction" = "CUSTOMER", "item" = "ITEM")


Transaction ID column defaults to the 1st column of data and item ID column defaults to the 2nd column of data.

k

integer, optional
Specifies the number (k) of top rules.
Defaults to 10.

max.antecedent

integer, optional
Maximum length of antecedent items for association rule generation.
Defaults to 4.

min.support

double, optional
User-specified minimum support value for rule generation.
Defaults to 0.

min.confidence

double, optional
User-specified minimum confidence value for rule generation.
Defaults to 0.

min.coverage

double, optional
User-specified minimum lift value for rule generation.
Defaults to the value of min.support.

measure

c("leverage", "lift", "support", "confidence"), optional
User-specified measure that defines the priority of generated association rules.
Defaults to "leverage".

epsilon

double, optional
User-specified maximum support value during the frequent items mining phase, i.e. if an item has support value above ubiquitous, it shall be ignored.
Defaults to 1.0.

max.consequent

integer, optional
User-specified maximum length of consequent items for association rule generation.
Should not be greater than 3.
New parameter added in SAP HANA Cloud.
Defaults to 1.

min.measure

double, optional
Specifies the minimum measure value for leverage or lift, whichever dependents on the setting of measure.
Defaults to 0.0.

Value

A "KORD" object with the following attributes.

  • antecedent: DataFrame
    Antecedent item information of mined association rules.

  • consequent: DataFrame
    Consequent item information of mined association rules.

  • statistics: DataFrame
    Support/confidence/lift values of mined association rules.

Examples

Input transaction DataFrame data:


> data$Collect()
   CUSTOMER  ITEM
1         2 item2
2         2 item3
3         3 item1
4         3 item2
5         3 item4
6         4 item1
7         4 item3
8         5 item2
9         5 item3
10        6 item1
11        6 item3
12        0 item1
13        0 item2
14        0 item5
15        1 item2
16        1 item4
17        7 item1
18        7 item2
19        7 item3
20        7 item5
21        8 item1
22        8 item2
23        8 item3

Creating an KORD object for mining association rules from the input data:


> kd <- hanaml.KORD(data = data,
                    used.cols = c(transaction = "CUSTOMER",
                                  item = "ITEM"),
                    min.support = 0.1, min.confidence = 0.2,
                    measure = "Lift", k = 5)

Check the mined association rules from the attributes of above KORD object:


> kd$antecedent
  RULE_ID ANTECEDENT
1       0      item2
2       1      item1
3       2      item2
4       2      item1
5       3      item5
6       4      item2
> kd$consequent
  RULE_ID CONSEQUENT
1       0      item5
2       1      item5
3       2      item5
4       3      item1
5       4      item4
> kd$statistics
  RULE_ID   SUPPORT CONFIDENCE     LIFT   LEVERAGE  MEASURE
1       0 0.2222222  0.2857143 1.285714 0.04938272 1.285714
2       1 0.2222222  0.3333333 1.500000 0.07407407 1.500000
3       2 0.2222222  0.5000000 2.250000 0.12345679 2.250000
4       3 0.2222222  1.0000000 1.500000 0.07407407 1.500000
5       4 0.2222222  0.2857143 1.285714 0.04938272 1.285714