dgpage_discriminant: Fit DGPAGE and return a discriminant_projector

View source: R/dpage.R

dgpage_discriminantR Documentation

Fit DGPAGE and return a discriminant_projector

Description

This function wraps dgpage_fit but returns a discriminant_projector (subclass "dgpage_projector") so that you can use the same predict interface as for other discriminant methods.

Usage

dgpage_discriminant(
  X,
  y,
  S = NULL,
  D = NULL,
  r = 2,
  alpha = 0.001,
  beta = 1e-05,
  maxiter = 20,
  tol = 1e-05,
  verbose = TRUE,
  q = 1.5
)

Arguments

X

A numeric matrix of size n x d (training samples).

y

A factor (or coercible to factor) of length n (class labels).

S

The n x n similarity graph. If NULL, we compute it from X,y.

D

The n x n diversity graph. If NULL, we compute it from X,y.

r

The target dimension (number of discriminant directions).

alpha, beta

Hyperparameters in Eq. (12).

maxiter, tol, verbose

Passed to dgpage_fit.

q

If S or D is NULL, we use q in compute_similarity_graph. Default 1.5.

Details

Algorithm:

  1. If S or D is NULL, we build them from X, y via compute_similarity_graph and compute_diversity_graph.

  2. We call dgpage_fit to jointly learn the adjacency graph W and projection matrix P.

  3. We create a discriminant_projector object with:

    • v = result$P (the loadings),

    • s = X %*% result\$P (the training scores),

    • sdev a vector of stdev per dimension,

    • labels = y.

    We store W and other metadata in the returned object.

NOTE: The dgpage_predict for 1-NN classification can now be replaced by a new S3 predict method that lives under dgpage_projector.

Value

An object of class c("dgpage_projector","discriminant_projector","bi_projector",...) containing:

  • v : the d x r loadings

  • s : the n x r scores

  • sdev : numeric vector of length r with stdevs of columns of s

  • labels : the training labels

  • W : the learned n x n adjacency graph

  • objective: final objective value

  • alpha,beta : stored hyperparameters

Examples

## Not run: 
  X <- matrix(rnorm(100*5), 100, 5)
  y <- factor(rep(1:2, each=50))
  dp <- dgpage_discriminant(X, y, r=2)
  preds_class  <- predict(dp, new_data=X, method="lda", type="class")
  preds_1nn    <- predict(dp, new_data=X, method="1nn")
  mean(preds_class == y)
  mean(preds_1nn   == y)

## End(Not run)

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