Description Usage Arguments Examples
Wrapper for RTextTools classifier. Also performs sampling of test group if needed.
1 | procureFit(procure, random = TRUE, text.var = "text", classifier = c("svm", "maxent", "glmnet"))
|
procure |
|
random |
|
text.var |
|
classifier |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (procure, random = TRUE, text.var = "text", classifier = c("svm",
"maxent", "glmnet"))
{
dtm <- formatProcureText(procure, text.var)
if (random) {
procure$fit <- 1
procure$fit[sample(1:nrow(procure), 250)] <- 0
}
container <- create_container(dtm, procure$label, trainSize = which(procure$fit ==
1), testSize = which(procure$fit == 0), virgin = TRUE)
if (classifier[1] == "svm") {
SVM <- train_model(container, "SVM")
predictions <- classify_model(container, SVM)
}
if (classifier[1] == "maxent") {
MAXENT <- train_model(container, "MAXENT")
predictions <- classify_model(container, MAXENT)
}
if (classifier[1] == "glmnet") {
GLMNET <- train_model(container, "GLMNET")
predictions <- classify_model(container, GLMNET)
}
predictions$true.label <- procure$label[procure$fit == 0]
predictions$text <- procure[procure$fit == 0, text.var]
return(predictions)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.