Teradata Package for R Function Reference | 17.00 - NaiveBayes - 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

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
NaiveBayes

Description

The NaiveBayes function (NaiveBayesMap and NaiveBayesReduce functions combined) generate a model from training data. A tbl_teradata of training data is input to the NaiveBayesMap function and its output is the input to the NaiveBayesReduce function which outputs the model.

Usage

  td_naivebayes_mle (
      formula = NULL,
      data = NULL,
      data.sequence.column = NULL,
      data.order.column = NULL
  )

Arguments

formula

Required Argument.
An object of class "formula". Specifies the model to be fitted. Only basic formula of the (col1 ~ col2 + col3 +...) form are supported and all variables must be from the same tbl_teradata object. The response should be a column of type real, numeric, integer or logical.

data

Required Argument.
Specifies the tbl_teradata defining the input training data.

data.order.column

Optional Argument.
Specifies Order By columns for "data".
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_naivebayes_mle" which is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator using name: result.

Examples

  
    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("naivebayes_example1", "nb_iris_input_train")
    
    # Create object(s) of class "tbl_teradata".
    nb_iris_input_train <- tbl(con, "nb_iris_input_train")

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