Teradata Package for R Function Reference | 17.20 - BincodeFit - 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

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
Product Category
Teradata Vantage

BincodeFit

Description

The td_bincode_fit_sqle() function outputs a tbl_teradata of information to input to td_bincode_transform_sqle() function, which bin-codes the specified input tbl_teradata.
Bin-coding is typically used to convert numeric data to categorical data by binning the numeric data into multiple numeric bins (intervals).
The bins can have a fixed-width with auto-generated labels or can have variable widths and labels.

Usage

  td_bincode_fit_sqle (
      data = NULL,
      fit.data = NULL,
      target.columns = NULL,
      method.type = NULL,
      nbins = NULL,
      label.prefix = NULL,
      target.colnames = NULL,
      minvalue.column = NULL,
      maxvalue.column = NULL,
      label.column = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

fit.data

Optional Argument.
Specifies the input tbl_teradata containing binning parameters for VARIABLE-WIDTH. It is not needed for EQUAL-WIDTH.
Types: tbl_teradata

target.columns

Required Argument.
Specifies the input tbl_teradata columns to generate bins information and binning parameters on.
Types: character OR vector of Strings (character)

method.type

Required Argument.
Specifies the method type which will be used for histogram computation.
Permitted Values: 'EQUAL-WIDTH', 'VARIABLE-WIDTH'
Types: character

nbins

Optional Argument.
Specifies the number of bins to be used when "method.type" is 'EQUAL-WIDTH'. It is not needed for 'VARIABLE-WIDTH'. If one value is provided, it applies to all target columns, if more than one value is specified, "nbins" values apply to "target.columns" in the order specified by the user.
Types: integer OR vector of integers

label.prefix

Optional Argument.
Specify the label prefix to be used when "method.type" is 'EQUAL-WIDTH'. If one value is provided, it applies to all target columns. If more than one value is specified, "label.prefix" values apply to "target.columns" in the order specified by the user.
Default Value: target column names.
Types: character OR vector of Strings (character)

target.colnames

Optional Argument.
Specifies the "fit.data" column which contains column name for which bins are specified.
Default Value: ColumnName.
Types: character

minvalue.column

Optional Argument.
Specifies the "fit.data" column which contains Min Value for the specified bins.
Default Value: MinValue.
Types: character

maxvalue.column

Optional Argument.
Specifies the "fit.data" column which contains Max Value for the specified bins.
Default Value: MaxValue.
Types: character

label.column

Optional Argument.
Specifies the "fit.data" column which contains label for which bins are specified.
Default Value: Label.
Types: character

...

Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:

persist:
Optional Argument.
Specifies whether to persist the results of the function in a table ornot. When set to TRUE, results are persisted in a table; otherwise, results are garbage collected at the end of the session.
Default Value: FALSE
Types: logical

volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table or not. When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical

Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:

  • "<input.data.arg.name>.partition.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.hash.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.order.column" accepts character OR vector of Strings (character) (Strings)

  • "local.order.<input.data.arg.name>" accepts logical

Note:
These generic arguments are supported by tdplyr if the underlying SQLE function supports it, else an exception is raised.

Value

Function returns an object of class "td_bincode_fit_sqle" which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator using the name(s):

  1. result

  2. output.data

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the example data.
    loadExampleData("tdplyr_example", "titanic", "bin_fit_ip")
    
    # Create tbl_teradata object.
    titanic_data <- tbl(con, "titanic")
    bin_fit_ip <- tbl(con, "bin_fit_ip")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Transform the data using td_bincode_fit_sqle() with
    # 'method.type' as 'Variable-Width'.
    bin_code_1 <- td_bincode_fit_sqle(data=titanic_data,
                                      fit.data=bin_fit_ip,
                                      fit.data.order.column = c('minVal',
                                                               'maxVal'),
                                      target.columns='age',
                                      minvalue.column='minVal',
                                      maxvalue.column='maxVal',
                                      label.column='label',
                                      method.type='Variable-Width',
                                      label.prefix='label.prefix'
                                     )
    
    # Print the result.
    print(bin_code_1$result)
    
    # Example 2: Transform the data using td_bincode_fit_sqle() with
    # 'method.type' as 'Equal-Width'.
    bin_code_2 <- td_bincode_fit_sqle(data=titanic_data,
                                      target.columns='age',
                                      method.type='Equal-Width',
                                      nbins=2,
                                      label.prefix='label.prefix'
                                     )
    
    # Print the result.
    print(bin_code_2$result)