dgpage_predict: Predict labels using a trained DGPAGE model via 1-NN...

View source: R/dpage.R

dgpage_predictR Documentation

Predict labels using a trained DGPAGE model via 1-NN classification

Description

After you have fit the DGPAGE model to some labeled training data Xtrain, you can project Xtrain and store their embeddings Ytrain, then for new data Xtest, you project them using the learned P, and perform a 1-nearest neighbor search in the low-dimensional subspace using Rnanoflann.

Usage

dgpage_predict(model, Xtest, k = 1, method = "euclidean")

Arguments

model

The list returned by dgpage_fit. Must also contain ytrain (the vector of training labels) and Ytrain (the n x r embedding of training data), which you can store yourself.

Xtest

A numeric matrix of size m \times d (test data).

k

Number of neighbors (default 1).

method

Distance method for nn. Default "euclidean".

Value

A vector of length m with predicted labels.

See Also

nn

Examples

## Not run: 
  # Suppose we already fit a model:
  # model$Ytrain <- t(model$P) %*% model$Z  # r x n -> we store its transpose below
  # model$Ytrain_t <- t(model$Ytrain)       # n x r
  # model$ytrain  <- y  # training labels
  #
  # Now we get new data Xtest:
  preds <- dgpage_predict(model, Xtest)

## End(Not run)

bbuchsbaum/discursive documentation built on April 14, 2025, 4:57 p.m.