incline.GaussianProcess¶
- class incline.GaussianProcess(kernel='rbf', amplitude=None, length_scale=None, noise_level=0.1, n_restarts=5, optimize=True, standardize=True)[source]¶
Gaussian process regression with an exact derivative posterior.
- Variables:
kernel (str) –
'rbf','matern32'or'matern52'. The Matern smoothness caps the derivative order: 3/2 is once differentiable, 5/2 twice.amplitude (float | None) – Prior variance of the signal. Optimized from a starting value of 1 when None.
length_scale (float | None) – Initial length scale. Optimized from the data when None.
noise_level (float) – Noise variance. A starting value when
optimizeis on, the value used when it is off.n_restarts (int) – Restarts for the hyperparameter optimizer.
optimize (bool) – Whether to fit the kernel hyperparameters by marginal likelihood. When False the kernel is used exactly as given.
standardize (bool) – Whether to rescale the response before fitting. Decides what units
amplitudeandnoise_levelare in.
- Parameters:
Note
The three settings are separable and each does one thing:
optimizedecides whether the hyperparameters are learned,standardizedecides what units they are expressed in, andamplitudeis one of them.With
standardize=Truethe response is centered and scaled, soamplitudeandnoise_levelare in units of the series’ own standard deviation. That is the right default when they are being learned, and it keeps the fit well conditioned.With
standardize=Falsethe response is only centered, so both are in the data’s own units and a prior can be stated exactly. Centering is kept either way because the prior mean is zero and real series are not; a constant shift does not affect any derivative. Scaling is what obscured the units: it made a suppliednoise_levelmean something other than what was asked for, and measured against data drawn from a known prior, credible intervals covered 0.90 instead of 0.95.Note
optimizeexists because sklearn re-fits the hyperparameters on every call regardless ofn_restarts_optimizer– that setting controls how many restarts an optimization gets, not whether one happens. Passing alength_scaletherefore only chose a starting point, and the fitted scale came out the same whatever was asked for, which silently madewith_scale()a no-op and a multi-scale sweep a single scale repeated.with_scalenow turns optimization off so the scale it sets is the scale that gets used.- __init__(kernel='rbf', amplitude=None, length_scale=None, noise_level=0.1, n_restarts=5, optimize=True, standardize=True)¶
Methods
__init__([kernel, amplitude, length_scale, ...])analytic_operators(axis, order)State the smoothing and derivative operators directly, if known.
evaluate(axis, y, order)Posterior mean of the smooth and of its derivative.
fit(axis, y[, order, se, noise, ...])Estimate the trend and, optionally, its uncertainty.
native_posterior(axis, y, order, ...)Exact posterior standard deviation of the derivative.
operators(axis, order)The smoothing and derivative operators for this configuration.
params()Report the kernel and length scale.
scale_of(axis)Length scale as a fraction of the span.
with_scale(scale, axis)Fix the length scale to
scaleof the series span.Attributes
is_linearWhether the derivative is a fixed linear map of the data.
linearrequires_regular_grid- native_posterior(axis, y, order, confidence_level)[source]¶
Exact posterior standard deviation of the derivative.
- with_scale(scale, axis)[source]¶
Fix the length scale to
scaleof the series span.Optimization is switched off, or the scale just set would immediately be optimized away and every scale in a sweep would return the same fit.