Skip to main content

CI Coverage Status Documentation Status

Logo

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.1.0}
}

List of Contents:

Installation

The implementation of LCGP requires Python >=3.10, <3.14. 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.21.0',
'joblib>=1.4.2',
"pytest",

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)

Metadata

Release files for lcgp 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lcgp 1.1.0
File Size Uploaded
lcgp-1.1.0.tar.gz 113.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lcgp 1.1.0
File Interpreter ABI Platform
lcgp-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 145.5 kB

Release files / lcgp-1.1.0.tar.gz

Download URL lcgp-1.1.0.tar.gz
Size 113.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6c274cb557a8a61ed3cb93c6a4aa121b6b53567b306836a9e12e37f4b7078a6d
BLAKE2b-256 checksum
How to use checksums
1c4026155344ecf9076a2dca3d407105d98d9c76505b1bde8731404c49fa3b46
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / lcgp-1.1.0-py3-none-any.whl

Download URL lcgp-1.1.0-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e508ffde23c177dd3fce232d082356df0d447fc00a99d9340473c96de4d6e6e
BLAKE2b-256 checksum
How to use checksums
c524fdc64b8c6919482da3e70cca07833ebe50f896875051ad9038d40f9a12f0
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

1.1.1

2 release files

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page