sparse_encode: sparse_encode

View source: R/sparse_encodes.R

sparse_encodeR Documentation

sparse_encode

Description

Sparse encoding method by closest neighbors. Three methods are available: - hard encoding: each patient's closest neighbors are set to 1, others are set to 0 - soft encoding: each patient's closest neighbors distances are transformed by the exponential norm, others are set to 0 - epsilon encoding: each patient's neighbors closer than the mean of the distance matrix are transformed by the exponential norm and others are set to 0.

Usage

sparse_encode(
  m_data,
  dist_method = "norm_inprod",
  encoding = c("epsilon", "hard", "soft"),
  sigma,
  n_neighbors = floor(nrow(m_data)/10),
  scale_obs = TRUE
)

Arguments

m_data

Numeric matrix

dist_method

Distance method passed to qb_dist

encoding

Encoding method: one of hard, soft, or epsilon

sigma

Parameter for the exponential norm transform. Default is mean of std. dev. of distance matrix columns

n_neighbors

Number of neighbors (ignored in epsilon encoding)

scale_obs

Scale by observations

Value

Projected matrix


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