matrix.Matrix.update_weight

Matrix.update_weight(criterion: str, weight: float)

Update the weight of a given criterion

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

  • weight (float) – The new value for the weight.

Examples

>>> import matrix
>>> m = matrix.Matrix(
...     choices=('apple', 'orange'),
...     criteria=('taste', 'color'),
...     weights=(7, 3)
... )
>>> m.rate_choice('apple', taste=1, color=2)
>>> m.rate_choice('orange', taste=3, color=4)
>>> m.update_weight('color', 9)
>>> m
|        |   taste |   color | Percentage   |
|:-------|--------:|--------:|:-------------|
| Weight |       7 |       9 |              |
| apple  |       1 |       2 | 15.625       |
| orange |       3 |       4 | 35.625       |