Skip to main content

tuning.HyperTuner

tuning.HyperTuner()

Tunes the hyperparameters of a posterior: its prior precision, a learned sigma.

lk.laplace(..., hyper_tuner=...) runs it after the fit, and lk.tune on any posterior. A tuner returns a new posterior and leaves its input unchanged.

Methods

Name Description
call Tune the posterior’s hyperparameters.
check Raise before the fit when this tuner can’t tune what the fit will give.

call

tuning.HyperTuner.__call__(posterior, /)

Tune the posterior’s hyperparameters.

Parameters

Name Type Description Default
posterior P The posterior to tune. It is left unchanged. required

Returns

Name Type Description
P A new posterior with tuned hyperparameters.

check

tuning.HyperTuner.check(prior, likelihood, batch, /)

Raise before the fit when this tuner can’t tune what the fit will give.

lk.laplace calls it once, with the first batch, before it reads the others.

Parameters

Name Type Description Default
prior Prior The prior of the fit. required
likelihood Likelihood The likelihood of the fit. required
batch Batch The first batch of the data. required

Raises

Name Type Description
StructureError The prior or the likelihood has nothing this tuner can tune.
ValueError The data can’t support the tune (no targets, say).