feat: add probability prediction to predict_spatial()#111
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The prediction type is taken from the predict_type of the learner. For classification learners with predict_type "prob", predict_spatial() returns one raster layer or one vector column per class. Works with multiclass tasks and rasters containing missing values. Closes #88 Closes #89 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #88
Closes #89
Summary
Reimplementation of #89 on current main.
predict_spatial()now supports probability predictions. Instead of adding apredict_typeargument, the prediction type is taken from the$predict_typeof the learner, so a mismatch between argument and learner state is impossible.LearnerClassifSpatialmirrors the wrapped learner's$predict_typeand fills a full-size probability matrix withNaNrows for incomplete observations. Only the column names are carried over, which fixes the dimension error with masked rasters reported in Support for plotting probabilities in predict_spatial #88.terra::writeValues()receives the full probability matrix, so multiclass tasks are supported. Layers are named after the class levels, and the categorical-labels step is skipped for probability output.$predict_newdata()instead of$predict()because predicting probabilities directly on an unsupervised task fails mlr3's prediction-data check.classif.ranger/regr.ranger.Verification
🤖 Generated with Claude Code