discontinuum.engines.pymc#

Data transformations to improve optimization

Classes

LatentPyMC([model_config])

MarginalPyMC([model_config])

class discontinuum.engines.pymc.LatentPyMC(model_config: Dict | None = None)#
fit(covariates, target=None)#

Fit model to data.

Parameters:
  • covariates (Dataset) – Covariates for training.

  • target (Dataset) – Target data for training.

  • kwargs (dict) – Additional keyword arguments.

class discontinuum.engines.pymc.MarginalPyMC(model_config: Dict | None = None)#
build_model(X, y, **kwargs)#

TODO: move this to parent?

Creates an instance of pm.Model based on provided data and model_config, and attaches it to self.

The subclass method must instantiate self.model and self.gp.

Raises:

NotImplementedError

fit(covariates: Dataset, target: Dataset, method: str = 'BFGS')#

Fit the model to data.

Parameters:
  • covariates (Dataset) – Covariates for prediction.

  • target (Dataset) – Target data for prediction.

  • method (str, optional) – Optimization method. The default is “BFGS”.

predict(covariates, diag=True, pred_noise=False) DataArray#

Uses the fitted model to make predictions on new data.

predict_grid(covariate: str, coord: str = None, t_step: int = 12)#

Predict on a grid of points.

Parameters:
  • covariate (str) – Covariate dimension to predict on.

  • coord (str, optional) – Coordinate of the covariate dimension to predict on. The default is the first coordinate of the covariate.

  • t_step (int, optional) – Number of grid points per step in coord units. The default is 12.

sample(covariates, n=1000, diag=False, pred_noise=False, method='cholesky', tol=1e-06) DataArray#

Sample from the posterior distribution of the model.

Parameters:
  • covariates (Dataset) – Covariates for prediction.

  • n (int, optional) – Number of samples to draw.

  • ‘svd’ (method{) – Method to use for covariance matrix decomposition. The default is ‘cholesky’.

  • ‘eigh’ – Method to use for covariance matrix decomposition. The default is ‘cholesky’.

  • ‘cholesky’} – Method to use for covariance matrix decomposition. The default is ‘cholesky’.

  • optional – Method to use for covariance matrix decomposition. The default is ‘cholesky’.

  • tol (float, optional) – Tolerance when checking the singular values in covariance matrix. The default is 1e-6.