Teradata R Package Function Reference | 17.00 - 17.00 - CFilter - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

The CFilter function is a general-purpose collaborative filter.

Usage

  td_cfilter_mle (
      data = NULL,
      input.columns = NULL,
      join.columns = NULL,
      add.columns = NULL,
      partition.key = "col1_item1",
      max.itemset = 100,
      data.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies the name of the tbl_teradata that contains the data to filter.

input.columns

Required Argument.
Specifies the columns of input tbl_teradata that contain the data to filter.
Types: character OR vector of Strings (character)

join.columns

Required Argument.
Specifies the columns input tbl_teradata to join.
Types: character OR vector of Strings (character)

add.columns

Optional Argument.
Specifies the names of the input columns to copy to the output tbl_teradata. The function partitions the input data and the output tbl_teradata on these columns. By default, the function treats the input data as belonging to one partition.
Note: Specifying a column as both an "add_column" and a "join_column" causes incorrect counts in partitions.
Types: character OR vector of Strings (character)

partition.key

Optional Argument.
Specifies the names of the output column to use as the partition key.
Default Value: "col1_item1"
Types: character

max.itemset

Optional Argument.
Specifies the maximum size of the item set.
Default Value: 100
Types: integer

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_cfilter_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.table

  2. output

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    # sales_transactions dataset contains sales transaction data from an office supply chain store. 
    loadExampleData("cfilter_example", "sales_transaction")
    
    # Create object(s) of class "tbl_teradata".
    sales_transaction <- tbl(con, "sales_transaction")
    
    # Example 1 -  Collaborative Filtering by Product.
    td_cfilter_out1 <- td_cfilter_mle(data = sales_transaction,
                                 input.columns = c("product"),
                                 join.columns = c("orderid"),
                                 add.columns = c("region")
                                 )
    
    # Example 2 - Collaborative Filtering by Customer Segment.
    td_cfilter_out2 <- td_cfilter_mle(data = sales_transaction,
                                 input.columns = c("customer_segment"),
                                 join.columns = c("product")
                                 )