mixle.models.gaussian_process module

Small Torch-backed Gaussian-process regression model.

class GaussianProcessRegressor(lengthscale=1.0, amplitude=1.0, noise=0.1, mean=0.0, jitter=1.0e-6, kernel='rbf', engine=None, precision=None)[source]

Bases: object

Exact GP regression with a stationary kernel and Gaussian observation noise.

The kernel is RBF (squared-exponential) by default; kernel="matern32" or "matern52" selects the Matern-3/2 or Matern-5/2 covariance, whose rougher sample paths often fit physical responses better than the very smooth RBF.

Parameters:
parameters()[source]

Return trainable raw kernel/noise parameters and the mean.

property lengthscale: float

Return the fitted kernel lengthscale.

property amplitude: float

Return the fitted kernel amplitude.

property noise: float

Return the fitted Gaussian observation-noise standard deviation.

kernel(x1, x2)[source]

Return the covariance matrix between two input arrays under the configured kernel.

Parameters:
Return type:

Any

log_marginal_likelihood(x, y)[source]

Return the exact GP log marginal likelihood for training data.

Parameters:
Return type:

Any

fit(x, y, max_its=500, lr=0.05, optimizer='adam', tol=1.0e-7, out=None, print_iter=100, return_result=False, restore_best=True)[source]

Maximize the GP log marginal likelihood.

The default return shape is the historical (value, iterations) tuple. Set return_result=True for the full objective diagnostics.

Parameters:
Return type:

Any

predict(x_train, y_train, x_new, return_cov=False)[source]

Return posterior predictive mean, and optionally covariance.

Parameters:
Return type:

Any

predict_monotone(x_train, y_train, x_new, increasing=True)[source]

Return the posterior-mean prediction projected to be monotone in scalar x_new.

Predicts the GP posterior mean at x_new and projects it onto the monotone cone (non-decreasing if increasing else non-increasing) by pool-adjacent-violators in x_new order – the L2-closest monotone curve to the GP mean. Intended for scalar (1-D) inputs (e.g. monotone age-depth / dose-response fits); reduces to predict() when the posterior mean is already monotone.

Parameters:
Return type:

ndarray