-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to run superClass
when one of the raster layer is factor
#108
Comments
@bappa10085 You are correct, logo$Class <- as.numeric(logo$Class)
rf_mod <- superClass(logo,
trainData = sf::st_as_sf(v),
responseCol = "pb",
model = "rf",
tuneLength = 1,
trainPartition = 0.7,
predict = T,
predType = "prob", #for class probabilities
mode = "classification",
kfold = 3, na.rm=TRUE)
plot(rf_mod$map) |
Does caret know how to convert the logo$Class back into a factor variable? The training data after the model suggests it treated Class as a pure numeric variable (only 6 of the 9 levels from Class are represented in the training data): rf_mod$model$trainingData |
If I understand u right its just a matter of training data, not about conversion. Executing rf_mod <- RStoolbox::superClass(logo, trainData = sf::st_as_sf(v),
responseCol = "pb",
model = "rf", tuneLength = 1, trainPartition = 0.7,
predict = T,
predType = "prob", #for class probabilities
mode = "classification",
kfold = 3, na.rm=TRUE)
length(unique(rf_mod$model$trainingData$Class)) gives back sometimes 6, 7, or 8 for me and maybe 10 test runs. It can be, that just the training split was randomly selected that some classes either are exclusively within the validation or training set or are just not really represented enough anymore to be predicted... |
I am trying to run
superClass
with a raster stack having both numeric and categorical layers. But it returns me the following error:But if I use
caret
package directly for model building, the model runs fine. By defaultcaret
convertsfactor
variable using one hot encoding. Here is a minimal, reproducible exampleThe text was updated successfully, but these errors were encountered: