mixle.utils.automatic.detectors package

Detector registry for automatic model selection.

A Detector describes one candidate distribution family for the profiler / get_estimator: when it applies (a support gate over the data), its BIC code length on the data (for selection), how to build its estimator, and (optionally) its CDF for goodness-of-fit. Families register here so the candidate set can be extended without editing the core profiling/selection code – every module in this package self-registers on import, and the registry is discovered lazily the first time it is queried.

This is purely additive: the profiler’s built-in candidates (gaussian / student_t / mixture / lognormal / gamma for continuous; poisson / categorical for integer) are unchanged; registered detectors are scored and built alongside them, so a richer family only ever wins when its BIC actually beats the builtins.

A detector receives the data two ways, matching the leaf profiler: * applies(arr) and score(arr, nobs) and cdf(arr) take the expanded value array (a NumPy array

of the observed scalars, repeated by their counts);

  • factory(vdict, pseudo_count, emp_suff_stat, use_bstats) takes the value->count map and returns a ParameterEstimator – the same signature as the built-in get_*_estimator factories.

class Detector(name, kind, applies, score, factory, cdf=None, n_params=2)[source]

Bases: object

One candidate distribution family for automatic selection.

Parameters:
name: str
kind: str
applies: Callable[[Any], bool]
score: Callable[[Any, int], float | None]
factory: Callable[[...], Any]
cdf: Callable[[Any], Any] | None = None
n_params: int = 2
register(detector)[source]

Register a detector (idempotent on name within its kind). Returns it, so it can decorate a build.

Parameters:

detector (Detector)

Return type:

Detector

continuous_detectors()[source]

Registered continuous-support candidate families.

Return type:

list[Detector]

discrete_detectors()[source]

Registered integer/discrete-support candidate families.

Return type:

list[Detector]

get_detector(name)[source]

Return the registered detector with this name (any kind), or None.

Parameters:

name (str)

Return type:

Detector | None

Submodules