Description Usage Arguments Value Examples
View source: R/build_features.R
Builds the feature-matrix from a text-vector
1 2 | build_features(x, term_count_min = 1, mdl = NULL, parallel = TRUE,
quiet = FALSE)
|
x |
a vector of text |
term_count_min |
a number passed to
|
mdl |
is a list of existing models-data (containing the vectorizer, the tfidf, and the lsa object), defaults to NULL, in which case it is rebuild |
parallel |
T/F if the task should be executed in parallel, defaults to TRUE |
quiet |
T/F if the function remains silent, defaults to FALSE |
a list of two: a dgCMatrix that contains the features (columns) for each text (row) and as a second element a list of the model that can be passed as mdl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | text <- c(
"This is a first text that describes something",
"A second Text That USES A LOT of CAPITALS",
"Lastly MANY!!!! (like, really a lot!) punctuations!!!"
)
build_features(text)
# a second example
train <- c("Banking is finance", "flowers are not houses", "finance is power", "houses are build")
test <- c("finance is greed", "flowers belong in the garbage", "houses are build")
a1 <- build_features(test)
a12 <- build_features(test, mdl = a1$mdl)
a2 <- build_features(train, mdl = a1$mdl)
a2$model_matrix %>% as.matrix()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.