Skip to content

Compare fitted models side by side - #24

Merged
Abson-dev merged 2 commits into
masterfrom
feat/compare-models
Dec 1, 2026
Merged

Abson-dev merged 2 commits into
masterfrom
feat/compare-models

Conversation

@Abson-dev

Copy link
Copy Markdown
Owner

Summary

Users fit several methods, but each result lived on its own page, so choosing between models, or deciding which belong in an ensemble, meant clicking back and forth. This PR puts them side by side.

sdmApp_compare(fits, metric = c("auc", "tss", "boyce"))

  • Returns one row per model, ordered by the chosen metric: the mean and SD of its cross-validated AUC, TSS and Boyce index, its numbers of predictors and points, its folds ("4 random" or "3 blocks") and its settings (or "defaults").
  • Showing points and folds makes it visible when models were not fitted on the same data and folds, and so can't be compared fairly.
  • Names in the list label the models; otherwise the method's label is used. NULL entries (models never fitted) are dropped. Non-fits give an error.

App: a "Compare models" tab, first on the Ensemble page

It works before any ensemble is built, and shows:

  • the comparison table, ordered by mean AUC, TSS or Boyce;
  • box plots of the metrics of every fold, so the spread between folds is visible, not just the mean;
  • the suitability maps side by side, each rescaled to 0–1 so profile methods (on their own scales) and probability models can be compared.

The R-Code tab writes sdmApp_compare(list(fit_glm, fit_rf, ...), metric = ...) when the comparison was viewed and at least two models exist.

Validation

On 600 Niakhar points with 4 random folds, the table ranks random forest (AUC 0.592, TSS 0.204, Boyce 0.356), then the GLM (0.584 / 0.197 / 0.188), then Bioclim (0.488 / 0.098 / 0.088). The box plots show Bioclim below the others on every metric. I rendered both plots and checked them visually; panel spacing was added so the longitude labels of neighbouring maps don't overlap.

Testing

  • New test-sdmApp_compare.R:
    • values equal the fold means and SDs;
    • ordering by metric;
    • labels, settings, folds and predictor counts;
    • names;
    • errors;
    • both plots;
    • the script line, which is left out when there's a single model.
  • The end-to-end server test orders the comparison by TSS, renders the table and maps, and checks the script.
  • lintr::lint_package(): no lints. spelling: no errors.
  • The full suite was still running when this PR was opened; results will be added here.

🤖 Generated with Claude Code

Abson-dev and others added 2 commits December 1, 2026 08:55
- New sdmApp_compare(): one row per model with the mean and SD of its
  cross-validated AUC, TSS and Boyce index, its predictors, points,
  folds and settings, best first.
- The Ensemble page has a "Compare models" tab with this table, box
  plots of the metrics of every fold and the suitability maps side by
  side (rescaled to 0-1); the R-Code tab records the comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Abson-dev
Abson-dev merged commit d6e712b into master Dec 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant