Skip to content

Evaluation, diagnostics, benchmarks, and additional tests · Evaluation, diagnostics, benchmarks, and additional hypothesis tests · EVA014 · Diagnostic

BIC and ICL for mixture-model selection

Compare fitted likelihood models while accounting for complexity; ICL additionally penalizes uncertain classification under a common approximation.

Partly runs in CodeSplash Complete calculation CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method covers part of this entry; some options or variants aren't built yet.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Partly runs in CodeSplash
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through discover.choose_k, discover.gmm. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Compare fitted likelihood models while accounting for complexity; ICL additionally penalizes uncertain classification under a common approximation.

Question / hypotheses

Which candidate mixture balances fit and complexity, and which favors well-separated assignments? Neither is a generic p-value.

Architecture / computational structure

Fit each candidate mixture by EM or another likelihood optimizer, count its free parameters under the covariance constraints, and evaluate penalized likelihood. The MAP ICL approximation adds a penalty for uncertainty in the assigned component; the soft-responsibility entropy alternative is displayed separately in the code.

Assumptions

Models must use the same observed-data likelihood and sample. Mixture singularities complicate ordinary asymptotic BIC reasoning. Missingness and sample dependence affect effective information.

Formula / computational definition

BICmin⁡=−2ℓ^+plog⁡n,ICLmin⁡MAP≈BICmin⁡−2∑i,gz^iglog⁡τig,z^ig=1{g=arg⁡max⁡hτih}.BIC_{\min}=-2\hat\ell+p\log n,\quad ICL_{\min}^{MAP}\approx BIC_{\min}-2\sum_{i,g}\hat z_{ig}\log\tau_{ig},\quad \hat z_{ig}=\mathbf1\{g=\arg\max_h\tau_{ih}\}.

Parameters and notation

p is the free-parameter count, n the number of fitted observations, tau the posterior responsibilities, and z-hat a one-hot MAP assignment. This is the classification approximation used by mclust, shown with a minimized sign convention; mclust itself maximizes its negative. A related soft-entropy criterion uses BIC_min+2H(tau), H(tau)=-sum tau log tau, which is generally a different numerical penalty. Component count and covariance constraints are model hyperparameters.

Fitting, fine-tuning, and adaptation

Refit candidate component counts and covariance families with multiple initializations and inspect singular components. This is model selection, not a null-calibrated test or neural fine-tuning. Changing priors, covariance floors, feature transforms, or sample size changes the comparison. Evaluate the selected density on independent data when predictive quality is the goal.

How to use and calibrate

Fit each component-count/covariance model with multiple starts, reject degenerate fits, and compare held-out log likelihood alongside BIC/ICL. Declare whether lower or higher is preferred.

Example application

Choose between a flexible overlapping density mixture and a simpler, more confidently separated clustering.

Interpretation / pitfalls

Watch out

Best density estimation and best partitioning can select different k. An extra component can approximate skewness rather than represent a new population.

Python and R code examples

Scope: Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.

Validation: Python — Executed successfully on synthetic inputs. R — reviewed but not executed in this environment. Python dependencies are explicit imports; R uses base R unless a package/bridge is explicitly named.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs numpy

import numpy as np
ll=-120.; p=8; tau=np.tile([[.9,.1],[.6,.4]],(50,1)); n=len(tau)
bic=-2*ll+p*np.log(n)
map_penalty=-2*np.log(tau.max(axis=1)).sum()
soft_penalty=-2*np.sum(tau*np.log(tau))
print('BIC_min',bic,'MAP_ICL_min',bic+map_penalty,'soft_entropy_variant',bic+soft_penalty)
R

Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.

ll <- -120; p <- 8; tau <- matrix(rep(c(.9,.1,.6,.4),50),ncol=2,byrow=TRUE); n <- nrow(tau)
bic <- -2*ll+p*log(n)
map.penalty <- -2*sum(log(apply(tau,1,max)))
soft.penalty <- -2*sum(tau*log(tau))
print(c(BIC_min=bic,MAP_ICL_min=bic+map.penalty,soft_entropy_variant=bic+soft.penalty))

Sources

From the CodeSplash reference, entry EVA014.