I am trying to perform an image classification using the random forest model. The image is a Landsat 7 ETM with bands 4,3,2. I am running the code on Rstudio server. However, I get the following error.
ntree = 2000, na.omit(training))
Error in randomForest.default(x = training[, c("B2", "B3", "B4")], y = as.factor(training$class), :
x and xtest must have same number of columns
I have tried to change the script for the random forest and I got the following error:
rf <- train(as.factor(class) ~ B2 + B3 + B4, method = "rf", data = training, na.action = na.omit)
note: only 2 unique complexity parameters in default grid. Truncating the grid to 2 .
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :2 NA's :2
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)