You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to run superClass with a raster stack having both numeric and categorical layers. But it returns me the following error:
Error: variable 'Class' was fitted with type "numeric" but type "factor" was supplied
But if I use caret package directly for model building, the model runs fine. By default caret converts factor variable using one hot encoding. Here is a minimal, reproducible example
@bappa10085 You are correct, caret converts it, however, terra does not. I am first using terra::predict before feeding anything into caret which seems to have some problems with factors. I will investigate on that, thanks for reporting. For now, just convert your SpatRaster Class (the values of it) to numeric before it then gets coverted by caret again to factors. As follows:
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: