Random forest classification is not stable

I classified my images by using the Random forest in SNAP but every time that I run RF in SNAP and then I calculate overall accuracy, results are different?

First time: 44.85
Second time: 38.9751
Third time: 43.9358
Do you know why? If results are different, then it is not logical using it.
I found some solutions but RF does not have so many options to change. What should I do?

Thanks in advance,

Hi @teflis,

Be aware that the accuracy assessment that RF performs only checks how well your model was able to classify the training data (in literature, “out of the bag” samples). If you want to know your classification accuracy you will have to run an independent accuracy assesment (not possible in SNAP btw).

To have different results each time you run the model makes sense since RF has a strong random component (as the name indicates). Each tree in the forest is created using a random subset of your training dataset and each node in a tree is created using a radom subset of variables.

When you run the model again, the process is repeated and new subsets are selected. That is why you have different results. If you want to apply always the same model, you can save it and loaded in the RF window in SNAP.


1 Like

How can I run a model that makes sense? I have 3 images that I plan to apply same RF model on them. As you mentioned before, When I run the model again, the process is repeated and new subsets are selected, then subsets are different in any process.
I want to apply same model for any images but when I chose same model, then I can not choose any images and they are inactive.

@teflis, do you want to run a separate RF classification on each image or run 1 RF classification using as input the three images?

@MCG I want to run 1 RF classification (same RF on all images) on images (one time one image, another time two image and so on) but by different trees numbers.

I mean I applied a RF classifier and then it is saved automaticly, I want to apply it on all images because as I heard by this way, we can avoid instability in RF.

@MCG I want to apply always the same model, I saved it and loaded in the RF window in SNAP but I also want to apply same model on different combination images with different trees.
I do not know is it possible to apply the same model by changing number of trees and different combinations?
Please look at below images, I chose ‘classifier is named ‘phase1’’ and you can change number of trees and image combination here but I am not sure this way is ok or not?


l have faced problem with RF classifier. l used 6 different time image, So combine in arc map. So l have 24 bands, but from visualize result is not good learn. How to combine image in SNAP?