# Classify cars in the Cars93 data set by type (Compact, Large,
# Midsize, Small, Sporty, or Van).
# Load data.
data(Cars93, package="MASS")
x <- Cars93
y <- Cars93$Type
# Select variables with which to train model.
vars <- c(4:22)
# Run model, grow 30 trees.
forest <- bigrfc(x, y, ntree=30L, varselect=vars, cachepath=NULL)
# Calculate proximity matrix and scaling co-ordinates, and plot
# them.
prox <- proximities(forest, cachepath=NULL)
scale <- scaling(prox)
plot(scale, col=as.integer(y) + 2, pch=as.integer(y) + 2)
# Calculate outlier scores, and circle the top 20% percent of
# them in red.
outscores <- outliers(forest)
points(scale[outscores > quantile(outscores, probs=0.8), ],
col=2, pch=1, cex=1.5)
Run the code above in your browser using DataLab