Skip to content

Add CRegCCD: class-based regularised CCD with full support - #18

Open
alexeid wants to merge 2 commits into
masterfrom
cregccd
Open

Add CRegCCD: class-based regularised CCD with full support#18
alexeid wants to merge 2 commits into
masterfrom
cregccd

Conversation

@alexeid

@alexeid alexeid commented Aug 18, 2026

Copy link
Copy Markdown
Member

Adds CRegCCD, a full-support CCD that replaces KRegCCD's escape mechanism with additive smoothing over every bipartition of a clade. Paper section is in a PR on the manuscript repo (yangsoph/CCD_regularisation#10).

The model

The pseudocount depends only on how many novel clades a bipartition introduces:

class bipartition pseudocount
$A_0$ both children observed — the CCD0 split set alpha per split
$A_1$ exactly one child observed alpha1 total
$A_2$ neither child observed alpha2 total

|A_2| follows by subtraction from 2^(m-1)-1, so the exponentially large class is never enumerated. There is no #P-hard counting, no reserve equation and no truncation — the cost is one O(#clades) scan per clade, comparable to the CCD0 expansion.

Per-class totals rather than per-split constants are essential: with a constant pseudocount the two-novel class swamps the data, leaving observed splits 6.3e-9 of the probability at a 40-taxon root clade (SplitClassSizeAnalysis).

Properties hold by construction rather than by correction:

  • exactly normalised by the chain rule — no partition function, and the Theta(mu^2) maximality deficit KRegCCD carries cannot arise, because there are no regions
  • full support
  • regCCD nested exactly at alpha1 = alpha2 = 0
  • an observed split always outranks an expanded one at the same clade
  • the mass held back shrinks as f(C) grows

What is implemented

Scoring, sampling, MAP and entropy.

Sampling draws a class then a member — classes 0 and 1 by enumeration, class 2 by rejection from uniform bipartitions with an enumeration fallback when acceptance would be poor. Each draw is scored with the same routine the scorer uses, so the sampled and scored distributions coincide exactly; there is no sampling-fidelity choice to make.

MAP runs a DP over the observed-clade DAG, with an optional wider search admitting one-novel-clade splits, plus a bound that can certify global optimality.

Entropy is unbiased by Monte Carlo, since sampler and scorer agree. A deterministic recursion is also provided; it approximates novel subclades as structureless and is therefore optimistic, measured at +2.0% to +10.4% on real data, so Monte Carlo is the estimator of record.

Verification

In CRegCCDTest and CRegCCDMapEntropyTest:

  • total mass 1.000000000000 by enumeration on 4–7 taxa, for several training sets and arbitrary pseudocounts
  • agreement with RegCCD to 1.8e-15 at alpha1 = alpha2 = 0
  • class sizes partitioning all 2^(m-1)-1 bipartitions on 135 clades
  • sampled frequencies matching scored probabilities across all 105 five-taxon topologies (worst |z| = 2.58 at 1e6 draws), plus the entropy identity at six taxa
  • MAP search matching brute force in twelve configurations, certificate firing in each

Also included

Measurement tests used to characterise the models: KRegNormalisationTest (KRegCCD is exactly normalised on four taxa, sub-normalised beyond, deficit scaling as mu^2 and never exceeding one), SplitClassSizeAnalysis, ClassUsageAnalysis, and RealDataHeadToHeadTest, which compares CCD1, regCCD, KRegCCD, MRegCCD and CRegCCD on a real posterior with hyperparameters selected on a disjoint validation split.

Known limitations

  • Within class 2 the model is uniform, so a bipartition into two novel clades is chosen without regard to the observed structure it destroys. On a real 129-taxon posterior these account for 0.01% of internal nodes and 0.4% of total log probability, but that is where the model is weakest.
  • The MAP certificate fires at 5–8 taxa but is inconclusive at 129 taxa; there the result is the MAP over the graph, the same guarantee CCD0 and regCCD give.
  • alpha1 and alpha2 are class totals, not per-split pseudocounts, so the alpha naming is arguably misleading — mu1/mu2 is under consideration and not yet applied.

🤖 Generated with Claude Code

alexeid and others added 2 commits August 18, 2026 12:58
Smooths over every bipartition of a clade rather than only those in the CCD
graph, with the pseudocount set by how many novel clades the bipartition
introduces: a per-split alpha on the CCD0 split set (classes 0 and 1
pooled), and class totals alpha1, alpha2 for the one- and two-novel-clade
classes. The exponentially large class is obtained by subtraction from
2^(m-1)-1, so it is never enumerated and there is no #P-hard counting.

Per-class totals rather than per-split constants are essential: with a
constant pseudocount the two-novel class swamps the data, leaving observed
splits 6e-9 of the probability at a 40-taxon root clade.

Properties, all by construction: exactly normalised by the chain rule (no
partition function, no truncation); full support; regCCD nested exactly at
alpha1 = alpha2 = 0; an observed split always outranks an expanded one at
the same clade; and the mass held back shrinks as f(C) grows.

Implements scoring, exact sampling, MAP and entropy. Sampling draws a class
then a member, using rejection for the two-novel class, and scores each draw
with the same routine the scorer uses, so the sampled and scored
distributions coincide. MAP runs a DP over the observed-clade DAG with an
optional wider search admitting one-novel-clade splits, plus a bound that
can certify global optimality. Entropy is unbiased by Monte Carlo; a
deterministic recursion is also provided, which approximates novel subclades
as structureless and is therefore optimistic.

Verified in CRegCCDTest and CRegCCDMapEntropyTest: total mass 1.000000000000
by enumeration on 4-7 taxa; agreement with RegCCD to 1.8e-15 at
alpha1 = alpha2 = 0; class sizes partitioning all 2^(m-1)-1 bipartitions;
sampled frequencies matching scored probabilities across all 105 five-taxon
topologies; and the MAP search matching brute force in twelve configurations
with the certificate firing in each.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… real data

KRegNormalisationTest enumerates every rooted topology and asserts that
KRegCCD is exactly normalised on four taxa but sub-normalised beyond it,
with the deficit scaling as mu^2 and never exceeding one. This is the
Theta(mu^2) maximality deficit, which is distinct from, and larger than, the
O(mu^(k+1)) reserve truncation.

SplitClassSizeAnalysis reports the four split-class sizes at a root clade,
showing that a constant per-split pseudocount leaves the observed splits
6.3e-9 of the probability by 40 taxa.

ClassUsageAnalysis attributes a held-out tree's log probability to the split
classes and measures how much observed structure a two-novel-clade split
destroys.

RealDataHeadToHeadTest compares CCD1, regCCD, KRegCCD, MRegCCD and CRegCCD
on a real posterior using the manuscript's RSV2 protocol, selecting each
model's hyperparameters on a validation split disjoint from the fitted set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant