physbo.blm.core.model module

class physbo.blm.core.model.model(lik, prior, options={})[source]

Bases: object

Baysean Linear Model

prior

prior distribution of weights

Type:

physbo.blm.prior.gauss

lik

kernel

Type:

physbo.blm.lik.gauss

nbasis

number of features in random feature map

Type:

int

stats

auxially parameters for sampling

Type:

Tuple

method

sampling method

Type:

str

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

calculates posterior covariance of model

Parameters:
  • 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)

Return type:

numpy.ndarray

get_post_fmean(X, Psi=None, w=None)[source]

calculates posterior mean of model (function)

Parameters:
  • X (numpy.ndarray) – inputs

  • Psi (numpy.ndarray) – feature maps

  • w (numpy.ndarray) – weight

get_post_params_mean()[source]

calculates posterior mean of weights

Return type:

numpy.ndarray

post_sampling(Xtest, Psi=None, N=1, alpha=1.0)[source]

draws samples of mean value of model

Parameters:
  • 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

Return type:

numpy.ndarray

predict_sampling(Xtest, Psi=None, N=1)[source]

draws samples from model

Parameters:
  • Xtest (numpy.ndarray) – inputs

  • Psi (numpy.ndarray) – feature map (default: blm.lik.get_basis(Xtest))

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

Return type:

numpy.ndarray

prepare(X, t, Psi=None)[source]

initializes model by using the first training dataset

Parameters:
  • X (numpy.ndarray) – inputs

  • t (numpy.ndarray) – target (label)

  • Psi (numpy.ndarray) – feature maps

sampling(w_mu=None, N=1, alpha=1.0)[source]

draws samples of weights

Parameters:
  • 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)

Returns:

samples of weights

Return type:

numpy.ndarray

update_stats(x, t, psi=None)[source]

updates model by using another training data

Parameters:
  • x (numpy.ndarray) – input

  • t (float) – target (label)

  • psi (numpy.ndarray) – feature map