Closed jpconnel closed 1 year ago
You can try the prob
branch.
remotes::install_github("mlr-org/mlr3spatial@prob")
This works. Only binary tasks.
library(mlr3spatial)
library(sf)
library(terra)
leipzig = read_sf(system.file("extdata", "leipzig_points.gpkg", package = "mlr3spatial"), stringsAsFactors = TRUE)
# probability for forest
leipzig$forest = as.factor(ifelse(leipzig$land_cover == "forest", 1, 0))
leipzig$land_cover = NULL
task = as_task_classif_st(leipzig, target = "forest", positive = "1")
task
leipzig_raster = rast(system.file("extdata", "leipzig_raster.tif", package = "mlr3spatial"))
learner = lrn("classif.rpart", predict_type = "prob")
learner$train(task)
land_cover = predict_spatial(leipzig_raster, learner, predict_type = "prob")
plot(land_cover, type = "continuous")
Thank you! :)
Hello! Just wanted to let you know the prob
branch was not working for me, I believe because my area of interest was masked (my masked area of interest produced correct results on the main branch for response
).
I believe this is because the predictions lengths for response
and prob
are of different lengths (response prediction data includes NA's, while prob
does not). I modified the existing main branch for prob
plotting in a forked repository by replacing non-na values in the response
prediction with results from the prob
prediction. However, I'm sure there is a better solution out there
Is it possible to plot probabilities instead of responses for classif tasks using
predict_spatial
?