# Alternative to MDS plot for random forest visualisation

I'm using R and 'randomForest' package for binary classification.
I can MDS plot (from the same package) the initial (more or less) class separation based on training set. However, this doesn't allow me to show the newly classified data and doesn't have the most intuitive meaning.

Is there some alternative to MDS plot for random forest visualisation?
Ideally one I could use to show new data as well.

• I've edited the question to try to be more fitting here. If it's still not, I'll try SO. Thanks – vuzun Jun 26 '17 at 13:09

I would recommend using MDS since it gives the best summary at a glance.

But in favor of interpretability, after looking at variable importances, you could pick the k most significant variables (if you have a large number of predictors) and use classCenter function on the proximity matrix. This will let you visualize the representative point for each class, for every variable.

Example code:

library(ggplot2)
library(reshape2)
data(iris)
iris.rf <- randomForest(iris[,-5], iris[,5], prox=TRUE)
iris.p <- melt(classCenter(iris[,-5], iris[,5], iris.rf\$prox), id=rownames())
iris.m <- melt(iris, id='Species', variable.name = 'Var', value.name = 'Measurement')
names(iris.p) <- names(iris.m)
ggplot(iris.m, aes(x=Species, color=Species)) +
geom_point(aes(y=Measurement)) +
geom_point(data=iris.p,aes(y=Measurement), size=4, pch=15, color='grey40') +
facet_grid(.~Var)


Output:

If you have new points with Species prediction, simply add another geom_point layer with the new data and change the color or pch attributes to differentiate from old points. This will let you visualize the new points relative to training data as well as class representatives from training data.

Alternatively, you could take the variables pairwise and see the class prototypes/ centers for each variable combination. The help file ?classCenter gives an example of that.