Skip to main content

Latent component Gaussian process

Project description

CI Coverage Status Documentation Status

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

lcgp-1.0.0.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lcgp-1.0.0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file lcgp-1.0.0.tar.gz.

File metadata

  • Download URL: lcgp-1.0.0.tar.gz
  • Upload date:
  • Size: 48.4 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

Hashes for lcgp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3c9d3e863554f3c228f8ae00d7e196c14a18ecccced011fd05f86527a87e5e3f
MD5 9adc6b33eca73d00890f6ed88571d183
BLAKE2b-256 b133491e92ceb32e0a6f34b84b1b9ce4b34e7603057a1c8097d369edf3cdd967

See more details on using hashes here.

File details

Details for the file lcgp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lcgp-1.0.0-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

Hashes for lcgp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 471c7652c235a43e3ab8c7a7db33a944059945738433bb4feb9c96e68d5d37aa
MD5 43d8cf21f2cb4f018a9b798a9ae6f909
BLAKE2b-256 11aeb5371857e6e70d9dad023a0442a6ed688dd86118d09fa805ec9b7c63311c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page