matrix.Matrix.criterion_value_to_score

Matrix.criterion_value_to_score(criterion_name: str, value_to_scores: dict[float, float])

Declare what score should a choice receive for a continuous criterion, given the values for that criterion.

Parameters
  • criterion_name (str) – The name of the criterion.

  • value_to_scores (dict[float, float]) – The criterion value (dictionary key) to score mapping (dictionary value). If a choice has a criterion value that matches exactly, the corresponding score must be assigned.

Examples

>>> import matrix
>>> m = matrix.Matrix()
>>> m.add_continuous_criterion('size', weight=4)
>>> m.criterion_value_to_score('size', {
...     # criterion value: score
...     0: 10,
...     10: 5,
...     15: 0,
... })
>>> m.value_score_df
   size  size_score
0     0          10
1    10           5
2    15           0