Latent component Gaussian process
Project description
Implementation of latent component Gaussian process (LCGP). LCGP handles the emulation of multivariate stochastic simulation outputs.
Reference
The development of the foundation of this work is described in the following work, cited as:
@phdthesis{chan2023thesis,
author = "Moses Y.-H. Chan",
title = "High-Dimensional {Gaussian} Process Methods for Uncertainty Quantification",
school = "Northwestern University",
year = "2023",
}
To cite the software, please use:
@software{Chan_LCGP,
author = {Chan, Moses Y.-H. and Handjaja, Edbert},
license = {MIT},
title = {{LCGP: Latent Component {Gaussian} Processes}},
url = {https://github.com/mosesyhc/lcgp},
version = {1.0.0}
}
List of Contents:
Installation
The implementation of LCGP requires Python 3.9 or above. The package can be installed through
pip install lcgp
The LCGP package has the following dependencies, as listed in its pyproject.toml configuration:
'numpy>=1.18.3',
'scipy>=1.10.1',
'tensorflow>=2.16.0',
'gpflow>=2.5.0'
This package is supported in Python >=3.9, <3.14.
Test suite
A list of basic tests is provided for user to verify that LCGP is installed correctly. Execute the follow code within the root directory:
$ python
>>> import lcgp
>>> lcgp.__version__
<version string>
>>> lcgp.test()
Basic usage
What most of us need:
import numpy as np
from lcgp import LCGP
from lcgp import evaluation # optional evaluation module
# Generate fifty 2-dimensional input and 4-dimensional output
x = np.random.randn(50, 2)
y = np.random.randn(4, 50)
# Define LCGP model
model = LCGP(y=y, x=x)
# Estimate error covariance and hyperparameters
model.fit()
# Prediction
p = model.predict(x0=x) # mean and variance
rmse = evaluation.rmse(y, p[0].numpy())
dss = evaluation.dss(y, p[0].numpy(), p[1].numpy(), use_diag=True)
print('Root mean squared error: {:.3E}'.format(rmse))
print('Dawid-Sebastiani score: {:.3f}'.format(dss))
# Access parameters
print(model)
Specifying number of latent components
There are two ways to specify the number of latent components by passing one of the following arguments in initializing an LCGP instance:
q = 5: Five latent components will be used. q must be less than or equal to the output dimension.
var_threshold = 0.99: Include \(q\) latent components such that 99% of the output variance are explained, using a singular value decomposition.
Note: Only one of the options should be provided at a time.
model_q = LCGP(y=y, x=x, q=5)
model_var = LCGP(y=y, x=x, var_threshold=0.99)
Specifying diagonal error groupings
If errors of multiple output dimensions are expected to be similar, the error variances can be grouped in estimation.
For example, the 6-dimensional output is split into two groups: the first two have low errors and the remaining four have high errors.
import numpy as np
x = np.linspace(0, 1, 100)
y = np.row_stack((
np.sin(x), np.cos(x), np.tan(x),
np.sin(x/2), np.cos(x/2), np.tan(x/2)
))
y[:2] += np.random.normal(2, 1e-3, size=(2, 100))
y[2:] += np.random.normal(-2, 1e-1, size=(4, 100))
Then, LCGP can be defined with the argument diag_error_structure as a list of output dimensions to group. The following code groups the first 2 and the remaining 4 output dimensions.
model_diag = LCGP(y=y, x=x, diag_error_structure=[2, 4])
By default, LCGP assigns a separate error variance to each dimension, equivalent to
model_diag = LCGP(y=y, x=x, diag_error_structure=[1]*6)
Define LCGP using different submethod
The main and recommended method under LCGP is the Full posterior (full) method. The method takes into account the uncertainty propagated to the latent components and integrates out the latent components.
Under circumstances where the simulation outputs are stochastic, the full posterior approach or the replication method (rep) should perform most effectively. The replication method is recommended when the simulation outputs contain replicated inputs.
LCGP_models = []
submethods = ['full', 'rep']
for submethod in submethods:
model = LCGP(y=y, x=x, submethod=submethod)
LCGP_models.append(model)
Standardization choices
LCGP standardizes the simulation output by each dimension to facilitate hyperparameter training. The two choices are implemented through robust_mean = True or robust_mean = False.
robust_mean = False: The empirical mean and standard deviation are used.
robust_mean = True: The empirical median and median absolute error are used.
model = LCGP(y=y, x=x, robust_mean=False)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lcgp-1.0.1.tar.gz.
File metadata
- Download URL: lcgp-1.0.1.tar.gz
- Upload date:
- Size: 47.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c85f136ba40c73e36cab82680c93f003c7e6fd323d605563655e0ad32bb8924
|
|
| MD5 |
907293e3f36faf7c71215e9b65e955c3
|
|
| BLAKE2b-256 |
1e5a6fdb4ba92665f03409edeac05c4b81ed783a0da9b43ce1db6a4a699ddc79
|
File details
Details for the file lcgp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lcgp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7902bc70c6d89f79ff99f97a3b0f4fc7b3b8be9480d3b3d0ee9937ebcd0be74a
|
|
| MD5 |
e0f2742daad8057c747a5ccadededc62
|
|
| BLAKE2b-256 |
70718bde77778690f14e0e6b0784b7fdba0f66dfacc800cd5a4f6981052c11ce
|