hanaml.Apriori {hana.ml.r}R Documentation

Apriori algorithm for association rule mining

Description

Apriori algorithm for association rule minining, based on PAL_APRIORI and PAL_APRIORI_RELATIONAL.

Usage

hanaml.Apriori(conn.context, data, used.cols = NULL,
              min.support, min.confidence, min.lift = NULL,
              relational = FALSE, max.item.length = NULL,
              max.consequent = NULL, use.prefix.tree = NULL,
              ubiquitous = NULL,
              lhs.restrict = NULL, rhs.complement.lhs = NULL,
              rhs.restrict = NULL, lhs.complement.rhs = NULL,
              timeout = NULL, thread.ratio = NULL,
              pmml.export = NULL)

Arguments

conn.context

ConnectionContext
Database connection object.

data

DataFrame Dataset used for association rule mininig.

min.support

numeric
User-specified minimum support value for rule generation.

min.confidence

numeric, optional
User-specified minimum confidence value for rule generation.

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 colum 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, while item ID column defauts to the 2nd column of data.

relational

logical, optional
Whether or not to apply relational logic for association rule mining. This will affect the format view of mined association rules. Defaults to FALSE.

min.lift

numeric, optional
User-specified minimum lift value for rule generation. Defaults to 0.

max.item.length

integer, optional
User-specified maximum length of items, inclusive of both antecedent and consequent items for association rule generation.
Defaults to 5.

max.consequent

double, optional
Maximum length of consequent items for association rule generation.
Defaults to 100.

use.prefix.tree

logical, optional
Indicates whether or not to use prefix tree data structure when generating association rules for the purpose of memory-saving.
Defaults to FALSe.

ubiquitous

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.

lhs.restrict

list of characters, optional
Specifies the items are only allowed to be antecedent items, i.e. they can only appear on the left-hand side of association rules.

rhs.complement.lhs

logical, optional
If 'lhs.restrict' is not NULL, you can set this paramter to TRUE to restrict rest of items so that they can only appear on the right-hand-side of association rules.

rhs.restrict

list of characters, optional
Specifies the items are only allowed to be consequent items, i.e. they can only appear on the right-hand-side of association rules.

lhs.complement.rhs

logical, optional
If 'rhs.restrict' is not NULL, you can set this paramter to TRUE to restrict rest of items so that they can only appear on the left-hand-side of association rules.

thread.ratio

double, optional
Controls the proportion of available threads to use. The value range is from 0 to 1, where 0 means only using 1 thread, and 1 means using at most all the currently available threads. Values outside this range tell PAL to heuristically determine the number of threads to use. Defaults to 0.0.

timeout

integer, optional
Specifies the maximum run time in seconds for association rule mining. The algorithm will stop running when the specified timeout is reached.

pmml.export

('no', 'single-row', 'multi-row'), optional
Controls whether to output a PMML representation of the model, and how to format the PMML. Case-insensitive.

  • 'no': No PMML model.

  • 'single-row': Export an PMML model in a single row.

  • 'multi-row': Export an PMML model in multiple-rows, each row with maximum of length of 5000 characters.

Format

R6Class object.

Value

An "Apriori" object with the following attributes:

Examples

## Not run: 
> df <- conn$table('PAL_APRIORI_TRANS_TBL')
> df
  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

> apr <- hanaml.Apriori(conn.context = conn, data = df, min.support = 0.1, min.confidence = 0.3,
                       min.lift = 1.10, max.consequent = 1, pmml.export = 'single-row')

> apr$result
         ANTECEDENT CONSEQUENT   SUPPORT CONFIDENCE     LIFT
1              item5      item2 0.2222222  1.0000000 1.285714
2              item1      item5 0.2222222  0.3333333 1.500000
3              item5      item1 0.2222222  1.0000000 1.500000
4              item4      item2 0.2222222  1.0000000 1.285714
5        item2&item1      item5 0.2222222  0.5000000 2.250000
6        item5&item1      item2 0.2222222  1.0000000 1.285714
7        item5&item2      item1 0.2222222  1.0000000 1.500000
8        item5&item3      item2 0.1111111  1.0000000 1.285714
9        item5&item3      item1 0.1111111  1.0000000 1.500000
10       item1&item4      item2 0.1111111  1.0000000 1.285714
11 item2&item1&item3      item5 0.1111111  0.5000000 2.250000
12 item5&item1&item3      item2 0.1111111  1.0000000 1.285714
13 item5&item2&item3      item1 0.1111111  1.0000000 1.500000

## End(Not run)

[Package hana.ml.r version 1.0.8 Index]