bayesvalidrox.surrogate_models.exp_designs.ExpDesigns

class bayesvalidrox.surrogate_models.exp_designs.ExpDesigns(input_object, meta_model_type='pce', sampling_method='random', hdf5_file=None, n_init_samples=1, n_new_samples=1, n_max_samples=None, mod_loo_threshold=1e-16, tradeoff_scheme=None, n_canddidate=1, explore_method='random', exploit_method='Space-filling', util_func='Space-filling', n_cand_groups=4, n_replication=1, max_func_itr=1, out_dir='')

Bases: InputSpace

This class generates samples from the prescribed marginals for the model parameters using the Input object.

Attributes

input_objectobj

Input object containing the parameter marginals, i.e. name, distribution type and distribution parameters or available raw data.

meta_model_typestr

Type of the meta_model_type.

sampling_methodstr

Name of the sampling method for the experimental design. The following sampling method are supported:

  • random

  • latin_hypercube

  • sobol

  • halton

  • hammersley

  • chebyshev(FT)

  • grid(FT)

  • user

hdf5_filestr

Name of the hdf5 file that contains the experimental design.

n_new_samplesint

Number of (initial) training points.

n_max_samplesint

Number of maximum training points.

mod_loo_thresholdfloat

The modified leave-one-out cross validation threshold where the sequential design stops.

tradeoff_schemestr

Trade-off scheme to assign weights to the exploration and exploitation scores in the sequential design.

n_canddidateint

Number of candidate training sets to calculate the scores for.

explore_methodstr

Type of the exploration method for the sequential design. The following methods are supported:

  • Voronoi

  • random

  • latin_hypercube

  • LOOCV

  • dual annealing

exploit_methodstr

Type of the exploitation method for the sequential design. The following methods are supported:

  • BayesOptDesign

  • BayesActDesign

  • VarOptDesign

  • alphabetic

  • Space-filling

util_funcstr or list

The utility function to be specified for the exploit_method. For the available utility functions see Note section.

n_cand_groupsint

Number of candidate groups. Each group of candidate training sets will be evaulated separately in parallel.

n_replicationint

Number of replications. Only for comparison. The default is 1.

Note

The following utiliy functions for the exploitation methods are supported:

#### BayesOptDesign (when data is available) - DKL (Kullback-Leibler Divergence) - DPP (D-Posterior-percision) - APP (A-Posterior-percision)

#### VarBasedOptDesign -> when data is not available - Entropy (Entropy/MMSE/active learning) - EIGF (Expected Improvement for Global fit) - LOOCV (Leave-one-out Cross Validation)

#### alphabetic - D-Opt (D-Optimality) - A-Opt (A-Optimality) - K-Opt (K-Optimality)

__init__(input_object, meta_model_type='pce', sampling_method='random', hdf5_file=None, n_init_samples=1, n_new_samples=1, n_max_samples=None, mod_loo_threshold=1e-16, tradeoff_scheme=None, n_canddidate=1, explore_method='random', exploit_method='Space-filling', util_func='Space-filling', n_cand_groups=4, n_replication=1, max_func_itr=1, out_dir='')

Methods

__init__(input_object[, meta_model_type, ...])

build_polytypes(rosenblatt)

Creates the polynomial types to be passed to univ_basis_vals method of the MetaModel object.

check_valid_inputs()

Check if the given input_object is valid to use for further calculations: 1) Has some Marginals 2) The Marginals have valid priors 3) All Marginals given as the same type (samples vs dist)

generate_ed([max_deg])

Generates experimental designs (training set) with the given method.

generate_samples(n_samples[, sampling_method])

Generates samples with given sampling method

init_param_space([max_deg])

Initializes parameter space.

pcm_sampler(n_samples, max_deg)

Generates collocation points based on the root of the polynomial degrees.

plot_samples(samples)

Visualizes generated samples over their given distributions.

random_sampler(n_samples[, max_deg])

Samples the given raw data randomly.

read_from_file(out_names)

Reads in the ExpDesign from a provided h5py file and saves the results.

transform(X[, params, method])

Transforms the samples via either a Rosenblatt or an isoprobabilistic transformation.

build_polytypes(rosenblatt)

Creates the polynomial types to be passed to univ_basis_vals method of the MetaModel object.

Parameters

rosenblattbool

Rosenblatt transformation flag.

Returns

orig_space_distobject

A chaospy j_dist object or a gaussian_kde object.

poly_typeslist

A list of polynomial types for the parameters.

check_valid_inputs() None

Check if the given input_object is valid to use for further calculations: 1) Has some Marginals 2) The Marginals have valid priors 3) All Marginals given as the same type (samples vs dist)

Returns

None

generate_ed(max_deg=1)

Generates experimental designs (training set) with the given method.

Parameters

max_degint, optional

Maximum (PCE) polynomial degree. The default is 1.

Returns

None

generate_samples(n_samples, sampling_method='random')

Generates samples with given sampling method

Parameters

n_samplesint

Number of requested samples.

sampling_methodstr, optional

Sampling method. The default is ‘random’.

Returns

samples: array of shape (n_samples, n_params)

Generated samples from defined model input object.

init_param_space(max_deg=1)

Initializes parameter space.

Parameters

max_degint, optional

Maximum degree. The default is 1.

Returns

raw_dataarray of shape (n_params, n_samples)

Raw data.

bound_tupleslist of tuples

A list containing lower and upper bounds of parameters.

pcm_sampler(n_samples, max_deg)

Generates collocation points based on the root of the polynomial degrees.

Parameters

n_samplesint

Number of requested samples.

max_degint

Maximum degree defined by user. Will also be used to run init_param_space if that has not been done beforehand.

Returns

opt_col_points: array of shape (n_samples, n_params)

Collocation points.

plot_samples(samples)

Visualizes generated samples over their given distributions.

Parameters

samplesarray

The samples to visualize.

Returns

None.

random_sampler(n_samples, max_deg=1)

Samples the given raw data randomly.

Parameters

n_samplesint

Number of requested samples.

max_degint, optional

Maximum degree. The default is 1. This will be used to run init_param_space, if it has not been done until now.

Returns

samples: array of shape (n_samples, n_params)

The sampling locations in the input space.

read_from_file(out_names)

Reads in the ExpDesign from a provided h5py file and saves the results.

Parameters

out_nameslist of strings

The keys that are in the outputs (y) saved in the provided file.

Returns

None.

transform(X, params=None, method=None)

Transforms the samples via either a Rosenblatt or an isoprobabilistic transformation.

Parameters

Xarray of shape (n_samples,n_params)

Samples to be transformed.

paramslist

Parameters for laguerre/gamma-type distribution.

methodstring

If transformation method is ‘user’ transform X, else just pass X.

Returns

tr_x: array of shape (n_samples,n_params)

Transformed samples.