apparun.parameters#
Classes#
Impact model enum parameter. |
|
Impact model float parameter. |
|
Impact model parameter. |
|
Module Contents#
- class apparun.parameters.EnumParam#
Bases:
ImpactModelParam
Impact model enum parameter. Contains a default, list of options and associated weights for monte carlo run. runs.
- corresponds(symbol_name: str) bool #
- draw_to_distrib(samples: numpy.ndarray) List[str] #
- full_option_name(option: str) str #
Return option with parameter name as a prefix. :param option: enum option. :return: option name with parameter name as a prefix.
- look_up_table() Dict[str, Dict[str, int]] #
Map every option to its one hot encoded vector, i.e. a dict with dummies names and associated value (1 if corresponding to current option, 0 otherwise). :return: a nested dict with all option and corresponding one hot encoded vector.
- transform(values: str | List[str]) Dict[str, float | numpy.array] #
Transform option, or list of options to be readily usable by ImpactModel. Value(s) one hot encoded, then mapped to a dict with parameter name as a key. :param values: :return: a dict mapping parameter name and transformed values.
- property dummies_names#
Give dummies names of all possible options. A dummy name is the option with parameter name as a prefix. :return: a list containing dummies names for all possible options.
- property options#
- type: str = 'enum'#
- weights: Dict[str, float]#
- class apparun.parameters.FloatParam(**kwargs)#
Bases:
ImpactModelParam
Impact model float parameter. Contains a default, min and max values, as well as a distribution for monte carlo runs. Supported distributions is “linear”.
- corresponds(symbol_name: str) bool #
- draw_to_distrib(samples: numpy.ndarray) List[float] #
- transform(values: float | List[float]) Dict[str, float | numpy.array] #
Transform float value, or list of float values to be readily usable by ImpactModel. Value(s) are mapped to a dict with parameter name as a key. :param values: :return: a dict mapping parameter name and transformed values.
- update_bounds()#
Compute min and max attributes from default attribute if pm, or pm_perc attributes is not None.
- update_default(new_value: float)#
Change default value of the parameter, and compute new min and max values if they are defined using pm or pm_perc. :param new_value: new default value
- distrib: str | None = 'linear'#
- max: float | None = None#
- min: float | None = None#
- pm: float | None = None#
- pm_perc: float | None = None#
- type: str = 'float'#
- class apparun.parameters.ImpactModelParam#
Bases:
pydantic.BaseModel
Impact model parameter.
- corresponds(symbol_name: str) bool #
- draw_to_distrib(samples) List[str] | List[float] #
- static from_dict(impact_model_param: dict) ImpactModelParam #
Convert dict to ImpactModelParam object. Subclass must be specified in ‘type’ field. :param impact_model_param: dict containing construction parameters of the param. :param frozen: should base model be frozen? Allows it to be hashable. :return: constructed param
- name_is_valid() bool #
Check if parameter’s name is considered as valid. Parameter name should only be composed of letters, numbers, underscores, and contain at least one letter. :return: if parameter’s name is valid
- to_dict() dict #
Convert self to dict. :return: self as a dict
- update_default(new_value: float | str)#
Change default value of the parameter, and compute new bounds if relevant. :param new_value: new default value
- default: str | float#
- name: str#
- class apparun.parameters.ImpactModelParams(**args)#
Bases:
pydantic.BaseModel
- draw_to_distrib(samples: numpy.ndarray) Dict[str, List[float] | List[str]] #
- find_corresponding_parameter(symbol_name: str, must_find_one: bool | None = True) ImpactModelParam | List[ImpactModelParam] #
- static from_list(parameters) ImpactModelParams #
- get_default_values(parameter_names: List) Dict #
- get_missing_parameter_names(parameters: List | Dict) List #
- get_parameter_by_name(parameter_name: str) ImpactModelParam | None #
- set_sobol_problem()#
- sobol_draw(n) numpy.ndarray #
- to_list(sorted_by_name: bool | None = False) List[Dict] #
Convert each parameter of parameters attribute to a dict, return them as a list, optionally sorted by parameter’s name :param sorted_by_name: sort parameters list by parameter’s name if True :return: list of parameter, themselves as dict
- uniform_draw(n) numpy.ndarray #
- update_defaults(defaults: Dict[str, str | float])#
Change default value of the parameters contained in argument, and compute new bounds if relevant. :param defaults: dict containing parameter name as key and new default as value
- property names#
- parameters: List[ImpactModelParam]#
- sobol_problem: Dict | None = None#