Skip to content

Simplex Projection

Simplex projection is the core prediction algorithm in EDM. It uses nearest neighbors in the embedded state space to make predictions.

For a query point q in E-dimensional space:

  1. Find the E+1 nearest neighbors in the library set (forming a simplex)
  2. Compute weights inversely proportional to distance: w_i = exp(-d_i / d_min)
  3. Predict as the weighted average of the neighbors’ target values
from edmkit.simplex_projection import simplex_projection
# X: library embeddings (N, E)
# Y: library targets (N,) or (N, D)
# Q: query embeddings (M, E)
predictions = simplex_projection(X, Y, Q)

All inputs support a leading batch dimension for parallel evaluation:

# X: (B, N, E), Y: (B, N, D), Q: (B, M, E)
predictions = simplex_projection(X, Y, Q) # -> (B, M, D)

Use the mask parameter to exclude specific library points:

mask = np.ones(N, dtype=bool)
mask[100:110] = False # Exclude points 100-109
predictions = simplex_projection(X, Y, Q, mask=mask)

The loo function performs leave-one-out prediction with Theiler window exclusion, which prevents temporal neighbors from being used as predictors:

from edmkit.simplex_projection import loo
predictions = loo(X, Y, theiler_window=5)
# Each point predicted using all others except those within ±5 time steps

The knn function handles neighbor finding, automatically choosing the best backend:

  • KDTree (SciPy) for lower dimensions or smaller datasets
  • usearch for high-dimensional or large-scale data (E >= 15 and N >= 10,000)
from edmkit.simplex_projection import knn
distances, indices = knn(X, Q, k=10)