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.1

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.1
File Size Uploaded
lcgp-1.1.1.tar.gz 99.7 kB Details

Built distribution (wheel)

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

Total release size: 131.9 kB

Release files / lcgp-1.1.1.tar.gz

Download URL lcgp-1.1.1.tar.gz
Size 99.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9517065a72f5f991e4cb070b769e98c6a8d86647f757b3b490904f687c497756
BLAKE2b-256 checksum
How to use checksums
3a6469853454f12e2eb5f92f4904c4e1c9fff4b6313a12a1decb9fef4ce47638
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.1-py3-none-any.whl

Download URL lcgp-1.1.1-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e46fa6faecf5478a3553f9aced68e56aaf68957f75a92f21b862a52316dc1383
BLAKE2b-256 checksum
How to use checksums
158d79cff58f28a16563c4e3056e3b6e4af9ef482d5cd56744d27d56c2f15582
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

This release

1.1.1 This release

2 release files

1.1.0

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