Skip to content

Validation views: land use cross-tabulation, class exclusion in figure of merit - #57

Merged
mmyrte merged 3 commits into
developfrom
claude/confident-albattani-56osfg-crosstab
Oct 19, 2026
Merged

mmyrte merged 3 commits into
developfrom
claude/confident-albattani-56osfg-crosstab

Conversation

@mmyrte

@mmyrte mmyrte commented Sep 24, 2026

Copy link
Copy Markdown
Member

Two additions to the validation views, both reading each run through its own lineage.

New: db$lulc_crosstab_v()

lulc_crosstab_v(id_period_anterior, id_period_post, id_run_anterior = <active run>, id_run_post = id_run_anterior) counts cells by their class in one period and in another. It returns the transition matrix in long form (id_lulc_anterior, id_lulc_posterior, n_cells); dcast() gives the matrix form. The same call covers:

  • observed change: one run, two periods;
  • simulated change: a simulated run from the initial map it inherits;
  • agreement between observed and simulated: two runs, one period.

New: figure_of_merit_v(exclude_id_lulc = )

Ignores cells whose initial or observed class is in exclude_id_lulc. Use it for a class whose change is imposed deterministically, which would otherwise count as hits by construction. The evoland-experiments ssp-ch/080 backcast writes the observed glacier change into each simulated period and needs this to score the model on the rest. Default: nothing is excluded.

Refactor

get_run_read_expr(self, table_name, id_run) returns a table's read expression as seen from another run, without changing the active run. figure_of_merit_v() now uses it instead of switching the active run inline.

Tests

Added to test_db_evoland.R, on the six-cell fixture of the figure-of-merit tests:

  • the crosstab for observed change, simulated change through lineage inheritance (active-run default), and observed against simulated at one period;
  • the figure of merit with a class excluded, and with an excluded class that doesn't occur, which must equal the unfiltered result.

tinytest::build_install_test(): all ok, 630 results. No undeclared globals.

🤖 Generated with Claude Code

https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np


Generated by Claude Code

…it_v()

- db$lulc_crosstab_v(id_period_anterior, id_period_post, id_run_anterior,
  id_run_post = id_run_anterior): cells by class in one period and another,
  each period read through its own run's lineage
- figure_of_merit_v(exclude_id_lulc = ): ignore cells whose initial or observed
  class is excluded, e.g. a class whose change is imposed deterministically
- get_run_read_expr(): read expression as seen from another run, without
  changing the active run; used by both views

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
mmyrte pushed a commit to mmyrte/evoland-experiments that referenced this pull request Sep 24, 2026
…licate seeds

- allocate each replicate period by period with alloc_clumpy_one_period() and
  write the observed into/out-of-glacier change onto the simulated map before
  the next period (apply_deterministic_change(); GloGEM output in 090 later)
- revert the fixed set.seed(4555) and the parameter-set-only loop: every
  replicate is allocated with its own registered seed
- the first period reads its potentials from the parameter-set run
  (use_parent_trans_pot), so replicates of a set share that prediction
- figure of merit leaves glacier cells out via figure_of_merit_v(exclude_id_lulc)
  instead of correcting after the fact; the ensemble null is the replicate mean
- pin evoland to the head of ethzplus/evoland-plus#57 (d1ee3cf)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
Comment thread inst/tinytest/test_db_evoland.R Outdated
Comment thread R/evoland_db.R Outdated
Comment thread R/evoland_db_util.R Outdated
Comment thread R/validation.R
Comment thread R/validation.R Outdated
Replaces get_run_read_expr(), which switched the active run to do the same.
Also: say that exclude_id_lulc is decided on the reference run, and let
glue_sql() pick the arguments up from the calling frame instead of passing
coerced copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
@mmyrte
mmyrte added this pull request to stack #83 October 19, 2026 12:33
@mmyrte
mmyrte merged commit 08aa38e into develop Oct 19, 2026
2 checks passed
@mmyrte
mmyrte deleted the claude/confident-albattani-56osfg-crosstab branch October 20, 2026 15:05
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.

2 participants