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,
  ...)

Arguments

object

trained fastText model

sentences

character containing the sentences

k

will return the k most probable labels (default = 1)

simplify

when TRUE and k = 1, function return a (flat) numeric instead of a list

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

Value

list containing for each sentence the probability to be associated with k labels.

Examples

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 #>