Teradata Package for R Function Reference | 17.00 - FPGrowth - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
FPGrowth

Description

The FPGrowth (Frequent Pattern Growth) function uses an FP-growth algorithm to generate association rules from patterns in a data set, and then determines their interestingness.

Usage

  td_fpgrowth_mle (
      data = NULL,
      tran.item.columns = NULL,
      tran.id.columns = NULL,
      patterns.or.rules = "both",
      groupby.columns = NULL,
      pattern.distribution.key.column = NULL,
      rule.distribution.key.column = NULL,
      compress = "nocompress",
      group.size = 4,
      min.support = 0.05,
      min.confidence = 0.8,
      max.pattern.length = "2",
      antecedent.count.range = "1-INFINITE",
      consequence.count.range = "1-1",
      delimiter = ",",
      data.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies the name of the tbl_teradata that contains the data set.

tran.item.columns

Required Argument.
Specifies the names of the columns that contain transaction items to analyze.
Types: character OR vector of Strings (character)

tran.id.columns

Required Argument.
Specifies the names of the columns that contain identifiers for the transaction items.
Types: character OR vector of Strings (character)

patterns.or.rules

Optional Argument.
Specifies whether the function outputs patterns, rules, or both. An example of a pattern is onions, potatoes, hamburger.
Default Value: "both"
Permitted Values: both, patterns, rules
Types: character

groupby.columns

Optional Argument.
Specifies the names of columns that define the partitions into which the function groups the input data and calculates output for it. At least one column must be usable as a distribution key. If you omit this argument, then the function considers all input data to be in a single partition.
Note: Do not specify the same column in both this argument and the "tran.id.column argument", because this causes incorrect counting in the partitions.
Types: character OR vector of Strings (character)

pattern.distribution.key.column

Optional Argument.
Specifies the name of the column to use as the distribution key for "output.pattern.table" tbl_teradata. The default value is the first column name - "pattern_<tran.item.columns>" as generated in the "output.pattern.table" tbl_teradata.
Note: Only one column name can be specified.
Types: character

rule.distribution.key.column

Optional Argument.
Specifies the name of the column to use as the distribution key for "output.rule.table" tbl_teradata. The default value is the first column name - "antecedent_<tran.item.columns>" as generated in the "output.rule.table" tbl_teradata.
Note: Only one column name can be specified.
Types: character

compress

Optional Argument.
Specifies the compression level of the output tbl_teradata objects. Realized compression ratios depend on both this value and the data characteristics. These ratios typically range from 3x to 12x.
Default Value: "nocompress"
Permitted Values: low, medium, high, nocompress
Types: character

group.size

Optional Argument.
Specifies the number of transaction items to be assigned to each worker. This value must be an integer in the range from 1 to the number of distinct transaction items, inclusive. For a machine with limited RAM, use a relatively small value.
Default Value: 4
Types: integer

min.support

Optional Argument.
Specifies the minimum support value of returned patterns (including the specified support value). This value must be a floating point number in the range [0, 1].
Default Value: 0.05
Types: numeric

min.confidence

Optional Argument.
Specifies the minimum confidence value of returned patterns (including the specified confidence value). This value must be a floating point number in the range [0, 1].
Default Value: 0.8
Types: numeric

max.pattern.length

Optional Argument.
Specifies the maximum length of returned patterns. The length of a pattern is the sum of the item numbers in the antecedent and consequence columns. This value must be an integer greater than 2. "max.pattern.length" also limits the length of returned rules to this value.
Default Value: "2"
Types: character

antecedent.count.range

Optional Argument.
Specifies the range for the number of items in the antecedent. This argument takes the format, "lower_bound-upper_bound". The function returns only patterns for which number of items in the antecedent is in the range [lower_bound, upper_bound]. The lower_bound must be an integer greater than 0. The lower_bound and upper_bound can be equal.
Default Value: "1-INFINITE"
Types: character

consequence.count.range

Optional Argument.
Specifies the range for the number of items in the consequence. The function returns only patterns for which number of items in the consequence is in the range [lower_bound, upper_bound]. The lower_bound must be greater an integer greater than 0. The lower_bound and upper_bound can be equal.
Default Value: "1-1"
Types: character

delimiter

Optional Argument.
Specifies the delimiter that separates items in the output.
Default Value: ","
Types: character

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_fpgrowth_mle" which is a named list containing objects of class "tbl_teradata".
Named list members can be referenced directly with the "$" operator using the following names:

  1. output.pattern.table

  2. output.rule.table

  3. output

Examples

  
    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("fpgrowth_example", "sales_transaction")
    
    # Create object(s) of class "tbl_teradata".
    # Sales transaction data of an office supply chain store.
    # The column "product" specifies the items that are purchased by a
    # customer in a given transaction (column "orderid")
    sales_transaction <- tbl(con, "sales_transaction")
    
    # Compute association rules based on the pattern in the "product" column
    td_fpgrowth_out <- td_fpgrowth_mle(data = sales_transaction,
                                   tran.item.columns = "product",
                                   tran.id.columns = "orderid",
                                   groupby.columns = "region",
                                   min.support = 0.01,
                                   min.confidence = 0.0,
                                   max.pattern.length = "4"
                                   )