Teradata Package for R Function Reference | 17.20 - PolynomialFeaturesFit - 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
Product Category
Teradata Vantage

PolynomialFeaturesFit

Description

td_polynomial_features_fit_sqle() function stores all the specified values in the argument in a tbl_teradata format.
All polynomial combinations of the features with degrees less than or equal to the specified degree are generated. For example, for a two-dimensional input sample [x, y], the degree-2 polynomial features are [x, y, x-squared, xy, y-squared, 1].

Usage

  td_polynomial_features_fit_sqle (
      data = NULL,
      target.columns = NULL,
      include.bias = TRUE,
      interaction.only = FALSE,
      degree = 2,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

target.columns

Required Argument.
Specifies the name(s) of the column(s) in "data" for which polynomial features needs to be generated.
Types: character OR vector of Strings (character)

include.bias

Optional Argument.
Specifies whether to include bias column in the output or not.
A bias column acts as an intercept term in a linear model.
Default Value: TRUE
Types: logical

interaction.only

Optional Argument.
Specifies whether to output polynomial combinations only for interaction features (features that are products of at most degree distinct input features).
Default Value: FALSE
Types: logical

degree

Optional Argument.
Specifies the maximum degree of the input features to output polynomial combinations.
Permitted Values: 1, 2, 3
Default Value: 2
Types: integer

...

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_polynomial_features_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. output.data

  2. 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: Create fit object to create polynomial features for 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)