Teradata Package for R Function Reference | 17.20 - PolynomialFeaturesTransform - 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
ft:locale
en-US
ft:lastEdition
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
lifecycle
latest
Product Category
Teradata Vantage

PolynomialFeaturesTransform

Description

td_polynomial_features_transform_sqle() function generates a feature matrix of all polynomial combinations of the feature by extracting the target column, degree, bias and interaction information from the output of the td_polynomial_features_fit_sqle() function.

Usage

  td_polynomial_features_transform_sqle (
      data = NULL,
      object = NULL,
      accumulate = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

object

Required Argument.
Specifies the tbl_teradata containing the output of generated by td_polynomial_features_fit_sqle() function or the instance of td_polynomial_features_fit_sqle.
Types: tbl_teradata or td_polynomial_features_fit_sqle

accumulate

Optional Argument.
Specifies the names of input tbl_teradata columns to copy to the output.
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 a table or not.
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 SQL Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_polynomial_features_transform_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", "numerics")
    
    # Create tbl_teradata object.
    numerics <- tbl(con, "numerics")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Generate feature tbl_teradata for all 2D polynomial combination of columns
    #            "integer_col" and "smallint_col".
    fit_obj <- td_polynomial_features_fit_sqle(
                                    data=numerics,
                                    target.columns=c("integer_col", "smallint_col"),
                                    degree=2)
    
    # Print the result.
    print(fit_obj$result)
    print(fit_obj$output.data)
    
    # Generate feature matrix. Note that tbl_teradata representing
    # the model is passed as input to "object".
    obj <- td_polynomial_features_transform_sqle(data=numerics,
                                                 object=fit_obj$result)
    
    # Print the result.
    print(obj$result)
    
    # Example 2: Generate feature matrix. Note that model is passed as instance of
    #            td_polynomial_features_fit_sqle to "object".
    obj1 <- td_polynomial_features_transform_sqle(data=numerics,
                                                  object=fit_obj)
    
    # Print the result.
    print(obj1$result)
    
    
    # Alternatively use S3 transform function to run transform on the output of
    # td_polynomial_features_fit_sqle() function.
    
    obj1 <- transform(fit_obj,
                      data=numerics)
    
    # Print the result.
    print(obj1$result)