parameters
parameters and related helper classes and functions
- class ema_workbench.em_framework.parameters.BooleanParameter(name, default=None, variable_name=None, pff=False)
boolean model input parameter
A BooleanParameter is similar to a CategoricalParameter, except the category values can only be True or False.
- Parameters:
name (str)
variable_name (str, or list of str)
- class ema_workbench.em_framework.parameters.CategoricalParameter(name, categories, default=None, variable_name=None, pff=False, multivalue=False)
categorical model input parameter
- Parameters:
name (str)
categories (collection of obj)
variable_name (str, or list of str)
multivalue (boolean) – if categories have a set of values, for each variable_name a different one.
TODO (#)
TODO
- cat_for_index(index)
return category given index
- Parameters:
index (int)
- Return type:
object
- from_dist(name, dist)
alternative constructor for creating a parameter from a frozen scipy.stats distribution directly
- Parameters:
dist (scipy stats frozen dist)
**kwargs (valid keyword arguments for Parameter instance)
- index_for_cat(category)
return index of category
- Parameters:
category (object)
- Return type:
int
- class ema_workbench.em_framework.parameters.Constant(name, value)
Constant class,
can be used for any parameter that has to be set to a fixed value
- class ema_workbench.em_framework.parameters.IntegerParameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)
integer valued model input parameter
- Parameters:
name (str)
lower_bound (int)
upper_bound (int)
resolution (iterable)
variable_name (str, or list of str)
pff (bool) – if true, sample over this parameter using resolution in case of partial factorial sampling
- Raises:
ValueError – if lower bound is larger than upper bound
ValueError – if entries in resolution are outside range of lower_bound and upper_bound, or not an integer instance
ValueError – if lower_bound or upper_bound is not an integer instance
- classmethod from_dist(name, dist, **kwargs)
alternative constructor for creating a parameter from a frozen scipy.stats distribution directly
- Parameters:
dist (scipy stats frozen dist)
**kwargs (valid keyword arguments for Parameter instance)
- class ema_workbench.em_framework.parameters.Parameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)
Base class for any model input parameter
- Parameters:
name (str)
lower_bound (int or float)
upper_bound (int or float)
resolution (collection)
pff (bool) – if true, sample over this parameter using resolution in case of partial factorial sampling
- Raises:
ValueError – if lower bound is larger than upper bound
ValueError – if entries in resolution are outside range of lower_bound and upper_bound
- classmethod from_dist(name, dist, **kwargs)
alternative constructor for creating a parameter from a frozen scipy.stats distribution directly
- Parameters:
dist (scipy stats frozen dist)
**kwargs (valid keyword arguments for Parameter instance)
- class ema_workbench.em_framework.parameters.RealParameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)
real valued model input parameter
- Parameters:
name (str)
lower_bound (int or float)
upper_bound (int or float)
resolution (iterable)
variable_name (str, or list of str)
pff (bool) – if true, sample over this parameter using resolution in case of partial factorial sampling
- Raises:
ValueError – if lower bound is larger than upper bound
ValueError – if entries in resolution are outside range of lower_bound and upper_bound
- classmethod from_dist(name, dist, **kwargs)
alternative constructor for creating a parameter from a frozen scipy.stats distribution directly
- Parameters:
dist (scipy stats frozen dist)
**kwargs (valid keyword arguments for Parameter instance)
- ema_workbench.em_framework.parameters.parameters_from_csv(uncertainties, **kwargs)
Helper function for creating many Parameters based on a DataFrame or csv file
- Parameters:
uncertainties (str, DataFrame)
**kwargs (dict, arguments to pass to pandas.read_csv)
- Return type:
list of Parameter instances
This helper function creates uncertainties. It assumes that the DataFrame or csv file has a column titled ‘name’, optionally a type column {int, real, cat}, can be included as well. the remainder of the columns are handled as values for the parameters. If type is not specified, the function will try to infer type from the values.
Note that this function does not support the resolution and default kwargs on parameters.
An example of a csv:
NAME,TYPE,,, a_real,real,0,1.1, an_int,int,1,9, a_categorical,cat,a,b,c
this CSV file would result in
- [RealParameter(‘a_real’, 0, 1.1, resolution=[], default=None),
IntegerParameter(‘an_int’, 1, 9, resolution=[], default=None), CategoricalParameter(‘a_categorical’, [‘a’, ‘b’, ‘c’], default=None)]
- ema_workbench.em_framework.parameters.parameters_to_csv(parameters, file_name)
Helper function for writing a collection of parameters to a csv file
- Parameters:
parameters (collection of Parameter instances)
file_name (str)
The function iterates over the collection and turns these into a data frame prior to storing them. The resulting csv can be loaded using the parameters_from_csv function. Note that currently we don’t store resolution and default attributes.