NaiveBayesPredict
Description
The NaiveBayesPredict function uses the model output by the
NaiveBayesReduce td_naivebayes_mle
function to predict
the outcomes for a test dataset.
Usage
td_naivebayes_predict_mle_sqle (
modeldata = NULL,
newdata = NULL,
id.col = NULL,
responses = NULL,
formula = NULL,
newdata.order.column = NULL,
modeldata.order.column = NULL
)
## S3 method for class 'td_naivebayes_mle'
predict(
modeldata = NULL,
newdata = NULL,
id.col = NULL,
responses = NULL,
formula = NULL,
newdata.order.column = NULL,
modeldata.order.column = NULL)
Arguments
modeldata |
Optional Argument. |
modeldata.order.column |
Optional Argument. |
newdata |
Required Argument. |
newdata.order.column |
Optional Argument. |
id.col |
Required Argument. |
responses |
Required Argument. |
formula |
Required Argument. Required when the "modeldata" is a tbl_teradata. |
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 can be referenced directly with the "$" operator
using the 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 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")
)
# 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"))