The get_posterior_model function#

Aliases#

halerium.core.get_posterior_model
halerium.core.model.get_posterior_model
get_posterior_model(graph, data=None, method=None, compiler=None, return_solved=True, copy_graph=True, model_graph_options=None, solver_args=None, **kwargs)#

Get posterior model.

Returns a model instance that calculates a posterior distribution. Such models are suitable for training or parameter estimation.

Parameters:
  • graph (halerium.core.Graph) – A Graph instance.

  • data (dict, halerium.core.DataLinker, optional) – The input data for the prediction. Either dictionary with variables as keys and data arrays as values, or a DataLinker holding links to the variables in graph. The default is None.

  • method ({'MAPFisher', 'MAP', 'ADVI', 'MGVI', or 'MCMC'}, optional) – The solving method. According to the chosen method either a MAPFisherModel, MAPModel, ADVIModel, MGVIModel, or MCMCModel instance is created. See the corresponding model classes for further information. The default is ‘MAPFisher’.

  • compiler (optional) – The compiler instance or class for compiling the model. The default is None, in which case a Tensorflow compiler is used.

  • return_solved (bool, optional) – Whether to return the model in a solved state. The default is True.

  • copy_graph (bool, optional) – Whether the model should make a copy of the graph for its own use, or just keep the graph itself as attribute. Users should leave this set to the default True, unless they are certain that the graph won’t be altered by the user or other code. Such changes to a graph a model holds directly (i.e. not a copy) makes that model inconsistent and likely causes errors.

  • model_graph_options (dict, optional) – The options for creating the model graph. The default is None.

  • solver_args (dict, optional) – The arguments to pass to the model’s solver function. The default is None.

  • **kwargs (model arguments, optional) – Further arguments that depend on the specified method. See the corresponding model classes for further information.

Returns:

model – An instance of the model class specified by method created with the provided graph and data_linker.

Return type:

halerium.core.model.model.Model

Raises:

ValueError – If the supplied method is unknown an error is raised.