Teradata R Package Function Reference - 16.20 - CFilter - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
16.20
created_date
February 2020
category
Programming Reference
featnum
B700-4007-098K

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 names of the input tbl_teradata columns that contain the data to filter.

join.columns

Required Argument.
Specifies the names of the input tbl_teradata columns to join.

add.columns

Optional Argument.
Specifies the names of the input columns to copy to the output table. The function partitions the input data and the output table 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.

partition.key

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

max.itemset

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

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.

Value

Function returns an object of class "td_cfilter_mle" which is a named list containing Teradata tbl objects.
Named list members can be referenced directly with the "$" operator using 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 remote tibble objects.
    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")
                                 )