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:
objectExact 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.
- log_marginal_likelihood(x, y)[source]
Return the exact GP log marginal likelihood for training data.
- 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. Setreturn_result=Truefor the full objective diagnostics.
- predict(x_train, y_train, x_new, return_cov=False)[source]
Return posterior predictive mean, and optionally covariance.
- 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_newand projects it onto the monotone cone (non-decreasing ifincreasingelse non-increasing) by pool-adjacent-violators inx_neworder – the L2-closest monotone curve to the GP mean. Intended for scalar (1-D) inputs (e.g. monotone age-depth / dose-response fits); reduces topredict()when the posterior mean is already monotone.