NaiveBayesTextClassifierPredict
Description
The td_naivebayes_textclassifier_predict_sqle()
function uses the model generated by the
td_naivebayes_textclassifier_trainer_sqle()
function to predict the outcomes for a test set
of data.
Usage
td_naivebayes_textclassifier_predict_sqle (
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,
output.prob = FALSE,
responses = NULL,
accumulate = NULL,
...
)
Arguments
object |
Required Argument. |
newdata |
Required 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. |
output.prob |
Optional Argument. |
responses |
Optional Argument. |
accumulate |
Optional Argument. |
... |
Specifies the generic keyword arguments SQLE functions accept. volatile: 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:
Note: |
Value
Function returns an object of class "td_naivebayes_textclassifier_predict_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
# Get the current context/connection.
con <- td_get_context()$connection
# Load the example data.
loadExampleData("naivebayes_textclassifier_predict_example", "token_table",
"complaints_tokens_test")
# Create tbl_teradata object.
token_table <- tbl(con, "token_table")
complaints_tokens_test <- tbl(con, "complaints_tokens_test")
# Check the list of available analytic functions.
display_analytic_functions()
# Create a model which is output of
# td_naivebayes_textclassifier_trainer_sqle() function.
nbt_out <- td_naivebayes_textclassifier_trainer_sqle(
data = token_table,
token.column = 'token',
doc.id.column = 'doc_id',
doc.category.column = 'category',
model.type = "Bernoulli",
data.partition.column = 'category')
# Example: Run td_naivebayes_textclassifier_predict_sqle() on model
# generated by td_naivebayes_textclassifier_trainer_sqle()
# where model_type is "Bernoulli".
nbt_predict_out <- td_naivebayes_textclassifier_predict_sqle(
object = nbt_out$result,
newdata = complaints_tokens_test,
input.token.column = 'token',
doc.id.columns = 'doc_id',
model.type = "Bernoulli",
model.token.column = 'token',
model.category.column = 'category',
model.prob.column = 'prob',
newdata.partition.column = 'doc_id')
# Print the result.
print(nbt_predict_out$result)
# Alternatively use S3 predict function to run predict on the output of
# td_naivebayes_textclassifier_trainer_sqle() function.
nbt_predict_out <- predict(
nbt_out,
newdata = complaints_tokens_test,
input.token.column = 'token',
doc.id.columns = 'doc_id',
model.type = "Bernoulli",
model.token.column = 'token',
model.category.column = 'category',
model.prob.column = 'prob',
newdata.partition.column = 'doc_id')
# Print the result.
print(nbt_predict_out$result)