xrspatial.mcda.weights.ahp_weights#

xrspatial.mcda.weights.ahp_weights(criteria: list[str], comparisons: dict[tuple[str, str], float]) tuple[dict[str, float], ConsistencyResult][source]#

Derive criterion weights from pairwise comparisons using AHP.

Uses the standard Saaty eigenvector method. Input pairwise comparisons on a 1-9 scale (or reciprocals). The function builds the full comparison matrix, computes the principal eigenvector for weights, and derives the consistency ratio.

Parameters:
  • criteria (list of str) – Criterion names in order.

  • comparisons (dict) – Pairwise comparisons as {(criterion_a, criterion_b): value}. Only provide each pair once; the reciprocal is inferred. Values follow the Saaty scale (1 = equal, 9 = extreme preference of a over b, 1/9 = extreme preference of b over a).

Returns:

  • weights (dict of str to float) – Normalized weights summing to 1.0.

  • consistency (ConsistencyResult) – Consistency ratio and related metrics. is_consistent is True when ratio < 0.10.

Raises:

ValueError – If criteria list has fewer than 2 items or comparisons are incomplete.