matrix.Matrix.add_criterion

Matrix.add_criterion(criterion: str, *, weight: float, **choices_to_ratings)

Add a criterion into the matrix to evaluate each choice against.

Parameters

criterion (str) – Name of the criterion to add.

Keyword Arguments
  • weight (float) – How important this criterion is (usually on a 0-10 scale).

  • **choices_to_ratings (float, optional) – Immediately assign a rating (dictionary values) to given choices (dictionary keys).

Raises

ValueError – If a weight value is zero.

Examples

>>> import matrix
>>> m = matrix.Matrix()
>>> m.add_criterion('taste', weight=7)
>>> m
|        |   taste |
|:-------|--------:|
| Weight |       7 |
>>> m = matrix.Matrix('apple', 'orange')
>>> m.add_criterion('color', weight=3, apple=4, orange=6)
>>> m
|        |   color | Percentage   |
|:-------|--------:|:-------------|
| Weight |       3 |              |
| apple  |       4 | 40.0         |
| orange |       6 | 60.0         |