Learn R Programming

RPEnsemble (version 0.2)

RPChoose: Chooses projection

Description

First chooses a projection from a block of size B2 based on a test error estimate, then classifies the training and test sets using the chosen projection.

Usage

RPChoose(XTrain, YTrain, XTest, d, B2 = 100, base = "LDA", k = c(3, 5), projmethod = "Haar", estmethod = "resub", ...)

Arguments

XTrain
An n by p matrix containing the training data feature vectors
YTrain
A vector of length n of the classes (either 1 or 2) of the training data
XTest
An n.test by p matrix of the test data
d
The lower dimension of the image space of the projections
B2
The block size
base
The base classifier one of "knn","LDA","QDA" or "other"
k
The options for k if base is "knn"
projmethod
Either "Haar" or "axis"
estmethod
Method for estimating the test errors to choose the projection: either resubstitution "resub" or leave-one-out "loo"
...
Optional further arguments if base = "other"

Value

n + n.test: the first n entries are the estimated classes of the training set, the last n.test are the estimated classes of the test set.

Details

Projects the the data using either Haar or axis-aligned random projections. Chooses the projection from a block of size B2 yielding the smallest estimate of the test error. Classifies the training set (via the same method as estmethod) and test set using the chosen projection.

References

Cannings, T. I. and Samworth, R. J. (2015) Random projection ensemble classification. http://arxiv.org/abs/1504.04595

See Also

RPParallel, RPChooseSS, lda, qda, knn

Examples

Run this code
set.seed(100)
Train <- RPModel(1, 50, 20, 0.5)
Test <- RPModel(1, 100, 20, 0.5)
Choose.out5 <- RPChoose(XTrain = Train$x, YTrain = Train$y, XTest = Test$x, 
d = 2, B2 = 5, base = "LDA", projmethod = "Haar", estmethod = "resub")
Choose.out10 <- RPChoose(XTrain = Train$x, YTrain = Train$y, XTest = Test$x, 
d = 2, B2 = 10, base = "LDA", projmethod = "Haar", estmethod = "resub")
sum(Choose.out5[1:50] != Train$y)
sum(Choose.out10[1:50] != Train$y)
sum(Choose.out5[51:150] != Test$y)
sum(Choose.out10[51:150] != Test$y)

Run the code above in your browser using DataLab