physbo.blm package
Subpackages
Module contents
Bayesian Linear Model
- class physbo.blm.Model(lik, prior, options={})[ソース]
ベースクラス:
object
Baysean Linear Model
- prior
prior distribution of weights
- Type:
physbo.blm.prior.Gauss
- lik
kernel
- Type:
- nbasis
number of features in random feature map
- Type:
int
- stats
auxially parameters for sampling
- Type:
Tuple
- method
sampling method
- Type:
str
- get_permutation_importance(X, t, n_perm: int, comm=None, split_features_parallel=False)[ソース]
Calculating permutation importance of model
- パラメータ:
X (numpy.ndarray) -- inputs
t (numpy.ndarray) -- target (label)
n_perm (int) -- number of permutations
comm (MPI.Comm) -- MPI communicator
- 戻り値:
numpy.ndarray -- importance_mean
numpy.ndarray -- importance_std
- get_post_fcov(X, Psi=None, diag=True)[ソース]
calculates posterior covariance of model
- パラメータ:
X (numpy.ndarray) -- inputs
Psi (numpy.ndarray) -- feature maps (default: blm.lik.linear.basis.get_basis(X))
diag (bool) -- if True, returns only variances as a diagonal matrix (default: True)
- 戻り値:
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.
- 戻り値の型:
numpy.ndarray
- get_post_fmean(X, Psi=None, w=None)[ソース]
calculates posterior mean of model (function)
- パラメータ:
X (numpy.ndarray) -- inputs
Psi (numpy.ndarray) -- feature maps
w (numpy.ndarray) -- weight
- post_sampling(Xtest, Psi=None, N=1, alpha=1.0)[ソース]
draws samples of mean value of model
- パラメータ:
Xtest (numpy.ndarray) -- inputs
Psi (numpy.ndarray) -- feature maps (default:
blm.lik.get_basis(Xtest)
)N (int) -- number of samples (default: 1)
alpha (float) -- noise for sampling source
- 戻り値の型:
numpy.ndarray
- predict_sampling(Xtest, Psi=None, N=1)[ソース]
draws samples from model
- パラメータ:
Xtest (numpy.ndarray) -- inputs
Psi (numpy.ndarray) -- feature map (default:
blm.lik.get_basis(Xtest)
)N (int) -- number of samples (default: 1)
- 戻り値の型:
numpy.ndarray
- prepare(X, t, Psi=None)[ソース]
initializes model by using the first training dataset
- パラメータ:
X (numpy.ndarray) -- inputs
t (numpy.ndarray) -- target (label)
Psi (numpy.ndarray) -- feature maps
- sampling(w_mu=None, N=1, alpha=1.0)[ソース]
draws samples of weights
- パラメータ:
blm (physbo.blm.core.Model) -- model
w_mu (numpy.ndarray) -- mean of weight
N (int) -- the number of samples (default: 1)
alpha (float) -- noise for sampling source (default: 1.0)
- 戻り値:
samples of weights
- 戻り値の型:
numpy.ndarray
- class physbo.blm.Predictor(config, model=None)[ソース]
ベースクラス:
BasePredictor
Predictor using Baysean linear model
- blm
- Type:
- config
configuration
- Type:
physbo.misc.SetConfig
- パラメータ:
config (physbo.misc.SetConfig) -- configuration
model (physbo.gp.core.Model)
- fit(training, num_basis=None, comm=None)[ソース]
fit model to training dataset
- パラメータ:
training (physbo.variable) -- dataset for training
num_basis (int) -- the number of basis (default: self.config.predict.num_basis)
comm (MPI.Comm) -- MPI communicator
- get_basis(X)[ソース]
calculates feature maps Psi(X)
- パラメータ:
X (numpy.ndarray) -- inputs
- 戻り値:
Psi -- feature maps
- 戻り値の型:
numpy.ndarray
- get_post_fcov(training, test, diag=True)[ソース]
calculates posterior variance-covariance matrix of model
- パラメータ:
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.
- 戻り値:
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.
- 戻り値の型:
numpy.ndarray
- get_post_fmean(training, test)[ソース]
calculates posterior mean value of model
- パラメータ:
training (physbo.variable) -- training dataset. If already trained, the model does not use this.
test (physbo.variable) -- inputs
- 戻り値:
Returned shape is (num_points), where num_points is the number of points in test.
- 戻り値の型:
numpy.ndarray
- get_post_params(training, test)[ソース]
calculates posterior weights
- パラメータ:
training (physbo.variable) -- training dataset. If already trained, the model does not use this.
test (physbo.variable) -- inputs (not used)
- 戻り値の型:
numpy.ndarray
- get_post_samples(training, test, N=1, alpha=1.0)[ソース]
draws samples of mean values of model
- パラメータ:
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)
alpha (float) -- noise for sampling source (default: 1.0)
- 戻り値の型:
numpy.ndarray
- get_predict_samples(training, test, N=1)[ソース]
draws samples of values of model
- パラメータ:
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)
alpha (float) -- noise for sampling source (default: 1.0)
- 戻り値の型:
numpy.ndarray (N x len(test))
- prepare(training)[ソース]
initializes model by using training data set
- パラメータ:
training (physbo.variable) -- dataset for training
- update(training, test)[ソース]
updates the model.
If not yet initialized (prepared), the model will be prepared by
training
. Otherwise, the model will be updated bytest
.- パラメータ:
training (physbo.variable) -- training dataset for initialization (preparation). If already prepared, the model ignore this.
test (physbo.variable) -- training data for update. If not prepared, the model ignore this.