fit_embeds_kg: Fit embeddings to a kgraph object

View source: R/fit_embeds.R

fit_embeds_kgR Documentation

Fit embeddings to a kgraph object

Description

Build a fit_kgraph object to act as an intermediate between the embeddings and the knowledge graph. If possible (i.e. if number of features is not too large) compute all pair-wise similarities, otherwise determine the similarity threshold using a number of random pairs. If a data frame of known pairs is available, call fit_embeds_to_pairs which will produce an AUC and use the threshold_projs parameter as the specificity threshold (e.g. the default specificity of 0.9 corresponds to 10 percent false positives). Otherwise take the quantile of similarity values corresponding to threshold_projs.

Usage

fit_embeds_kg(
  m_embeds,
  similarity = c("cosine", "inprod", "cov_simi", "norm_inprod"),
  threshold_projs = 0.9,
  df_pairs = NULL,
  df_pairs_cols = 1:2,
  max_concepts = 1000,
  ...
)

Arguments

m_embeds

Embedding matrix, rownames must be able to be matched to concepts in df_pairs

similarity

Similarity measure to be computed. One of 'inprod' (inner product), 'cosine', 'cov_simi' (covariance similarity), 'norm_inprod' (normalized inner product).

threshold_projs

Specificity threshold to use for projections. (default 0.9 is equivalent to 10 percent false positives, and 0.95 to 5 percent false positives)

df_pairs

Known relationships data frame

df_pairs_cols

Columns of df_pairs for identifiers, that map to m_embeds rownames

max_concepts

Maximum number of concepts to compute all pair-wise similarities

...

Passed to gen_df_notpairs

Value

Knowledge graph, list of slots df_nodes and df_links


kgraph documentation built on April 12, 2025, 1:42 a.m.