physbo.gp package

Subpackages

Module contents

class physbo.gp.Model(lik, mean, cov, inf='exact')[source]

Bases: object

Parameters:
  • lik

  • mean

  • cov

  • inf

cat_params(lik_params, prior_params)[source]

Concatinate the likelihood and prior parameters

Parameters:
  • lik_params (numpy.ndarray) – Parameters for likelihood

  • prior_params (numpy.ndarray) – Parameters for prior

Returns:

params – parameters about likelihood and prior

Return type:

numpy.ndarray

decomp_params(params=None)[source]

decomposing the parameters to those of likelifood and priors

Parameters:

params (numpy.ndarray) – parameters

Returns:

  • lik_params (numpy.ndarray)

  • prior_params (numpy.ndarray)

eval_marlik(params, X, t, N=None)[source]

Evaluating marginal likelihood.

Parameters:
  • params (numpy.ndarray) – Parameters.

  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • N (int) – Total number of subset data (if not specified, all dataset is used)

Returns:

  • marlik (float)

  • Marginal likelihood.

export_blm(num_basis, comm=None)[source]

Exporting the blm(Baysean linear model) predictor

Parameters:
  • num_basis (int) – Total number of basis

  • comm (MPI.Comm) – MPI communicator

Returns:

Bayesian linear model

Return type:

physbo.blm.core.Model

fit(X, t, config, comm=None)[source]

Fitting function (update parameters)

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • config (physbo.misc.set_config object)

  • comm (MPI.Comm) – MPI communicator

get_cand_params(X, t)[source]

Getting candidate for parameters

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

Returns:

params – Parameters

Return type:

numpy.ndarray

get_grad_marlik(params, X, t, N=None)[source]

Evaluating gradiant of marginal likelihood.

Parameters:
  • params (numpy.ndarray) – Parameters.

  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • N (int) – Total number of subset data (if not specified, all dataset is used)

Returns:

grad_marlik – Gradiant of marginal likelihood.

Return type:

numpy.ndarray

get_params_bound()[source]

Getting boundary of the parameters.

Returns:

bound – An array with the tuple (min_params, max_params).

Return type:

list

get_permutation_importance(X, t, n_perm: int, comm=None, split_features_parallel=False)[source]

Calculating permutation importance of model

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • n_perm (int) – Number of permutations

  • comm (MPI.Comm) – MPI communicator

Returns:

  • numpy.ndarray – importance_mean

  • numpy.ndarray – importance_std

get_post_fcov(X, Z, params=None, diag=True)[source]

Calculating posterior covariance matrix of model (function)

Parameters:
  • X (numpy.ndarray) – inputs

  • Z (numpy.ndarray) – feature maps

  • params (numpy.ndarray) – Parameters

  • diag (bool) – If true, only variances (diagonal elements) are returned.

Returns:

Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false, where num_points is the number of points in X.

Return type:

numpy.ndarray

get_post_fmean(X, Z, params=None)[source]

Calculating posterior mean of model (function)

Parameters:
  • X (numpy.ndarray) – inputs

  • Z (numpy.ndarray) – feature maps

  • params (numpy.ndarray) – Parameters

post_sampling(X, Z, params=None, N=1, alpha=1)[source]

draws samples of mean value of model

Parameters:
  • X (numpy.ndarray) – inputs

  • Z (numpy.ndarray) – feature maps

  • N (int) – number of samples (default: 1)

  • alpha (float) – noise for sampling source

Return type:

numpy.ndarray

predict_sampling(X, Z, params=None, N=1)[source]
Parameters:
  • X (numpy.ndarray) – training datasets

  • Z (numpy.ndarray) – input for sampling objective values

  • params (numpy.ndarray) – Parameters

  • N (int) – number of samples (default: 1)

Return type:

numpy.ndarray

prepare(X, t, params=None)[source]
Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • params (numpy.ndarray) – Parameters.

print_params()[source]

Printing parameters

set_params(params)[source]

Setting parameters

Parameters:

params (numpy.ndarray) – Parameters.

sub_sampling(X, t, N)[source]

Make subset for sampling

Parameters:
  • X (numpy.ndarray) – Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – The negative energy of each search candidate (value of the objective function to be optimized).

  • N (int) – Total number of data in subset

Returns:

  • subX (numpy.ndarray)

  • subt (numpy.ndarray)

class physbo.gp.Predictor(config, model=None)[source]

Bases: BasePredictor

Predictor using Gaussian process

Parameters:
  • config (physbo.misc.SetConfig)

  • model (model object) – A default model is set as gp.core.Model

delete_stats()[source]

Default function to delete status. This function must be overwritten in each model.

Parameters:
  • args

  • kwds

fit(training, num_basis=None, comm=None)[source]

Fitting model to training dataset

Parameters:
  • training (physbo.variable) – dataset for training

  • num_basis (int) – Not used for gp.model the number of basis (default: self.config.predict.num_basis)

  • comm (MPI.Comm) – MPI communicator

