Python-Based Models¶
-
class
emat.model.
PythonCoreModel
(function: Callable, configuration: Optional[Union[str, Mapping]] = None, scope: Optional[Union[emat.scope.scope.Scope, str]] = None, safe: bool = True, db: Optional[emat.database.database.Database] = None, name: str = 'EMAT', metamodel_id=None)[source]¶ Bases:
emat.model.core_model.AbstractCoreModel
,emat.workbench.em_framework.model.Model
An EMAT interface for a core model that is a Python function.
Parameters: - function (callable) – The Python function to be evaluated. This function must accept keyword arguments that include all of the uncertainties and levers, and return a dict that contains key-value pairs that map the names of performance measures to the computed performance measure outputs.
- configuration (str, dict, or None) – The configuration for this core model. This can be passed as a dict, or as a str which gives the filename of a yaml file that will be loaded. A core model that is a stand-alone Python function will not often not require any configuration.
- scope (Scope or str) – The Scope for this exploratory analysis. Can be given as an explicit Scope object, or as a str which gives the filename of a yaml file that will be loaded.
- safe (bool) – Load the configuration yaml file in ‘safe’ mode. This can be disabled if the configuration requires custom Python types or is otherwise not compatible with safe mode. Loading configuration files with safe mode off is not secure and should not be done with files from untrusted sources.
- db (Database) – An optional default Database to store experiments and results.
- name (str) – A name for this model, given as an alphanumeric string. The name is required by ema_workbench operations. If not given, the name of the function is extracted, or failing that, “EMAT” is used.
- metamodel_id – An identifier for this model, if it is a meta-model. Defaults to 0 (i.e., not a meta-model).