range.textspace | R Documentation |
Calculates embedding similarities between 2 embedding matrices and gets the range of resulting similarities.
## S3 method for class 'textspace'
range(
x,
from = as.matrix(x),
to = as.matrix(x, type = "labels"),
probs = seq(0, 1, by = 0.01),
breaks = "scott",
...
)
x |
an object of class |
from |
an embedding matrix. Defaults to the embeddings of all the labels and the words from the model. |
to |
an embedding matrix. Defaults to the embeddings of all the labels. |
probs |
numeric vector of probabilities ranging from 0-1. Passed on to |
breaks |
passed on to |
... |
other parameters passed on to |
a list with elements
range: the range of the embedding similarities between from
and to
quantile: the quantiles of the embedding similarities between from
and to
hist: the histogram of the embedding similarities between from
and to
data(dekamer, package = "ruimtehol")
dekamer <- subset(dekamer, depotdat < as.Date("2017-02-01"))
dekamer$text <- strsplit(dekamer$question, "\\W")
dekamer$text <- lapply(dekamer$text, FUN = function(x) setdiff(x, ""))
dekamer$text <- sapply(dekamer$text,
FUN = function(x) paste(x, collapse = " "))
dekamer$question_theme_main <- gsub(" ", "-", dekamer$question_theme_main)
set.seed(123456789)
model <- embed_tagspace(x = tolower(dekamer$text),
y = dekamer$question_theme_main,
early_stopping = 0.8,
dim = 10, minCount = 5)
ranges <- range(model)
ranges$range
ranges$quantile
plot(ranges$hist, main = "Histogram of embedding similarities")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.