Skip to content

Surface provenance metadata on correspondence and aggregate outputs #13

Description

@dshkol

Preamble: this came out of a Claude-assisted brainstorming session while looking at related census-tooling issues across griddy and bayesiansurpriser. Filing it as a discussion starter rather than a hard ask — happy to drop or rescope any of it.

When using tongfen for longitudinal work (e.g. dynamics analysis across multiple census vintages, or comparing model-based scores like Bayesian surprise across years), I keep wanting to ask the output two questions that aren't easy to answer today:

  1. Which source regions does this target inherit from, and at what weight?
  2. How comparable is this target across vintages — is it intact, a split, a merge, or substantially redrawn?

Tongfen already has the building blocks: TongfenID/TongfenUID keys, TongfenMethod, check_tongfen_areas's max_log_ratio, and tongfen_tag_largest_overlap. This proposal is about surfacing the underlying provenance more directly so users can audit and filter without re-deriving it.

Proposed additions (all backward-compatible):

  • estimate_tongfen_correspondence() gains a weight column (area- or pop-based, configurable) on the long-format correspondence so the contribution of each source to each target is explicit.
  • Derive a change_class ∈ {intact, split, merge, redrawn, novel} column from the correspondence (cheap given TongfenID).
  • tongfen_aggregate() output retains the correspondence used via attr(out, \"tongfen_correspondence\") — no breaking change to the columns of the returned object.
  • A small tongfen_comparability_score() helper combining max_log_ratio, weight entropy, and method into a per-target 0–1 score downstream code can threshold against.
  • Optional plot_tongfen_provenance() — map of change-class by target, useful for sanity-checking a longitudinal study area.

Related: #2 covers error propagation through downstream analysis when tongfen_estimate is used; this issue is complementary, focused on transparency rather than statistical error modelling. Happy to draft a PR if any of this is welcome — could split it into two (the weight + change_class work, and the score/plot helpers).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions