Description
The NaiveBayesTextClassifierPredict (td_naivebayes_textclassifier_predict_mle
)
function uses the model output by the NaiveBayesTextClassifierTrainer
(td_naivebayes_textclassifier_mle
) function to predict outcomes
for test data.
Note: This function is only available when tdplyr is connected to Vantage 1.1
or later versions.
Usage
td_naivebayes_textclassifier_predict_mle ( object = NULL, newdata = NULL, input.token.column = NULL, doc.id.columns = NULL, model.type = "MULTINOMIAL", top.k = NULL, model.token.column = NULL, model.category.column = NULL, model.prob.column = NULL, terms = NULL, output.prob = FALSE, output.responses = NULL, newdata.sequence.column = NULL, object.sequence.column = NULL, newdata.partition.column = NULL, newdata.order.column = NULL, object.order.column = NULL )
Arguments
object |
Required Argument. |
object.order.column |
Optional Argument. |
newdata |
Required Argument. |
newdata.partition.column |
Required Argument. |
newdata.order.column |
Optional Argument. |
input.token.column |
Required Argument. |
doc.id.columns |
Required Argument. |
model.type |
Optional Argument. |
top.k |
Optional Argument. |
model.token.column |
Optional Argument. |
model.category.column |
Optional Argument. |
model.prob.column |
Optional Argument. |
terms |
Optional Argument. |
output.prob |
Optional Argument. |
output.responses |
Optional Argument.
Types: character OR vector of characters |
newdata.sequence.column |
Optional Argument. |
object.sequence.column |
Optional Argument. |
Value
Function returns an object of class
"td_naivebayes_textclassifier_predict_mle" 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_textclassifier_predict_example", "token_table","complaints_tokens_test") # Create remote tibble objects. token_table <- tbl(con, "token_table") complaints_tokens_test <- tbl(con,"complaints_tokens_test") # Example - # Run NaiveBayesTextClassifier on the train data (token_table). nbt_out <- td_naivebayes_textclassifier_mle(data = token_table, data.partition.column = c("category"), token.column = "token", doc.id.columns = c("doc_id"), doc.category.column = "category", model.type = "Bernoulli" ) # Use the generated model to predict the 'tokens' on the test data complaints_tokens_test # by using nbt_out model. nbt_predict_out <- td_naivebayes_textclassifier_predict_mle(newdata = complaints_tokens_test, object = nbt_out, newdata.partition.column = "doc_id", input.token.column = "token", doc.id.columns = c("doc_id"), model.type = "Bernoulli", top.k = 1 ) # Use the argument 'output.responses' to predict the 'tokens' on the test data complaints_tokens_test # by using nbt_out model generated by td_naivebayes_textclassifier_mle. nbt_predict_out1 <- td_naivebayes_textclassifier_predict_mle(newdata=complaints_tokens_test, newdata.partition.column='doc_id', object=nbt_out, input.token.column='token', doc.id.columns='doc_id', model.token.column='token', model.category.column='category', model.prob.column='prob', model.type='Bernoulli', terms = 'token', output.prob = TRUE, output.responses = c('crash','no_crash'), newdata.sequence.column = 'token', object.sequence.column = 'token', newdata.order.column = 'doc_id', object.order.column = 'category' )