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

NaiveBayesPredict

Description

td_naivebayes_predict_mle_sqle() function predicts the outcomes for a test set of data using the model output generated by the td_naivebayes_mle() function.

Usage

  td_naivebayes_predict_mle_sqle (
      modeldata = NULL,
      newdata = NULL,
      id.col = NULL,
      responses = NULL,
      formula = NULL,
      ...
  )

Arguments

modeldata

Required Argument.
Specifies the tbl_teradata which contains the model
data generated by the td_naivebayes_mle() function or instance of td_naivebayes_mle.
Types: tbl_teradata or td_naivebayes_mle

newdata

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

id.col

Required Argument.
Specifies the name of the column that contains the ID that uniquely identifies the test input data.
Types: character

responses

Required Argument.
Specifies a list of Responses to output.
Types: character OR vector of Strings (character)

formula

Optional Argument.
Required when the modeldata is a tbl_teradata.
A string consisting of "formula".
Specifies the model to be fitted. Only basic formula of the "col1 ~ col2 + col3 +..." form is supported and all variables must be from the same virtual data frame object. The response should be column of type real, numeric, integer or logical.
Types: character

...

Specifies the generic keyword arguments which 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 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 SQLE Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_naivebayes_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

  

    # Load example data.
    loadExampleData("naivebayes_predict_example", "nb_iris_input_train","nb_iris_input_test")

    # Create object(s) of class "tbl_teradata".
    nb_iris_input_train <- tbl(con, "nb_iris_input_train")
    nb_iris_input_test <- tbl(con, "nb_iris_input_test")

    # Example 1 -
    # Run the train function.
    naivebayes_train <- td_naivebayes_mle(formula = (species ~ petal_length + sepal_width +
                                                     petal_width + sepal_length),
                                          data = nb_iris_input_train)

    # Generate prediction using output of train function.
    naivebayes_predict_result1 <- td_naivebayes_predict_mle_sqle(newdata=nb_iris_input_test,
                                  formula = (species ~ petal_length + sepal_width + petal_width +
                                             sepal_length),
                                  modeldata = naivebayes_train,
                                  id.col = "id",
                                  responses = c("virginica","setosa","versicolor")
                                  )
    # Print the result.
    print(naivebayes_predict_result1$result)