embed_pagespace | R Documentation |
Build a Starspace model for interest-based recommendation (pagespace). For example a user clicks on a webpage.
embed_pagespace(
x,
model = "pagespace.bin",
early_stopping = 0.75,
useBytes = FALSE,
...
)
x |
a list where each list element contains a character vector of pages which the user was interested in |
model |
name of the model which will be saved, passed on to |
early_stopping |
the percentage of the data that will be used as training data. If set to a value smaller than 1, 1- |
useBytes |
set to TRUE to avoid re-encoding when writing out train and/or test files. See |
... |
further arguments passed on to |
an object of class textspace
as returned by starspace
.
data(dekamer, package = "ruimtehol")
x <- subset(dekamer, !is.na(question_theme))
x <- strsplit(x$question_theme, ",")
x <- lapply(x, FUN=unique)
str(x)
set.seed(123456789)
model <- embed_pagespace(x, dim = 5, epoch = 5, minCount = 10, label = "__THEME__")
plot(model)
predict(model, "__THEME__MARINE __THEME__DEFENSIEBELEID")
pagevectors <- as.matrix(model)
mostsimilar <- embedding_similarity(pagevectors,
pagevectors["__THEME__MIGRATIEBELEID", ])
head(sort(mostsimilar[, 1], decreasing = TRUE), 3)
mostsimilar <- embedding_similarity(pagevectors,
pagevectors["__THEME__DEFENSIEBELEID", ])
head(sort(mostsimilar[, 1], decreasing = TRUE), 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.