sfa_load_npz: Load Pre-generated Embeddings from a NumPy .npz File

View source: R/load.R

sfa_load_npzR Documentation

Load Pre-generated Embeddings from a NumPy .npz File

Description

Reads a NumPy .npz archive of pre-computed item embeddings (and, if present, the item codes, factor labels, scoring, and item text) into a tidy object that sfa, sfa_similarity, and sfa_corplot accept directly — so loading saved embeddings is one line instead of hand-rolling reticulate/NumPy calls.

Usage

sfa_load_npz(
  path,
  embeddings_key = "embeddings",
  codes_key = "codes",
  items_key = "items",
  factors_key = "factors",
  scoring_key = "scoring"
)

Arguments

path

Path to a .npz file.

embeddings_key

Name of the embeddings array in the archive (default "embeddings").

codes_key, items_key, factors_key, scoring_key

Names of the optional metadata arrays (codes, item text, factor labels, +1/-1 scoring). Missing keys are silently skipped.

Details

The archive is expected to contain a 2-D embeddings array; the other fields are optional and matched by name.

Value

An object of class "sfa_embeddings": a list with embeddings (numeric matrix, n_items x dim, with item codes as rownames when available) and any of codes, items, factors, scoring found in the archive.

See Also

sfa, sfa_similarity, sfa_corplot

Examples

## Not run: 
emb <- sfa_load_npz("DASS_items_8B.npz")
emb                                  # summary of what was loaded
sfa_corplot(sfa_similarity(emb))     # grouped heatmap, two lines total
fit <- sfa(emb)                      # or run the full analysis

## End(Not run)

semanticfa documentation built on Sept. 2, 2026, 1:07 a.m.