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.
ATTRIBUTION.md3.9 KBLICENSE1.0 KBREADME.md3.0 KBatom_cli.py3.0 KBcomponent.json9.7 KBcorrelation_source_decomposition.py4.4 KBnumerics.py28.0 KBschema_lite.py8.9 KBtest_correlation_source_decomposition.py4.2 KBtest_package.py12.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
- Statistics for comparing resultsDeterministic skills
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.