NaiveBayesTextClassifierPredict
Description
The td_naivebayes_textclassifier_predict_mle_sqle()
function uses the model generated by the
td_naivebayes_textclassifier_mle()
function to predict the outcomes for a test set
of data.
Usage
td_naivebayes_textclassifier_predict_mle_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_mle_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 example data.
loadExampleData("naivebayes_textclassifier_predict_example", "token_table",
"complaints_tokens_test")
# Create object(s) of class "tbl_teradata".
token_table <- tbl(con, "token_table")
complaints_tokens_test <- tbl(con,"complaints_tokens_test")
# Example -
# Create the model
textclassifier_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"
)
# Predict the output
predict_out <- td_naivebayes_textclassifier_predict_mle_sqle(
newdata = complaints_tokens_test,
object = textclassifier_out,
newdata.partition.column = "doc_id",
input.token.column = "token",
doc.id.columns = c("doc_id"),
model.type = "Bernoulli",
top.k = 1
)
# Print the result.
print(nbt_predict_out$result)