Previous topic

Model libraries

Next topic

Cash flow model library

This Page

Aggregation model libraryΒΆ

An aggregation model takes one attribute as its input parameter. The parameter is an instance of the AggregationArg class (see simo.simulation.model.aggregationarg).

The object instance has the following attributes:

  • operands – the number of operands for the model
  • target_variable – index of the target variable in the data matrix
  • remove_targets – indices of the objects for which the aggregation model is not evaluated
  • use_nan_funcs – boolean indicating NaN values in the data
  • values – operand values
  • weights – weight attribute values
  • target_index – indices of the object for which the model is evaluated
  • oper_target_index – target index tables for operand(s)
  • oper_data_level – operand data level indice, int
  • success – boolean for successfull model evaluation
  • errors – list of errors encountered during model evaluation
  • deterministic – boolean that can be used to control whether random values are used in aggregation models or not (among others, random number generation is treated as an aggregation model)
  • results – a numpy vector for storing aggregation results, NOTE: aggregation model implementation is responsible for making sure that this actually is a numpy array

Below is an example of a very simple substract aggregation model:

def substract(arg):
    """Substract two operands
    """
    if arg.operands != 2:
        arg.success = False
        arg.errors.append("Two operands required in 'substract'")
    else:
        arg.results = arg.values[0] - arg.values[1]