dgpage_discriminant | R Documentation |
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.
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
)
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 |
D |
The n x n diversity graph. If |
r |
The target dimension (number of discriminant directions). |
alpha , beta |
Hyperparameters in Eq. (12). |
maxiter , tol , verbose |
Passed to |
q |
If |
Algorithm:
If S
or D
is NULL
, we build them from X, y
via compute_similarity_graph
and compute_diversity_graph
.
We call dgpage_fit
to jointly learn the adjacency graph W
and projection matrix P
.
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
.
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
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.