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

Teradata® Package for R Function Reference

Product
Teradata Package for R
Release Number
17.00
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B700-4007-090K
Language
English (United States)

Description

The CFilter function is a general-purpose collaborative filter. A typical input tbl_teradata for the CFilter function is a set of sales transactions, with a column of purchased items and a column of something by which to group the purchased items; for example, a transaction id or timestamp.

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,
      null.handling = TRUE,
      use.basketgenerator = TRUE
  )

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.
Types: character OR vector of Strings (character)

join.columns

Required Argument.
Specifies the names of the input tbl_teradata columns 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

null.handling

Optional Argument.
Specifies whether to handle null values in the input. If the input data contains null values, then this argument should be TRUE.
Note: "null.handling" is only available when tdplyr is connected to Vantage 1.3.
Default Value: TRUE
Types: logical

use.basketgenerator

Optional Argument.
Specify this argument to basket_generator to generate baskets.
Note: "use.basketgenerator" is only available when tdplyr is connected to Vantage 1.3.
Default Value: TRUE
Types: logical

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")
                                 )