Tournament Graph¶
Tournament graph diagnostics.
Build the directed tournament graph from pairwise outcomes and analyse its strongly connected component (SCC) structure. Non-trivial SCCs (size > 1) indicate clusters of models that cannot be linearly ordered — i.e. pockets of non-transitivity.
- class winference.tournament.TournamentGraph(models)[source]¶
Bases:
objectDirected tournament graph built from pairwise comparison data.
Examples
>>> tg = TournamentGraph(["A", "B", "C"]) >>> tg.add_result("A", "B", win=True) >>> tg.add_result("B", "C", win=True) >>> tg.add_result("C", "A", win=True) >>> tg.scc_sizes() [3]
- add_result(model_a, model_b, win)[source]¶
Record a single comparison outcome (model_a wins if win=True).
- add_results_df(df, col_a='model_a', col_b='model_b', col_win='a_wins')[source]¶
Bulk-load from a DataFrame with columns for model_a, model_b, a_wins (bool).
- strongly_connected_components(threshold=0.5)[source]¶
Return SCCs via Tarjan’s algorithm.
Each SCC is a list of model names. SCCs of size > 1 represent non-transitive clusters.
- nontransitivity_index(threshold=0.5)[source]¶
Fraction of models inside non-trivial SCCs (size > 1).
0.0 = perfectly transitive, 1.0 = all models in one big cycle.