Matrix.
add_data
Adds criterion data for the given choice, which is used to calculate their score.
choice (str) – The name of the choice.
values_dict (Optional[dict[str, float]]) – The criterion-value pairs in the form of a dictionary.
**criteria_to_values (float) – The criterion-value pairs (str, float) as keyword arguments.
TypeError – If neither values_dict nor criteria_to_values is given.
TypeError
values_dict
criteria_to_values
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.add_data('apple', price=2, size=3) >>> m.add_data('orange', {'price': 7, 'size': 5}) >>> m | | size | price | Percentage | |:-------|-------:|--------:|:-------------------| | Weight | 4 | 8 | | | apple | 3 | 8 | 63.33333333333333 | | orange | 5 | 3 | 36.666666666666664 | >>> m.value_score_df price price_score size size_score 0 0.0 10.0 NaN NaN 1 10.0 0.0 NaN NaN 2 NaN NaN 0.0 0.0 3 NaN NaN 10.0 10.0 >>> m.data_df price size apple 2 3 orange 7 5
See also
batch_add_data()
The method that is wrapped