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

OneHotEncodingFit

Description

Function records all the parameters required for td_one_hot_encoding_transform_sqle() function.
Such as, target attributes and their categorical values to be encoded and other parameters.
Output of td_one_hot_encoding_fit_sqle() function is used by td_one_hot_encoding_transform_sqle() function for encoding the input data. It supports inputs in both sparse and dense format.

Usage

  td_one_hot_encoding_fit_sqle (
      data = NULL,
      is.input.dense = NULL,
      target.column = NULL,
      categorical.values = NULL,
      other.column = NULL,
      attribute.column = NULL,
      value.column = NULL,
      target.attributes = NULL,
      other.attributes = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

is.input.dense

Required Argument.
Specifies whether input is in dense format or sparse format.
Types: logical

target.column

Required Argument when 'is_input_dense=TRUE', disallowed otherwise.
Specifies the name of the column in "data" to be encoded.
Types: character

categorical.values

Required Argument when 'is_input_dense=TRUE', disallowed otherwise.
Specifies the categorical values to encode in one-hot form.
Types: character OR vector of Strings (character)

other.column

Required Argument when 'is_input_dense=TRUE', disallowed otherwise.
Specifies a category name for values that "categorical.values" does not specify (categorical values not to encode in one-hot form).
Default Value: 'other'
Types: character

attribute.column

Required Argument when 'is_input_dense=FALSE', disallowed otherwise.
Specifies the name of the column in "data" which contains attribute names.
Types: character

value.column

Required Argument when 'is_input_dense=FALSE', disallowed otherwise.
Specifies the name of the column in "data" which contains attribute values.
Types: character

target.attributes

Required Argument when 'is_input_dense=FALSE', disallowed otherwise.
Specifies one or more attributes to encode in one-hot form. Every target attribute must be in "attribute.column".
Types: character OR vector of Strings (character)

other.attributes

Optional Argument when 'is_input_dense=FALSE', disallowed otherwise.
For each target attribute, specifies a category name for attributes that "target.attributes" does not specify. The nth "other.attributes" corresponds to the nth "target_attribute".
Types: character OR vector of Strings (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 table or not.
When set to TRUE, results are persisted in 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 volatile table or not.
When set to TRUE, results are stored in 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 SQL Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_one_hot_encoding_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):result

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the example data.
    loadExampleData("tdplyr_example", "titanic")
    
    # Create tbl_teradata object.
    titanic_data <- tbl(con, "titanic")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Generate fit object to encode "male" and "female" values of column "sex".
    fit_obj <- td_one_hot_encoding_fit_sqle(data=titanic_data,
                                            is.input.dense=TRUE,
                                            target.column="sex",
                                            categorical.values=c("male", "female"),
                                            other.column="other")
    
    # Print the result.
    print(fit_obj$result)