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

tdplyr: Model Transformations

Description

Generic transform function for performing transformations using results of model fitting functions, such as

  1. td_bincode_fit()

  2. td_fit()

  3. td_non_linear_combine_fit()

  4. td_one_hot_encoding_fit()

  5. td_ordinal_encoding_fit()

  6. td_outlier_filter_fit()

  7. td_polynomial_features_fit()

  8. td_random_projection_fit()

  9. td_row_normalize_fit()

  10. td_scale_fit()

  11. td_simple_impute_fit()

  12. td_target_encoding_fit()

This function invokes respective transform methods, based on the class of the the model (first argument).

Usage

  transform(`_data`, ...)

Arguments

`_data`

Required Argument.
Model object can be one of the following class:

  1. td_bincode_fit()

  2. td_fit()

  3. td_non_linear_combine_fit()

  4. td_one_hot_encoding_fit()

  5. td_ordinal_encoding_fit()

  6. td_outlier_filter_fit()

  7. td_polynomial_features_fit()

  8. td_random_projection_fit()

  9. td_row_normalize_fit()

  10. td_scale_fit()

  11. td_simple_impute_fit()

  12. td_target_encoding_fit()

It is usually created using the following methods:

  1. td_bincode_fit()

  2. td_fit()

  3. td_non_linear_combine_fit()

  4. td_one_hot_encoding_fit()

  5. td_ordinal_encoding_fit()

  6. td_outlier_filter_fit()

  7. td_polynomial_features_fit()

  8. td_random_projection_fit()

  9. td_row_normalize_fit()

  10. td_scale_fit()

  11. td_simple_impute_fit()

  12. td_target_encoding_fit()

...

Additional arguments useful for predictions.

Value

Return value from transfrom depends on the class of the object.

Examples

  
    # Please visit individual predict in-line documentation for more examples.
    # transform.td_bincode_fit            
    # transform.td_fit                     
    # transform.td_non_linear_combine_fit 
    # transform.td_one_hot_encoding_fit    
    # transform.td_ordinal_encoding_fit    
    # transform.td_outlier_filter_fit     
    # transform.td_polynomial_features_fit 
    # transform.td_random_projection_fit   
    # transform.td_row_normalize_fit      
    # transform.td_scale_fit               
    # transform.td_simple_impute_fit       
    # transform.td_target_encoding_fit 
    
    
    #### Bincode Transform Example ####
    # 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: Convert the continuous numeric data in the column 'age' to
    #            categorical data.
    
    # First generate a model using td_bincode_fit_sqle() function to bin-code the values
    # in column 'age' using the 'Variable-Width' method type.
    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'
    )
    
    # use S3 transform function to run transform on the output of
    # td_bincode_fit_sqle() function.
    obj <- transform(bin_code_2,
                     data=titanic_data,
                     accumulate=c('passenger', 'ticket')
    )
    
    # Print the result.
    print(obj$result)