# 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.
prox <- proximities(forest, cachepath=NULL)
# Calculate scaling co-ordinates.
scale <- scaling(prox, 3L)
# Plot the 1st vs 2nd scaling co-ordinates.
plot(scale[, 1], scale[, 2], col=as.integer(y), pch=as.integer(y))
# Plot the 1st vs 3rd scaling co-ordinates.
plot(scale[, 1], scale[, 3], col=as.integer(y), pch=as.integer(y))
# Plot the 2nd vs 3rd scaling co-ordinates.
plot(scale[, 2], scale[, 3], col=as.integer(y), pch=as.integer(y))
Run the code above in your browser using DataLab