The get_generative_model function#

Aliases#

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

Get generative model.

Returns a generative model instance suitable for forward simulations.

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 ({'Forward', 'MAPFisher', 'MAP', 'ADVI', 'MGVI', 'MCMC'}, optional) – The solving method. According to the chosen method a either a ForwardModel , MAPFisherModel, MAPModel, ADVIModel, MGVIModel, or MCMCModel instance is created. See the corresponding model class for further information. The default is ‘Forward’.

  • 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.

Raises:

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

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