lol.xval.eval {lolR} | R Documentation |
Embedding Cross Validation
Description
A function for performing leave-one-out cross-validation for a given embedding model. This function produces fold-wise
cross-validated misclassification rates for standard embedding techniques. Users can optionally specify custom embedding techniques
with proper configuration of alg.*
parameters and hyperparameters. Optional classifiers implementing the S3 predict
function can be used
for classification, with hyperparameters to classifiers for determining misclassification rate specified in classifier.*
parameters and hyperparameters.
Usage
lol.xval.eval(
X,
Y,
r,
alg,
sets = NULL,
alg.dimname = "r",
alg.opts = list(),
alg.embedding = "A",
classifier = lda,
classifier.opts = list(),
classifier.return = "class",
k = "loo",
rank.low = FALSE,
...
)
Arguments
X |
|
Y |
|
r |
the number of embedding dimensions desired, where |
alg |
the algorithm to use for embedding. Should be a function that accepts inputs |
sets |
a user-defined cross-validation set. Defaults to
|
alg.dimname |
the name of the parameter accepted by |
alg.opts |
the hyper-parameter options you want to pass into your algorithm, as a keyworded list. Defaults to |
alg.embedding |
the attribute returned by
|
classifier |
the classifier to use for assessing performance. The classifier should accept |
classifier.opts |
any extraneous options to be passed to the classifier function, as a list. Defaults to an empty list. |
classifier.return |
if the return type is a list,
|
k |
the cross-validated method to perform. Defaults to
|
rank.low |
whether to force the training set to low-rank. Defaults to
|
... |
trailing args. |
Value
Returns a list containing:
lhat |
the mean cross-validated error. |
model |
The model returned by |
classifier |
The classifier trained on all of the embedded data. |
lhats |
the cross-validated error for each of the |
Details
For more details see the help vignette:
vignette("xval", package = "lolR")
For extending cross-validation techniques shown here to arbitrary embedding algorithms, see the vignette:
vignette("extend_embedding", package = "lolR")
For extending cross-validation techniques shown here to arbitrary classification algorithms, see the vignette:
vignette("extend_classification", package = "lolR")
Author(s)
Eric Bridgeford
Examples
# train model and analyze with loo validation using lda classifier
library(lolR)
data <- lol.sims.rtrunk(n=200, d=30) # 200 examples of 30 dimensions
X <- data$X; Y <- data$Y
r=5 # embed into r=5 dimensions
# run cross-validation with the nearestCentroid method and
# leave-one-out cross-validation, which returns only
# prediction labels so we specify classifier.return as NaN
xval.fit <- lol.xval.eval(X, Y, r, lol.project.lol,
classifier=lol.classify.nearestCentroid,
classifier.return=NaN, k='loo')
# train model and analyze with 5-fold validation using lda classifier
data <- lol.sims.rtrunk(n=200, d=30) # 200 examples of 30 dimensions
X <- data$X; Y <- data$Y
xval.fit <- lol.xval.eval(X, Y, r, lol.project.lol, k=5)
# pass in existing cross-validation sets
sets <- lol.xval.split(X, Y, k=2)
xval.fit <- lol.xval.eval(X, Y, r, lol.project.lol, sets=sets)