get_basis(*args, **kwds)[source]
Parameters:
  • args

  • kwds

get_post_fcov(training, test, diag=True)[source]

Calculating posterior variance-covariance matrix of model

Parameters:
  • training (physbo.variable) – training dataset. If already trained, the model does not use this.

  • test (physbo.variable) – inputs

  • diag (bool) – If true, only variances (diagonal elements) are returned.

Returns:

Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false, where num_points is the number of points in test.

Return type:

numpy.ndarray

get_post_fmean(training, test)[source]

Calculating posterior mean value of model

Parameters:
  • training (physbo.variable) – training dataset. If already trained, the model does not use this.

  • test (physbo.variable) – inputs

Return type:

numpy.ndarray

get_post_params(*args, **kwds)[source]
Parameters:
  • args

  • kwds

get_post_samples(training, test, alpha=1)[source]

Drawing samples of mean values of model

Parameters:
  • training (physbo.variable) – training dataset. If already trained, the model does not use this.

  • test (physbo.variable) – inputs (not used)

  • alpha (float) – tuning parameter of the covariance by multiplying alpha**2 for np.random.multivariate_normal.

Return type:

numpy.ndarray

get_predict_samples(training, test, N=1)[source]

Drawing samples of values of model

Parameters:
  • training (physbo.variable) – training dataset. If already trained, the model does not use this.

  • test (physbo.variable) – inputs

  • N (int) – number of samples (default: 1)

Return type:

numpy.ndarray (N x len(test))

prepare(training)[source]

Initializing model by using training data set

Parameters:

training (physbo.variable) – dataset for training

update(training, test)[source]

Default function to update variables. This function must be overwritten in each model.

Parameters:
  • args

  • kwds

class physbo.gp.Prior(mean, cov)[source]

Bases: object

prior of gaussian process

Parameters:
cat_params(mean_params, cov_params)[source]
Parameters:
  • mean_params (numpy.ndarray) – Mean values of parameters

  • cov_params (numpy.ndarray) – Covariance matrix of parameters

Return type:

numpy.ndarray

decomp_params(params)[source]

decomposing the parameters to those of mean values and covariance matrix for priors

Parameters:

params (numpy.ndarray) – parameters

Returns:

  • mean_params (numpy.ndarray)

  • cov_params (numpy.ndarray)

get_cov(X, Z=None, params=None, diag=False)[source]

Calculating the variance-covariance matrix of priors

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • Z (numpy.ndarray) – N x d dimensional matrix. Each row of Z denotes the d-dimensional feature vector of tests.

  • params (numpy.ndarray) – Parameters.

  • diag (bool) – If true, only variances (diagonal elements) are returned.

Returns:

Returned shape is (num_points) if diag=true, (num_points, num_points) if diag=false, where num_points is the number of points in X.

Return type:

numpy.ndarray

get_grad_cov(X, params=None)[source]

Calculating the covariance matrix priors

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • params (numpy.ndarray) – Parameters.

Return type:

numpy.ndarray

get_grad_mean(num_data, params=None)[source]

Calculating the gradiant of mean values of priors

Parameters:
  • num_data (int) – Total number of data

  • params (numpy.ndarray) – Parameters

Return type:

numpy.ndarray

get_mean(num_data, params=None)[source]

Calculating the mean value of priors

Parameters:
  • num_data (int) – Total number of data

  • params (numpy.ndarray) – Parameters

Return type:

float

sampling(X, N=1)[source]

Sampling from GP prior

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • N (int)

Return type:

float

set_cov_params(params)[source]

Setting parameters for covariance matrix of priors

Parameters:

params (numpy.ndarray) – Parameters

set_mean_params(params)[source]

Setting parameters for mean values of priors

Parameters:

params (numpy.ndarray) – Parameters

set_params(params)[source]

Setting parameters

Parameters:

params (numpy.ndarray) – Parameters.

class physbo.gp.SFS(lik, mean, cov, inf='exact', config=None)[source]

Bases: Model

Parameters:
  • lik

  • mean

  • cov

  • inf

fit(X, t)[source]

Fitting function (update parameters)

Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • config (physbo.misc.SetConfig object)

get_params(deep=True)[source]
get_post_fmean(X, Z, params=None)[source]

Calculating posterior mean of model (function)

Parameters:
  • X (numpy.ndarray) – inputs

  • Z (numpy.ndarray) – feature maps

  • params (numpy.ndarray) – Parameters

predict(Z, params=None)[source]

Calculating posterior mean of model (function)

Parameters:
  • X (numpy.ndarray) – inputs

  • Z (numpy.ndarray) – feature maps

  • params (numpy.ndarray) – Parameters

prepare(X, t, params=None)[source]
Parameters:
  • X (numpy.ndarray) – N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of search candidate.

  • t (numpy.ndarray) – N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).

  • params (numpy.ndarray) – Parameters.