Most measures of association are symmetric: they report a
single number for a pair of variables, as if the relationship between
X and Y were the same as between Y and
X. Many real relationships are not. Knowing a country often tells
you its capital, yet a capital tells you its country far more decisively;
one symptom may predict a disease while the disease barely predicts that
symptom. ASymCat quantifies association separately in each direction,
across a dozen probabilistic, information-theoretic, and statistical
measures, behind one consistent interface.
Installation
pip install asymcat
Quick start
How English spellings map to sounds: the letter q is always
pronounced /k/, but /k/ is spelled in several ways.
>>> from asymcat import CatScorer >>> pairs = ([("q", "k")] * 2 + [("c", "k")] * 6 ... + [("k", "k")] * 3 + [("c", "s")] * 4) >>> scorer = CatScorer(pairs) >>> k_given_q, q_given_k = scorer.mle()[("q", "k")] >>> round(k_given_q, 2), round(q_given_k, 2) (1.0, 0.18)
Every measure returns, for each pair (x, y), a
tuple (x→y, y→x). Here q predicts /k/
perfectly, while /k/ points back to q only 18% of the time. A
symmetric measure would collapse the two numbers into one and hide exactly
that difference.
The asymmetry
mle) on the
1,000 mushrooms of the UCI Mushroom sample shipped with the repository. Each
odour fully determines whether a mushroom is edible (solid bars), but knowing
that a mushroom is edible says little about its odour (open bars). In this
sample every poisonous mushroom smells pungent, so that pair is symmetric. A
single symmetric score would hide the difference.Measures
| Measure | Family | Reports |
|---|---|---|
| mle | probabilistic | P(y|x), P(x|y) |
| pmi, pmi_smoothed | information-theoretic | pointwise mutual information |
| theil_u | information-theoretic | uncertainty coefficient |
| cond_entropy | information-theoretic | conditional entropy |
| mutual_information | information-theoretic | shared information (also normalized) |
| chi2, cramers_v | statistical | χ² association |
| fisher | statistical | exact odds ratio |
| log_likelihood_ratio | statistical | G² statistic |
| goodman_kruskal_lambda | statistical | proportional error reduction |
| jaccard_index | set-based | set overlap |
| tresoldi | specialized | PMI tempered by conditional probability |
Statistical tests expose matching p-value scorers
(chi2_pvalue, fisher_pvalue,
log_likelihood_ratio_pvalue); a generic
permutation_pvalue and bootstrap_ci provide
significance and confidence intervals for any measure.
Across domains
Directional association between categories recurs wherever one kind of label helps predict another:
- Linguistics. grapheme–phoneme correspondence and sound-change directionality.
- Ecology. asymmetric species co-occurrence from presence–absence data.
- Machine learning. feature screening by directional predictive strength.
- Categorical analytics. dependency and information flow between discrete variables.
Documentation
Related projects
- FreqProb. provides ASymCat's smoothed probabilities and bias-corrected entropy estimators.
- scipy.stats.contingency.association. symmetric association for a whole contingency table (Cramér's V, Tschuprow's T, Pearson's contingency coefficient); ASymCat adds directional measures and scores every pair of categories.
Citation
Please cite the version you used. See How to cite for APA and classic BibTeX forms, and References for the papers behind each measure.
@software{tresoldi_asymcat,
author = {Tresoldi, Tiago},
title = {{ASymCat}: Asymmetric measures of association between
categorical variables},
year = {2026},
version = {0.9.0},
doi = {10.5281/zenodo.23917211},
url = {https://asymcat.tresoldi.org/}
}