Reference / binference.PointEstimate

binference.PointEstimate

class binference.PointEstimate(model, value, *, method='map', x=None, log_posterior=nan, log_likelihood=nan, kkt_gap=nan, n_iter=0, converged=True, info=None)[source]

A MAP / maximum-likelihood estimate of the population.

Attributes:
value(K,) array

Fractions (or rates for rate models) at the optimum; with a Basis, the component weights (rho and rates are per bin).

x(dim,) array or None

Unconstrained coordinates (when optimised there).

kkt_gapfloat

Optimality certificate (zero at the exact optimum on the simplex).

__init__(model, value, *, method='map', x=None, log_posterior=nan, log_likelihood=nan, kkt_gap=nan, n_iter=0, converged=True, info=None)[source]

Methods

__init__(model, value, *[, method, x, ...])

assignment_probabilities([idx, n_draws, chunk])

Posterior probability that each object lies in each bin, \(P(z_i = k \mid D)\).

assignment_probabilities_best([idx])

assignment_probabilities() at the best fit, best.

assignment_probabilities_loo([idx, n_draws, ...])

Each object's posterior over bins under the population fitted without it, \(P(z_i = k \mid D_{-i})\): leave-one-out, for calibration checks (DECISIONS #52).

check([kkt_max, strict])

Warn (or raise with strict=True) when the optimiser did not converge or the KKT gap (per object; see PopulationModel.kkt_gap()) exceeds kkt_max.

density()

Population density per unit bin volume at the optimum.

laplace([n_samples, rng])

Laplace approximation around the mode (see binference.samplers.Laplace).

log_predictive(likelihoods[, n_draws, chunk])

Log posterior-predictive density of new objects, \(\log E[L_i\cdot\rho]\).

log_predictive_best(likelihoods, **kwargs)

log_predictive() at the best fit, best.

plot(**kwargs)

plot_individual(i, **kwargs)

Object i's own likelihood against its hierarchical posterior (see binference.plotting.plot_individual()).

predict_proba(likelihoods[, n_draws, chunk])

Posterior over bins for new objects under the inferred population.

predict_proba_best(likelihoods, **kwargs)

predict_proba() at the best fit, best.

prior_information_ratio([h])

Efron's (2016) ratio of prior to data information, \(\mathrm{tr}(-H_\text{prior}) / \mathrm{tr}(-H_\text{data})\).

realized_counts([n_draws, rng, full])

Draws of the realised histogram of the observed objects' true bins.

realized_counts_best(**kwargs)

realized_counts() at the best fit, best.

sample_assignments([idx, n_draws, rng])

Joint draws of the bin labels of objects idx (all by default).

sample_assignments_best([idx])

sample_assignments() at the best fit, best.

sample_values([idx, n_draws, rng, loglike, ...])

Joint draws of the continuous true values of objects idx.

sample_values_best([idx])

sample_values() at the best fit, best.

Attributes

best

The best fit of a point estimate is itself.

data_support

Objects' worth of likelihood in each bin, \(\sum_i w_i \ell_{ik}\) with each object's likelihood normalised over the bins: below about one, a bin's fraction is set by the prior (DECISIONS #41).

rates

Rates at the optimum (per bin): for fractions \(\hat\Lambda\rho\) with \(\hat\Lambda = W / (S\cdot\rho)\) (None with a relative selection).

rho

Population fractions at the optimum (per bin).

selected

The selected population at the estimate (see PopulationResult.selected).

selection

The selection function of the fit (a point estimate is not saved, so it is always the model's).

total

Total rate at the optimum (see rates).

model

basis

bins

kind

method

info

property best

The best fit of a point estimate is itself.

check(kkt_max=0.0001, strict=False)[source]

Warn (or raise with strict=True) when the optimiser did not converge or the KKT gap (per object; see PopulationModel.kkt_gap()) exceeds kkt_max.

Estimates found by L-BFGS in unconstrained coordinates have no KKT gap (NaN); for them the check is converged (see tol of MAP).

The default is ten times the round-off floor at which MAP stops (DECISIONS #12). Returns the messages (empty if the estimate looks fine).

Parameters:
kkt_maxfloat, optional

Largest KKT gap that passes.

strictbool, optional

Raise DiagnosticsError instead of warning.

density()[source]

Population density per unit bin volume at the optimum.

laplace(n_samples=4000, rng=None, **kwargs)[source]

Laplace approximation around the mode (see binference.samplers.Laplace).

Parameters:
n_samplesint, optional

Draws of the Laplace approximation.

rngint, Generator or None

Random number generator.

**kwargs

Options of Laplace.

property rates

Rates at the optimum (per bin): for fractions \(\hat\Lambda\rho\) with \(\hat\Lambda = W / (S\cdot\rho)\) (None with a relative selection).

property rho

Population fractions at the optimum (per bin).

property selected

The selected population at the estimate (see PopulationResult.selected).

property selection

The selection function of the fit (a point estimate is not saved, so it is always the model’s).

property total

Total rate at the optimum (see rates).