| pipeline | R Documentation |
This function takes a data frame with pre-cleaned text and handles the data splitting, vectorization, model training, and evaluation.
pipeline(
vect_method,
model_name,
text_vector,
sentiment_vector,
n_gram = 1,
balance = FALSE,
tune = FALSE,
parallel = FALSE
)
vect_method |
A string specifying the vectorization method.
Defaults to
|
model_name |
A string specifying the model to train.
Defaults to
|
text_vector |
A character vector containing the **preprocessed** text. |
sentiment_vector |
A vector or factor containing the target labels (e.g., ratings). |
n_gram |
The n-gram size to use for BoW/TF-IDF. Defaults to 1. |
balance |
Logical. If TRUE, calculates inverse class weights to correct for imbalanced datasets. Defaults to FALSE. |
tune |
Logical. If TRUE, the pipeline will perform hyperparameter tuning for the selected model. Defaults to FALSE. [NEW] |
parallel |
If TRUE, runs model training in parallel. Default FALSE. |
A list containing the trained model object, the DFM template, class levels, and a comprehensive evaluation report.
df <- data.frame(
text = c("good product", "excellent", "loved it", "great quality",
"bad service", "terrible", "hated it", "awful experience",
"not good", "very bad", "fantastic", "wonderful"),
y = c("P", "P", "P", "P", "N", "N", "N", "N", "N", "N", "P", "P")
)
out <- pipeline("bow", "naive_bayes", text_vector = df$text, sentiment_vector = df$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.