Skip to contents

Introduction

The get_embed function retrieves embeddings based on provided input data. This vignette demonstrates the usage of the get_embed function with example datasets included in the MUGS package.


Load the Required Library

Ensure the MUGS package is loaded before running the example:


Load Example Data

Load the example datasets for the get_embed function:

set.seed(1)
S <- matrix(rnorm(100^2), 100, 100)
library(rsvd)
#> Warning: package 'rsvd' was built under R version 4.4.1
svd <- rsvd(S, 20)

Run the get_embed Function

Run the get_embed function to extract embeddings from the data:

# Example usage of get_embed
U <- get_embed(svd, d=10, normalize=TRUE)

Examine the Output

Explore the structure and key components of the output:

# View the structure of the output
str(U)
#>  num [1:100, 1:10] -5.65e-01 -6.38e-01 3.79e-01 3.06e-01 -5.82e-05 ...

# Display the first few rows of the results
cat("\nEmbedding Results (first 5 rows):\n")
#> 
#> Embedding Results (first 5 rows):
print(head(U, 5))
#>               [,1]        [,2]       [,3]        [,4]        [,5]         [,6]
#> [1,] -5.647594e-01  0.09626616 -0.5793501 -0.10084797  0.13928182 -0.377441496
#> [2,] -6.384830e-01 -0.29585454 -0.3236334 -0.39702952 -0.17937683 -0.229562372
#> [3,]  3.786506e-01 -0.21009859 -0.2831174  0.39243036  0.02058818  0.075576728
#> [4,]  3.060991e-01 -0.26686624 -0.2882164 -0.56902082 -0.06900927 -0.003753071
#> [5,] -5.819784e-05 -0.53728680  0.3493060  0.03360345  0.12269969  0.513945126
#>             [,7]       [,8]        [,9]       [,10]
#> [1,]  0.01630144 -0.2049133 -0.17183344  0.30384089
#> [2,]  0.28273084  0.2719569  0.03996107  0.04549094
#> [3,] -0.61570868  0.3135361  0.27342339  0.14151726
#> [4,]  0.32838411  0.2242880 -0.50550587 -0.09888660
#> [5,]  0.08446232  0.3807319 -0.36149449  0.16191136

Notes

  1. Input Data: Ensure that U.1 and S.1 are properly formatted matrices or data frames.
  2. Output Structure: The output contains embeddings derived from the input data, which can be used in downstream analysis.

Summary

This vignette demonstrated the use of the get_embed function to retrieve embeddings from input data. Use this function to process your data and extract meaningful embeddings for further applications.