Apply the trained model to new sentences.
Average word embeddings and search most similar label
vector.
# S3 method for Rcpp_fastrtext predict(object, sentences, k = 1, simplify = FALSE, unlock_empty_predictions = FALSE, threshold = 0, ...)
object | trained |
---|---|
sentences | character containing the sentences |
k | will return the |
simplify | when TRUE and |
unlock_empty_predictions | logical to avoid crash when some predictions are not provided for some sentences because all their words have not been seen during training. This parameter should only be set to TRUE to debug. |
threshold | used to limit number of words used. (optional; 0.0 by default) |
... | not used |
list containing for each sentence the probability to be associated with k
labels.
library(fastrtext) data("test_sentences") model_test_path <- system.file("extdata", "model_classification_test.bin", package = "fastrtext") model <- load_model(model_test_path) sentence <- test_sentences[1, "text"] print(predict(model, sentence))#> [[1]] #> OWNX #> 0.9999757 #>