gp_api.utils package
Submodules
gp_api.utils.fit_compact module
Utilities for the compact kernel
- gp_api.utils.fit_compact.fit_compact_nd(x_train, y_train, whitenoise=0.0, sparse=True, xpy=None, order=1, **kwargs)
Fit data for an arbitrary function using the compact kernel
- Parameters
x_train (array like, shape = (npts, dim)) – Training data samples
y_train (array like, shape = (npts,)) – Training data values
whitenoise (float, optional) – White noise kernel threshold
sparse (bool, optional) – Use sparse matrix operations from scikit-sparse?
xpy (ModuleType, optional) – A module, either
numpyorcupy.cupyis not yet supported.
- gp_api.utils.fit_compact.train_function(true_pdf, dim, limits=None, train_res=10, xnoise=0.0, ynoise=0.0, seed=10)
Generate training data for an arbitrary function on a grid
- Parameters
true_pdf (function) – A function to evaluate the pdf on
dim (int) – Number of dimensions
limits (array like, shape = (dim, 2)) – List of
(min, max)pairs for each dimensionres (float) – Sample resolution for training
xnoise (float) – Input noise for data
ynoise (float) – Output noise for data
seed (np.random.RandomState or int, optional) – Seed for the random number generator
gp_api.utils.fit_matern module
Utilities for the Matern kernel
- gp_api.utils.fit_matern.fit_matern_nd(x_train, y_train, whitenoise=0.0, nu=0.5, xpy=None, **kwargs)
Fit data for an arbitrary function using the compact kernel
- Parameters
x_train (array like, shape = (npts, dim)) – Training data samples
y_train (array like, shape = (npts,)) – Training data values
whitenoise (float, optional) – White noise kernel threshold
sparse (bool, optional) – Use sparse matrix operations from scikit-sparse?
xpy (ModuleType, optional) – A module, either
numpyorcupy.cupyis not yet supported.
gp_api.utils.hypercube module
Utilities for hypercubes
- gp_api.utils.hypercube.sample_hypercube(limits, res)
Generate a list of points for a hypercube with shape
(res**dim, dim)- Parameters
limits (array like, shape = (dim, 2)) – List of [min,max] pairs for each dimension
res (int) – Sample resolution in one dimension
gp_api.utils.multigauss module
Utility for multi-dimensional Gaussians
- class gp_api.utils.multigauss.Multigauss(ngauss, dim, limits=None, std_offset=0.1, seed=10)
Bases:
objectMulti-Gaussian probability density
This is a useful distribution for testing KDE accuracy.
- rvs(n_sample)
Draw random samples
- Parameters
n_sample (int) – Number of random samples to draw
- sample_grid_gp(sample_res=10)
Sample a grid of hypercube points with GP approximate y values
- train(x_train, y_train, **kwargs)
Train a compact GP approximate using training data
- Parameters
x_train (array like, shape = (npts,)) – Training samples matching the pdf
y_train (array like, shape = (npts,)) – Training values matching the pdf
- train_matern(x_train, y_train, **kwargs)
Train a Matern GP approximate using training data
- Parameters
x_train (array like, shape = (npts,)) – Training samples matching the pdf
y_train (array like, shape = (npts,)) – Training values matching the pdf
- training_grid(train_res=10, xnoise=0.0, ynoise=0.0)
Generate a training grid
- Parameters
train_res (int, optional) – Number of training points on side of hypercube
xnoise (float, optional) – Scaling on noise added to
x_trainynoise (float) – Scaling on noise added to
y_train
gp_api.utils.utils module
General utilities used by the package
- gp_api.utils.utils.fit_compact_nd(x_train, y_train, whitenoise=0.0, sparse=True, xpy=None, **kwargs)
Fit data for an arbitrary function using the compact kernel
- Parameters
ndarray[npts (x_train) –
dim] (Training data samples) –
ndarray[npts] (y_train) –
whitenoise (Whitenoise kernel threshold) –
sparse (Use sparse matrix operations from scikit-sparse?) –
xpy (numpy equivalent (alternatively cupy)) –
- gp_api.utils.utils.fit_multigauss(n_gauss, dim, limits=None, seed=10)
Fit a number of Multivariate Normal distributions in n dimensinos
- Inputs:
n_gauss: number of gaussians to generate dim: number of dimensions limits ndarray[:,2]: list of [min,max] pairs seed: numpy random state or int
- gp_api.utils.utils.multigauss_nd(n_gauss, dim, limits=None, train_res=10, sample_res=10, xnoise=0, ynoise=0, whitenoise=0.0, seed=20211222, sparse=True, xpy=None)
Model an n dimensional gaussian and provide a sample cube
- Inputs:
n_gauss: number of gaussians to generate dim: number of dimensions limits ndarray[:,2]: list of [min,max] pairs train_res: sample resolution for hypercube training data sample_res: sample resolution for hypercube samples xnoise: input noise for data ynoise: output noise for data whitenoise: noise for whitenoise kernel seed: numpy random state or int sparse: Use sparse matrix operations from scikit-sparse? xpy: numpy equivalent (alternatively cupy)
- gp_api.utils.utils.multigauss_samples(n_gauss, dim, n_sample, limits=None, seed=20211222)
Model an n dimensional gaussian and draw random samples
- Inputs:
n_gauss: number of gaussians to generate dim: number of dimensions n_sample: number of random samples to draw limits ndarray[:,2]: list of [min,max] pairs seed: numpy random state or int
- gp_api.utils.utils.sample_list_nd(limits, res)
Generate a list of points for a hypercube with shape (res**dim, dim)
- Inputs:
limits ndarray[:,2]: list of [min,max] pairs res int: sample resolution in one dimension
- gp_api.utils.utils.train_function(true_pdf, dim, limits=None, train_res=10, xnoise=0.0, ynoise=0.0, seed=10)
Generate training data for an arbitrary function on a grid
- Inputs:
true_pdf: a function to evaluate the pdf on dim: number of dimensions limits ndarray[:,2]: list of [min,max] pairs res: sample resolution for TRAINING xnoise = input noise for data ynoise: output noise for data seed: numpy random state or int