Description
The NaiveBayesPredict function uses the model output by the NaiveBayesReduce function to predict the outcomes for a test set of data.
Usage
td_naivebayes_predict_sqle ( modeldata = NULL, newdata = NULL, id.col = NULL, responses = NULL, formula = NULL ) ## S3 method for class 'td_naivebayes_mle' predict( modeldata = NULL, newdata = NULL, id.col = NULL, responses = NULL, formula = NULL)
Arguments
modeldata |
Required Argument. |
newdata |
Required Argument. |
id.col |
Required Argument. |
responses |
Required Argument. |
formula |
Required Argument. |
Value
Function returns an object of class "td_naivebayes_predict_sqle" which is
a named list containing Teradata tbl object.
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_predict_example", "nb_iris_input_train","nb_iris_input_test") # Create remote tibble objects. 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_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") ) # Alternatively use S3 predict method to find the predictions. naivebayes_predict_result2 <- predict(naivebayes_train, newdata=nb_iris_input_test, id.col = "id", responses = c("virginica","setosa","versicolor"))