Matrix.
batch_add_data
For multiple choices, add criterion data. If the length of either list is different, the extra items in the longer list is ignored.
choices_and_values (dict[str, dict[str, float]]) – The nested dictionary that maps the choices to another dictionary. The inner dictionary maps the criteria to the data.
Examples
>>> import matrix >>> m = matrix.Matrix() # No need to add choices >>> m.add_continuous_criterion('size', weight=4) >>> m.add_continuous_criterion('price', weight=8) >>> m.if_(price=0).then(score=10) >>> m.if_(price=10).then(score=0) >>> m.if_(size=0).then(score=0) >>> m.if_(size=10).then(score=10) >>> m.batch_add_data({ ... 'apple': {'price': 8, 'size': 5}, ... 'orange': {'price': 5, 'size': 3} ... }) >>> m | | size | price | Percentage | |:-------|-------:|--------:|:-------------------| | Weight | 4 | 8 | | | apple | 5 | 2 | 30.0 | | orange | 3 | 5 | 43.333333333333336 | >>> m.data_df price size apple 8 5 orange 5 3
Note
This method has time complexity O(n) in respect to the number of continuous criteria.