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

DecisionTreePredict

Description

The td_decision_tree_predict_mle_sqle() function applies a tree model to a data input, outputting predicted labels for each data point.

Usage

  td_decision_tree_predict_mle_sqle (
      object = NULL,
      newdata = NULL,
      attr.table.groupby.columns = NULL,
      attr.table.pid.columns = NULL,
      attr.table.val.column = NULL,
      output.response.probdist = FALSE,
      accumulate = NULL,
      output.responses = NULL,
      ...
  )

Arguments

object

Required Argument.
Specifies the name of the tbl_teradata containing the output model from td_decision_tree_sqle() function or instance of td_decision_tree_mle_sqle.
Types: tbl_teradata or td_decision_tree_mle_sqle

newdata

Required Argument.
Specifies the tbl_teradata containing the attribute names and the values.
Types: tbl_teradata

attr.table.groupby.columns

Required Argument.
Specifies the names of the columns on which newdata is
partitioned. Each partition contains one attribute of the input data.
Types: character OR vector of character

attr.table.pid.columns

Required Argument.
Specifies the names of the columns that define the data point
identifiers.
Types: character OR vector of character

attr.table.val.column

Required Argument.
Specifies the name of the column that contains the input values.
Types: character

output.response.probdist

Optional Argument.
Specifies whether to output probabilities.
Note: "output.response.probdist" argument can accept input value TRUE only when tdplyr is connected to Vantage 1.0 Maintenance Update 2 version or later.
Default Value: FALSE
Types: logical

accumulate

Optional Argument.
Specifies the name(s) of the input tbl_teradata column(s) to copy to the output.
Types: character OR vector of character

output.responses

Optional Argument.
Required if "output.response.probdist" is TRUE.
Specifies all responses in newdata.
Types: character OR vector of 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 character (Strings)

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

  • "<input.data.arg.name>.order.column" accepts character or vector of 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_decision_tree_predict_mle_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("decisiontreepredict_example", "iris_attribute_test", "iris_attribute_output")
    
    # Create tbl_teradata object.
    iris_attribute_test <- tbl(con, "iris_attribute_test")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: First create tbl_teradata of trained Decision Tree Model and then
    #            perform prediction using "td_decision_tree_predict_mle_sqle()" function.
    
    # Create tbl_teradata of trained Decision Tree Model.
    td_decision_tree_out  = tbl(con, "iris_attribute_output")
    
    # Run predict on the trained decision tree model.
    decision_tree_predict_out <- td_decision_tree_predict_mle_sqle(
                                  newdata=iris_attribute_test,
                                  newdata.partition.column='pid',
                                  object=td_decision_tree_out,
                                  attr.table.groupby.columns='attribute',
                                  attr.table.pid.columns='pid',
                                  attr.table.val.column='attrvalue',
                                  accumulate='attribute')
    # Print output.
    print(decision_tree_predict_out$result)