batch_validate | R Documentation |
Batch validate algorithms over a list of dfms
batch_validate( x, y, set = docvars(x, "training"), alg = NULL, pred = predict, as_matrix = FALSE, positive = FALSE, write_out = TRUE )
x |
A dfm or list of dfms to evaluate. |
y |
A variable in docvars of the dfms with the class (must be logical for now). |
set |
A variable in docvars indicating membership to training or test set. |
alg |
A named list of functions containing the algorithms to be evaluated (see example) |
pred |
A list of prediction functions (most packages use predict(), which is the default). Either length of 1 or same length as alg. |
as_matrix |
A list of logical values indicating if the respective alg needs the dfm converted to a matrix. |
positive |
value for the positive class. |
write_out |
Should intermediate results be written to the working directory. |
## Not run: library(quanteda) corp <- corpus(c(d1 = "Chinese Beijing Chinese", d2 = "Chinese Chinese Shanghai", d3 = "Chinese Macao", d4 = "Tokyo Japan Chinese", d5 = "Chinese Chinese Chinese Tokyo Japan")) docvars(corp, "class") <- c(TRUE, TRUE, TRUE, FALSE, FALSE) docvars(corp, "training") <- c(TRUE, TRUE, TRUE, TRUE, FALSE) test_prep <- batch_prep(corp) batch_validate(x = test_prep[1:3], y = "class", set = "training", alg = list(textmodel_nb = quanteda.textmodels::textmodel_nb, textmodel_svm = quanteda.textmodels::textmodel_svm) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.