5
$\begingroup$

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)
$\endgroup$
2
$\begingroup$

Over classification may be caused by prediction bias, which is a problem for the canonical RF method and for which a number of modifications have been researched. Probably the principal approach to mitigating bias is to utilise randomised split thresholds, sometimes referred to as 'extreme' random forest. I'm not sure what flavour of RF is implemented in the R package, but certainly the problem will be more prominent when working with unbalanced classification data sets - by taking a majority vote the forest loses the information regarding the balance of votes, and that can and often will introduce bias to the classifications.

$\endgroup$
  • $\begingroup$ Good call. Prediction bias is definitely present while I am creating the training sets--thus, the need for an unsupervised approach. $\endgroup$ – Aaron Nov 10 '12 at 1:55
  • 1
    $\begingroup$ Basically classification introduces a problem - if class A has probability 51% then our best prediction is class A. Thus the balance of probabilities is lost in the predictions - they are biased towards class A. If we try and fix the bias by using a probabilistic prediction (predict class A 51% of the time, entirely randomly) then we increase prediction error. I don't see any way around that (but I'm no expert, merely an enthusiastic amateur!) $\endgroup$ – redcalx Nov 11 '12 at 2:35
2
$\begingroup$

In the randomforest function, instead of listing a y ~ x model, simply input your predictor matrix.

randomforest thinks you want to run a supervised classification because you are listing the classifying variable factor(category) as the y in your model.

$\endgroup$
  • $\begingroup$ Thanks for the reply. Any pointers on how to input the predictor matrix? $\endgroup$ – Aaron Nov 10 '12 at 14:26
  • 1
    $\begingroup$ 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. $\endgroup$ – Nick Adams Nov 12 '12 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.