Models¶
- class mini_gpr.models.Model(
- kernel,
- noise=1e-08,
- solver=<function vanilla>,
- Parameters:
kernel (Kernel)
noise (float)
solver (LinearSolver)
- abstractmethod fit(X, y)[source]¶
Fit the model to the data.
- Parameters:
X (Float[ndarray, 'N D']) – the data points.
y (Float[ndarray, 'N']) – the target values.
- abstractmethod predict(T)[source]¶
Get the predictive mean of the function at the given locations.
- Parameters:
T (Float[ndarray, 'T D']) – the data points/locations at which to make predictions
- Return type:
Float[ndarray, ‘T’]
- abstractmethod latent_uncertainty(T)[source]¶
Get the latent uncertainty of the function at the given locations.
- Parameters:
T (Float[ndarray, 'T D']) – the data points/locations at which to get the latent uncertainty
- Return type:
Float[ndarray, ‘T’]
- predictive_uncertainty(T)[source]¶
Get the predictive uncertainty of the function at the given locations.
- Parameters:
T (Float[ndarray, 'T D']) – the data points/locations at which to get the predictive uncertainty
- Return type:
Float[ndarray, ‘T’]
- abstract property log_likelihood: float¶
Get the log marginal likelihood of the model conditioned on the training data.
- sample_prior(
- locations,
- n_samples=1,
- *,
- rng=None,
- jitter=1e-08,
Generate samples from the model’s prior distribution.
- Parameters:
locations (Float[ndarray, 'N D']) – the data points/locations at which to generate samples
n_samples (int) – the number of samples to generate
rng (RandomState | int | None) – the random number generator to use
jitter (float) – a small value to add to the diagonal of the kernel matrix to ensure numerical stability
- Return type:
Float[ndarray, ‘n N’]
- abstractmethod sample_posterior(
- locations,
- n_samples=1,
- *,
- rng=None,
- jitter=1e-06,
Generate samples from the model’s posterior distribution.
- Parameters:
locations (Float[ndarray, 'N D']) – the data points/locations at which to generate samples
n_samples (int) – the number of samples to generate
rng (RandomState | int | None) – the random number generator to use
jitter (float) – a small value to add to the diagonal of the kernel matrix to ensure numerical stability
- Return type:
Float[ndarray, ‘n N’]
- class mini_gpr.models.GPR(
- kernel,
- noise=1e-08,
- solver=<function vanilla>,
Bases:
Model
Full-rank Gaussian Process Regression model.
- Parameters:
kernel (Kernel) – defines the covariance between data points.
noise (float) – the aleatoric noise assumed to be present in the data.
solver (LinearSolver) – solver of linear systems of the form A @ x = y.
Example
>>> from mini_gpr.kernels import RBF >>> from mini_gpr.models import GPR >>> model = GPR(kernel=RBF(), noise=1e-3) >>> model.fit(X, y) >>> predictions = model.predict(T) # (T,) >>> uncertainties = model.predictive_uncertainty(T) # (T,)
- class mini_gpr.models.SoR(
- kernel,
- sparse_points,
- noise=1e-08,
- solver=<function vanilla>,
Bases:
Model
Subset of Regressors low-rank Gaussian Process Regression approximation.
- Parameters:
kernel (Kernel) – defines the covariance between data points.
sparse_points (Float[ndarray, 'M D']) – the inducing points.
noise (float) – the aleatoric noise assumed to be present in the data.
solver (LinearSolver) – solver of linear systems of the form A @ x = y.
Example
>>> from mini_gpr.kernels import RBF >>> from mini_gpr.models import SoR >>> model = SoR( ... kernel=RBF(), sparse_points=np.random.rand(10, 2), noise=1e-3 ... ) >>> model.fit(X, y) >>> predictions = model.predict(T) # (T,) >>> uncertainties = model.latent_uncertainty(T) # (T,)
Solvers¶
- class mini_gpr.solvers.LinearSolver(*args, **kwargs)[source]¶
Solve a linear system of the form A @ x = y.