NaiveBayesTextClassifierTrainer
Description
The td_naivebayes_textclassifier_trainer_sqle()
function calculates the
conditional probabilities for token-category pairs, the prior probabilities,
and the missing token probabilities for all categories.
The trainer function trains the model with the probability values, and
the predict function uses the values to classify documents into categories.
Usage
td_naivebayes_textclassifier_trainer_sqle (
data = NULL,
doc.category.column = NULL,
token.column = NULL,
doc.id.column = NULL,
model.type = "MULTINOMIAL",
...
)
Arguments
data |
Required Argument. |
doc.category.column |
Required Argument. |
token.column |
Required Argument. |
doc.id.column |
Optional Argument. |
model.type |
Optional Argument. |
... |
Specifies the generic keyword arguments SQLE functions accept. Below
are the generic keyword arguments: 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_trainer_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
model.data
Examples
# Get the current context/connection.
con <- td_get_context()$connection
# Load the example data.
loadExampleData("textparser_example", "complaints", "stop_words")
# Create tbl_teradata object.
complaints <- tbl(con, "complaints")
stop_words <- tbl(con, "stop_words")
# Check the list of available analytic functions.
display_analytic_functions()
# Tokenize the "text_column" and accumulate result by "doc_id" and "category".
complaints_tokenized <- td_text_parser_sqle(
data=complaints,
text.column="text_data",
object=stop_words,
remove.stopwords=TRUE,
accumulate=c("doc_id", "category"))
# Example 1 : Calculate the conditional probabilities for token-category pairs.
NaiveBayesTextClassifierTrainer_out <- td_naivebayes_textclassifier_trainer_sqle(
data=complaints_tokenized$result,
token.column="token",
doc.category.column="category")
# Print the result tbl_teradata objects.
print(NaiveBayesTextClassifierTrainer_out$result)
print(NaiveBayesTextClassifierTrainer_out$model.data)