Reference / binference.PopulationEstimator
binference.PopulationEstimator¶
- class binference.PopulationEstimator(prior=None, *, method='auto', selection=None, selection_mode=None, bins=None, n_samples=None, rng=None, engine_kwargs=None)[source]¶
Population inference with the scikit-learn estimator conventions.
fit(X)infers the population from per-object likelihoodsX(aLikelihoodsor an(N, K)array) and stores the result inresult_.predict_proba(X)gives per-object posteriors over bins for (new) objects under the inferred population, andscore(X)the mean log posterior-predictive density per object, which can be used to compare priors or binnings by cross-validation. The estimator follows the scikit-learnget_params/set_paramscontract without depending on scikit-learn.- Parameters:
- priorPopulationPrior, optional
Population prior (default
Dirichlet(1.0)).- methodstr
Inference engine (see
binference.infer()).- selectionarray_like (K,), callable or Selection, optional
Selection function.
- selection_mode{“on_measurement”, “on_truth”}, optional
Required with an array or callable
selection.- binsBins, optional
Bins for raw array inputs.
- n_samplesint, optional
Draws per chain / in total.
- rngint, Generator, or None
Random number generator.
- engine_kwargsdict, optional
Extra keyword arguments for the engine.
- __init__(prior=None, *, method='auto', selection=None, selection_mode=None, bins=None, n_samples=None, rng=None, engine_kwargs=None)[source]¶
Methods
__init__([prior, method, selection, ...])fit(X[, y])Infer the population from likelihoods
X.get_params([deep])Constructor parameters (scikit-learn convention).
predict(X)Most probable bin of each object under the inferred population.
Per-object posterior over bins under the inferred population.
sample([n, rng])Draws of the population fractions from the fitted posterior.
score(X[, y])Mean log posterior-predictive density per object (higher is better).
set_params(**params)Set constructor parameters (scikit-learn convention).
- fit(X, y=None)[source]¶
Infer the population from likelihoods
X.- Parameters:
- XLikelihoods or array_like (N, K)
Per-object likelihoods.
- yNone, optional
Ignored; accepted for scikit-learn compatibility.
- get_params(deep=True)[source]¶
Constructor parameters (scikit-learn convention).
- Parameters:
- deepbool, optional
Accepted for scikit-learn compatibility; has no effect.
- predict(X)[source]¶
Most probable bin of each object under the inferred population.
- Parameters:
- XLikelihoods or array_like (N, K)
Likelihoods of the objects.
- predict_proba(X)[source]¶
Per-object posterior over bins under the inferred population.
- Parameters:
- XLikelihoods or array_like (N, K)
Likelihoods of the objects.
- sample(n=1, rng=None)[source]¶
Draws of the population fractions from the fitted posterior.
- Parameters:
- nint, optional
Number of population draws returned.
- rngint, Generator or None
Random number generator.