get_weights | R Documentation |
Extract the weights from the model.
get_weights(
object,
views = "all",
factors = "all",
abs = FALSE,
scale = FALSE,
as.data.frame = FALSE
)
object |
a trained |
views |
character vector with the view name(s), or numeric vector with the view index(es). Default is "all". |
factors |
character vector with the factor name(s) or numeric vector with the factor index(es). |
abs |
logical indicating whether to take the absolute value of the weights. |
scale |
logical indicating whether to scale all weights from -1 to 1 (or from 0 to 1 if |
as.data.frame |
logical indicating whether to return a long data frame instead of a list of matrices.
Default is |
By default it returns a list where each element is a loading matrix with dimensionality (D,K),
where D is the number of features and K is the number of factors.
Alternatively, if as.data.frame
is TRUE
, returns a long-formatted data frame with columns (view,feature,factor,value).
# Using an existing trained model on simulated data
file <- system.file("extdata", "model.hdf5", package = "MOFA2")
model <- load_model(file)
# Fetch weights in matrix format (a list, one matrix per view)
weights <- get_weights(model)
# Fetch weights for factor 1 and 2 and view 1
weights <- get_weights(model, views = 1, factors = c(1,2))
# Fetch weights in data.frame format
weights <- get_weights(model, as.data.frame = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.