marginTree.cv {marginTree}R Documentation

Cross-validation of the margin tree classifier

Description

A function to cross-validate the margin tree classifier

Usage

marginTree.cv(x, y, train.obj, nfold = min(table(y)), folds = NULL, threshold = NULL, n.threshold=20)

Arguments

x Data of feature values, n samples by p features
y Vector of class labels
train.obj Output from call to marginTree
nfold Number of cross-validation folds (default 10)
folds A list with nfold components, each component a vector of indices of the samples in that fold. By default a (random) balanced cross-validation is used
threshold Optional vector of threshold values, for feature selection
n.threshold Number of threshold value for feature selection (default 10)

Details

marginTree.cv Does K-fold cross-validation of a margin tree classifier, to choose the threshold parameter for feature selection.

Value

A list with components:

threshold Threshold values tried
error CV misclassification errors for each threshold
size Average number of features used at each threshold
size.indiv Matrix of number of features used at each split (rows) and at each threshold (columns).
yhat Matrix of cross-validated predictions.
y Vector of outcome values
folds Indices of CV folds
call The calling sequence

Author(s)

Robert Tibshirani and Trevor Hastie

References

Rob Tibshirani and Trevor Hastie. Tech report. Feb. 2006. Margin trees for high-dimensional classification Available at http://www-stat.stanford.edu/~tibs/research.html

Examples

#generate some data with 5 classes and 100 features
set.seed(543)

x=matrix(rnorm(40*1000),nrow=40)
y=sort(rep(1:5,8))
x[y==2 | y==3, 1:50]=x[y==2|y==3, 1:50]+1
x[y==3,51:100]=x[y==3,51:100]+1
x[y==4|y==5,1:50]=x[y==4|y==5,1:50]-1
x[y==5, 51:100]=x[y==5,51:100]+1



#train the classifier

train.obj<-  marginTree(x,y)

# do cross-validation
cv.obj<- marginTree.cv(x,y,train.obj)

# examine results

cv.obj


[Package marginTree version 1.00 Index]