Baltor Get started

Library / Code module

Within-group and between-group covariance decomposition

correlation_source_decomposition

Split the covariance between a score Y and a prediction P into the expected within-group covariance and the covariance of group means, exactly, using rational arithmetic. Use it to see whether a correlation comes from differences between tasks or sources rather than from agreement inside each group.

Files, names only

  • ATTRIBUTION.md 3.9 KB
  • LICENSE 1.0 KB
  • README.md 3.0 KB
  • atom_cli.py 3.0 KB
  • component.json 9.7 KB
  • correlation_source_decomposition.py 4.4 KB
  • numerics.py 28.0 KB
  • schema_lite.py 8.9 KB
  • test_correlation_source_decomposition.py 4.2 KB
  • test_package.py 12.0 KB

Full files in your harness.

What it takes and gives

Runs with
Python 3.10 or later
Entry points
decompose_covariance, decompose_variance
Known answers
8 cases its tests reproduce

Cases it covers

  • within part is not the total: Averaging the per-group covariances drops the between-group term; here it reports 1 while the overall covariance is 0.

Limits and scope

Limits
Population moments only; sample (n - 1) moments do not satisfy the identity. Rational arithmetic is exact but slow for very long inputs (tens of thousands of rows are fine). The decomposition describes the data at hand; it does not say which grouping is causally relevant, and correlations themselves do not decompose additively.
Guarantees
total_covariance = within_group + between_group exactly in rational arithmetic on the exact binary values of the inputs; identity_residual is 0.0. One group gives between_group 0; one row per group gives within_group 0. Results are rounded to float only at the end.
Assumes
Moments are population moments (divide by n) with empirical group weights n_g / n; this is what makes the identity exact. Each row belongs to exactly one group.

Details

Kind
Code module
Licence
MIT
Declared effects
runs commands
Source
github.com/alisonjieli-png/loop-engine/tools/creative_originals/evaluation_atoms/items/correlation_source_decomposition
Size
10 files, 78.1 KB
Identity
library.supply.creative_originals.f24863ff4a709ae8965d2026.10d84ed931befc05
Version
10d84ed931befc05a1013e75091772914e6593ebb802a4a394193a11a527178b

The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.

Where it is shown

Related components

Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.