ML beginner here, so apologies for any wrong terminology.
I have two questions. Firstly, is it possible to add an additional "unknown" class, when the probability of any one class is very low? And, secondly, how can I return the probability values for each cell for each class as a layer?
Here's a reprex and shortened version of the code I'm running:
library(terra, exclude = "resample") # working with rasters
library(sf) # working with vectors
library(mlr3verse) # machine learning - lazy load of most mlr3 packages
library(mlr3spatiotempcv) # spatial resampling methods
library(mlr3spatial)
leipzig = read_sf(system.file("extdata", "leipzig_points.gpkg", package = "mlr3spatial"), stringsAsFactors = TRUE)
leipzig_raster = rast(system.file("extdata", "leipzig_raster.tif", package = "mlr3spatial"))
task = as_task_classif_st(leipzig,
id = "veg_class",
target = "land_cover",
backend = leipzig)
resample_method = rsmp("repeated_spcv_coords", folds = 10)
rf_ranger_lrn = lrn("classif.ranger", predict_type = "prob", importance = "impurity")
resample_rf = resample(task = task,
learner = rf_ranger_lrn,
resampling = resample_method,
store_models = FALSE)
rf_ranger_lrn$train(task)
classes <- terra::predict(leipzig_raster, rf_ranger_lrn, na.rm = TRUE)