range.textspace {ruimtehol} | R Documentation |
Get the scale of embedding similarities alongside a Starspace model
Description
Calculates embedding similarities between 2 embedding matrices and gets the range of resulting similarities.
Usage
## 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",
...
)
Arguments
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 |
Value
a list with elements
range: the range of the embedding similarities between
from
andto
quantile: the quantiles of the embedding similarities between
from
andto
hist: the histogram of the embedding similarities between
from
andto
Examples
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")
[Package ruimtehol version 0.3.2 Index]