# How to perform unsupervised Random Forest classification using R?

I am working with the randomForest and predict packages in R for land classification. For each 4-band CIR image, I have created training data in a GIS, run the training data through a model to produce a .csv, which is then input into R's randomForest algorithm. I am finding the Random Forest supervised classification is seriously overclassifying areas. In fact, I am producing better results using the unsupervised ISODATA algorithm.

Is there a way to implement unsupervised classification with the randomForest package in R? I have attached a section of code I've been using to run supervised random forest classification.

myrf = randomForest(factor(category) ~ band1 + band2 + band3 + band4, data = intable,
ntree=2000,
importance = TRUE)

predict(rasters, myrf, filename="RFtest7.img", type="response",
index=1, na.rm=TRUE, progress="window", overwrite=TRUE)


• Construct your matrix so that rows are observations and columns are predictor variables, and input this instead of your y ~ x model. You may want to check help(randomforest) to make sure you wouldn't have to transpose this (columns as observations and rows are variables), as I don't remember the format that randomforest likes to see. – Nick Adams Nov 12 '12 at 19:06