Multi-Criteria Decisions and Responsible Analytics¶
Every model in this course so far had one number to make as good as possible: profit, cost, NPV, expected value. Many real decisions have several goals that do not convert into riyals: quality, reliability, sustainability, risk. This reading shows how to choose with several criteria in a way you can show and defend: screen out the options that cannot win, put the criteria on one scale, weigh them (with AHP when the weights are disputed), rank the options (weighted sum and TOPSIS), and test how much the weights would have to change before the answer changes.
The second part is about responsible analytics: what a model assumes and what it leaves out, personal data, whether a model’s decisions treat groups of people differently, how to document a recommendation, and how to use generative AI honestly. These are the questions you will be asked at your capstone defence.
After this reading you can:
set up a decision matrix and screen out dominated options;
normalise criteria and rank options with a weighted sum;
derive weights from pairwise comparisons with AHP and check their consistency;
rank options with TOPSIS;
find how much a weight must change before the winner changes;
check a model’s decisions group by group, and document a recommendation’s assumptions, limits and use of AI.
Setup¶
Everything here runs with pandas, NumPy and matplotlib; Part 2 also uses scikit-learn. Colab has all of them.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
BASE = "https://chebil.github.io/BusinessDecision/data/"
def load(name):
"""Read a course dataset from the website, or from a local copy of the repository."""
try:
return pd.read_csv(BASE + name)
except Exception: # offline, or working from a copy of the course repository
return pd.read_csv("../data/" + name)
suppliers = load("qahwa_supplier_criteria.csv")
suppliers1. The decision¶
Qahwa House roasts about 50 tonnes of green coffee a year for its house blend. The import contract ends this year, and the board must choose one importer for the next two years among five. The purchasing team scored each of them on five criteria:
| Column | Criterion | Better when |
|---|---|---|
cost_sar_kg | landed price of green coffee, SAR per kg | lower |
cupping_score | quality on the specialty-coffee cupping scale (0–100; 80 or more is “specialty”) | higher |
on_time_pct | reliability: share of the last 24 months’ shipments that arrived on the agreed date | higher |
sustainability_score | the team’s audit score (0–100): traceability, farmer pay, certification | higher |
supply_risk | the team’s risk rating, 1 (low) to 10 (high): one origin, the shipping route, the importer’s finances | lower |
The importers and their scores are invented for this course. A table with one row per option and one column per criterion is a decision matrix. We also record, for each criterion, whether more or less is better.
crit = ["cost_sar_kg", "cupping_score", "on_time_pct", "sustainability_score", "supply_risk"]
better = pd.Series(["low", "high", "high", "high", "low"], index=crit)
X = suppliers.set_index("supplier")[crit].astype(float) # the decision matrix
XCost alone¶
If cost were the only criterion, the decision would take one line. Here is the cheapest importer, and what each of the others would cost a year more for 50 tonnes:
TONNES = 50
cheapest = X["cost_sar_kg"].idxmin()
extra = (X["cost_sar_kg"] - X["cost_sar_kg"].min()) * TONNES * 1000 # SAR a year
print("cheapest:", cheapest)
extra.astype(int).sort_values()cheapest: Santos Bulk
supplier
Santos Bulk 0
Red Sea Traders 250000
Harar Direct 400000
Sidamo Link 450000
Jazan Highlands 600000
Name: cost_sar_kg, dtype: int64Santos Bulk is the cheapest at 26 SAR/kg. Red Sea Traders would cost 250,000 SAR a year more, Jazan Highlands 600,000 more. But Santos Bulk also has the lowest cupping score (79, just below specialty grade) and the lowest sustainability score. Are better coffee and more reliable deliveries worth 250,000 SAR a year? No formula answers that by itself: it is a judgment. Multi-criteria methods do not remove the judgment; they make it explicit, so that it can be discussed, tested and shown.
2. Screen first: dominated options¶
Option A dominates option B when A is at least as good as B on every criterion and strictly better on at least one. A dominated option can never be the best choice, whatever the weights, so we drop it before weighing anything.
To compare criteria in one direction, we flip the sign of the lower is better ones, so that higher is better everywhere:
good = X.copy()
good.loc[:, better == "low"] *= -1 # now higher is better on every criterion
def dominates(a, b):
"""True if option a is at least as good as b everywhere and better somewhere."""
return (good.loc[a] >= good.loc[b]).all() and (good.loc[a] > good.loc[b]).any()
pairs = [(a, b) for a in X.index for b in X.index if a != b and dominates(a, b)]
pairs[('Harar Direct', 'Sidamo Link')]Harar Direct dominates Sidamo Link: it is cheaper (34 against 35 SAR/kg), better coffee, more punctual, more sustainable and less risky. Sidamo Link buys Ethiopian coffee through a broker; Harar Direct buys it straight from the cooperatives. We drop it.
The four that remain are each the best at something, so there is a real trade-off:
X4 = X.drop(index="Sidamo Link")
best_at = {c: (X4[c].idxmin() if better[c] == "low" else X4[c].idxmax()) for c in crit}
pd.Series(best_at, name="best on this criterion")cost_sar_kg Santos Bulk
cupping_score Harar Direct
on_time_pct Red Sea Traders
sustainability_score Jazan Highlands
supply_risk Jazan Highlands
Name: best on this criterion, dtype: str3. Where the weights come from: AHP¶
A weighted method needs one number per criterion: how much it counts. Asking a board directly “what weight for sustainability?” gives numbers that are hard to defend. The Analytic Hierarchy Process (AHP), proposed by Thomas Saaty, asks easier questions, two criteria at a time: “how much more important is cost than sustainability?”, answered on a 1 to 9 scale.
| Value | Meaning |
|---|---|
| 1 | equally important |
| 3 | moderately more important |
| 5 | strongly more important |
| 7 | very strongly more important |
| 9 | extremely more important |
| 2, 4, 6, 8 | in between |
If cost is 4 times as important as sustainability, then sustainability is 1/4 as important as cost: the matrix is reciprocal, and only the ten judgments above the diagonal are needed. Here are the board’s judgments (each row compared with each column):
| cost | quality | reliability | sustainability | risk | |
|---|---|---|---|---|---|
| cost | 1 | 1 | 2 | 4 | 2 |
| quality | 1 | 1 | 2 | 3 | 2 |
| reliability | 1/2 | 1/2 | 1 | 2 | 2 |
| sustainability | 1/4 | 1/3 | 1/2 | 1 | 1/2 |
| risk | 1/2 | 1/2 | 1/2 | 2 | 1 |
The weights are the principal eigenvector of this matrix (the eigenvector of its largest eigenvalue), scaled to add up to 1. A good approximation, easy to compute by hand, is the geometric mean of each row, scaled to add up to 1.
board = np.array([
[1, 1, 2, 4, 2 ],
[1, 1, 2, 3, 2 ],
[1/2, 1/2, 1, 2, 2 ],
[1/4, 1/3, 1/2, 1, 1/2],
[1/2, 1/2, 1/2, 2, 1 ],
])
eigvals, eigvecs = np.linalg.eig(board)
k = np.argmax(eigvals.real) # the largest eigenvalue
w = np.abs(eigvecs[:, k].real)
weights = pd.Series(w / w.sum(), index=crit)
geo = board.prod(axis=1) ** (1 / 5) # the row geometric means
pd.DataFrame({"eigenvector": weights, "geometric mean": geo / geo.sum()}).round(3)The board’s weights: cost 30.8%, quality 29.2%, reliability 18.1%, sustainability 8.2% and risk 13.6%. The geometric means give almost the same numbers.
Are the judgments consistent?¶
If cost is twice as important as reliability, and reliability twice as important as sustainability, then cost should be about four times as important as sustainability. Real judgments are never exactly consistent, and AHP measures by how much they miss. For a perfectly consistent matrix the largest eigenvalue equals the number of criteria ; the further above , the less consistent the judgments:
, the random index, is the average of matrices filled in at random: 1.12 for five criteria. Saaty’s rule of thumb is to accept the judgments when the consistency ratio is below 0.10, and to revisit them otherwise.
n = len(board)
lam = eigvals.real[k]
CI = (lam - n) / (n - 1)
CR = CI / 1.12 # random index for n = 5
print(f"lambda max = {lam:.3f}, CI = {CI:.4f}, CR = {CR:.3f}")lambda max = 5.069, CI = 0.0171, CR = 0.015
= 0.015, well below 0.10: the board’s judgments hang together. When is above 0.10, look for a circle such as A beats B, B beats C, but C beats A, show it to the people who made the judgments, and let them revise. Lab 15 has an example.
4. Comparable scales and the weighted sum¶
The criteria are in SAR per kg, points, percent and ratings: they cannot be added as they are. Min–max normalisation puts each one on a 0-to-1 scale among the options being compared, where 1 is the best option and 0 the worst:
def minmax(X):
"""Each criterion on a 0-1 scale among the options: 1 for the best, 0 for the worst."""
lo, hi = X.min(), X.max()
R = (X - lo) / (hi - lo)
low = better[better == "low"].index
R[low] = (hi[low] - X[low]) / (hi[low] - lo[low])
return R
R = minmax(X4)
R.round(3)The weighted sum of each row is its score: .
def weighted_sum(X, weights):
return (minmax(X) * weights).sum(axis=1)
wsm = weighted_sum(X4, weights).sort_values(ascending=False)
wsm.round(3)supplier
Red Sea Traders 0.655
Jazan Highlands 0.619
Harar Direct 0.453
Santos Bulk 0.363
dtype: float64# what each criterion adds to each importer's score
contrib = (minmax(X4) * weights).loc[wsm.index[::-1]]
names = ["cost", "quality", "reliability", "sustainability", "risk"]
colours = ["#1f6f8b", "#e07b39", "#6aa84f", "#8e7cc3", "#c9a227"]
fig, ax = plt.subplots(figsize=(7, 3.2))
left = np.zeros(len(contrib))
for c, name, col in zip(crit, names, colours):
ax.barh(contrib.index, contrib[c], left=left, color=col, label=name)
left += contrib[c].values
for y, total in enumerate(left):
ax.text(total + 0.01, y, f"{total:.3f}", va="center", fontsize=9)
ax.set_xlim(0, 0.8)
ax.set_xlabel("weighted-sum score (board's weights)")
ax.legend(ncol=5, fontsize=8, loc="upper center", bbox_to_anchor=(0.45, -0.25), frameon=False)
plt.tight_layout()
plt.show()
Red Sea Traders wins with 0.655, ahead of Jazan Highlands (0.619), Harar Direct (0.453) and Santos Bulk (0.363). The two leaders win in different ways: Red Sea Traders on cost, reliability and risk; Jazan Highlands on quality, sustainability and risk, despite the highest price.
Two properties of the weighted sum to keep in mind:
It is compensatory: a very good score on one criterion can make up for a very bad one on another. If some level is unacceptable (say, a cupping score under 80), make it a must-have and screen the options before scoring, as we did for dominance.
Min–max scores depend on which options are compared: adding or removing an option can move the minimum or the maximum of a criterion and change every score.
5. A second method: TOPSIS¶
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) asks a different question: how close is each option to an ideal importer that would be the best of the four on every criterion, and how far from an anti-ideal that would be the worst on every one?
Normalise each column by its length: .
Weigh: .
The ideal takes the best of each column, the anti-ideal the worst.
Compute each option’s distance to both: to the ideal, to the anti-ideal.
The closeness is between 0 and 1; the higher, the better.
def topsis(X, weights):
V = X / np.sqrt((X ** 2).sum()) * weights
ideal = pd.Series({c: V[c].max() if better[c] == "high" else V[c].min() for c in crit})
anti = pd.Series({c: V[c].min() if better[c] == "high" else V[c].max() for c in crit})
d_ideal = np.sqrt(((V - ideal) ** 2).sum(axis=1))
d_anti = np.sqrt(((V - anti) ** 2).sum(axis=1))
return pd.DataFrame({"d_ideal": d_ideal, "d_anti": d_anti, "closeness": d_anti / (d_ideal + d_anti)})
top = topsis(X4, weights).sort_values("closeness", ascending=False)
top.round(3)TOPSIS agrees on the top two: Red Sea Traders (0.639) is closest to the ideal, then Jazan Highlands (0.554). It disagrees on third place: Santos Bulk (0.507) comes before Harar Direct (0.293), which is far from the ideal on reliability and risk. Two reasonable methods that measure “best” differently, and they agree on the winner: that is some evidence that the answer is not an artefact of one method. It does not yet tell us whether the answer depends on the weights.
6. Sensitivity: how much must a weight change?¶
The weights came from judgments, and judgments differ from one board member to another. So we ask: how far can one weight move before the winner changes? We raise or lower one weight and scale the other four in proportion, so that the five still add up to 1.
def with_weight(weights, criterion, value):
"""The weights with one criterion set to value, the others scaled to keep the total at 1."""
w = weights * (1 - value) / (1 - weights[criterion])
w[criterion] = value
return w
def winner(method, w):
s = weighted_sum(X4, w) if method == "weighted sum" else topsis(X4, w)["closeness"]
return s.idxmax()
def flip(method, criterion, step=0.001):
"""The nearest weight, below and above the board's, at which the winner changes (None if it never does)."""
base = winner(method, weights)
grid = np.round(np.arange(0, 1 + step / 2, step), 3)
up = next((v for v in grid if v > weights[criterion] and winner(method, with_weight(weights, criterion, v)) != base), None)
down = next((v for v in grid[::-1] if v < weights[criterion] and winner(method, with_weight(weights, criterion, v)) != base), None)
return down, up
rows = []
for c, name in zip(crit, names):
for method in ["weighted sum", "TOPSIS"]:
down, up = flip(method, c)
rows.append({"criterion": name, "method": method, "board's weight": round(weights[c], 3),
"flips below": down, "new winner (below)": None if down is None else winner(method, with_weight(weights, c, down)),
"flips above": up, "new winner (above)": None if up is None else winner(method, with_weight(weights, c, up))})
pd.DataFrame(rows)Read the table row by row. Some flips need large changes: quality would have to weigh 36% or more before the weighted sum picks Jazan Highlands. Two are small:
Sustainability: from the board’s 8.2% to 13.2% (weighted sum) or 14.1% (TOPSIS), Jazan Highlands wins under both methods. That is about six points of weight.
Cost: from 30.8% down to 26.2%, the weighted sum picks Jazan Highlands.
The chart shows the scores of the four importers as the sustainability weight goes from 0 to 40%:
grid = np.linspace(0, 0.4, 81)
fig, axes = plt.subplots(1, 2, figsize=(9.5, 3.4), sharex=True)
for ax, method in zip(axes, ["weighted sum", "TOPSIS"]):
scores = pd.DataFrame([weighted_sum(X4, with_weight(weights, "sustainability_score", v)) if method == "weighted sum"
else topsis(X4, with_weight(weights, "sustainability_score", v))["closeness"] for v in grid], index=grid)
for s, col in zip(["Red Sea Traders", "Jazan Highlands", "Harar Direct", "Santos Bulk"], ["#1f6f8b", "#e07b39", "#8e7cc3", "#999999"]):
ax.plot(grid, scores[s], color=col, lw=2.2 if s in ("Red Sea Traders", "Jazan Highlands") else 1.4, label=s)
ax.axvline(weights["sustainability_score"], color="black", ls=":", lw=1)
f = flip(method, "sustainability_score")[1]
ax.axvline(f, color="#e07b39", ls="--", lw=1)
lo, hi = ax.get_ylim()
ax.text(weights["sustainability_score"] - 0.005, lo + 0.04 * (hi - lo), "board", fontsize=8, ha="right")
ax.text(f + 0.005, lo + 0.04 * (hi - lo), f"flip: {f:.1%}", fontsize=8, color="#e07b39")
ax.set_title(method, fontsize=10)
ax.set_xlabel("weight of sustainability")
ax.set_xticks(np.arange(0, 0.41, 0.1))
ax.xaxis.set_major_formatter(plt.matplotlib.ticker.PercentFormatter(1.0, decimals=0))
axes[0].set_ylabel("score")
axes[1].legend(fontsize=8, loc="lower right")
plt.tight_layout()
plt.show()
And with equal weights, 20% each, a choice that only looks neutral:
equal = pd.Series(0.2, index=crit)
pd.DataFrame({"weighted sum": weighted_sum(X4, equal), "TOPSIS": topsis(X4, equal)["closeness"]}).round(3)With equal weights Jazan Highlands wins clearly under both methods (0.733 and 0.756). So the recommendation is Red Sea Traders, as long as the board keeps cost at about 26% or more and sustainability at about 13% or less. Outside that band, Jazan Highlands wins.
This is the most important result of the week: with several criteria, the weights are the decision. A good analysis does not hide them inside a score. It shows them, says where they came from (here, the board’s pairwise judgments with = 0.015), and reports how far they can move before the answer changes. The board can then see exactly what it is choosing: Red Sea Traders saves 350,000 SAR a year against Jazan Highlands, in exchange for a lower sustainability score and slightly lower quality. If the board wants Jazan Highlands, the analysis also says what it would take, for example a lower price (Lab 15 asks how much lower).
Part 2. Responsible analytics¶
A recommendation is only as good as the honesty around it. The rest of this reading is a short guide to the questions you should be able to answer about any model you build, starting with your capstone.
7. Assumptions and limits¶
Every model leaves things out. Write down what yours assumes, how you checked it, and what would change the answer. For the importer decision:
| Assumption | How we checked it | What would change the answer |
|---|---|---|
| The scores describe the next two years | on-time rates come from 24 months of shipments; sustainability and risk are the purchasing team’s judgments | a new audit, a price change, a shipping disruption |
| The weights are the board’s | AHP with = 0.015 | sustainability above about 13%, or cost below about 26% |
| Five criteria cover what matters | discussed with the board | a criterion we left out: payment terms, minimum order, a second supplier as backup |
| One importer for all 50 tonnes | the contract asks for it | splitting the volume between two importers, which could reduce risk |
The last row is a reminder that a model answers the question it was given. Sometimes the best recommendation is to change the question.
8. Personal data¶
Week 7’s churn model used the records of 6,000 loyalty-app members: their visits, baskets, complaints. Data about identifiable people deserves care, and in Saudi Arabia it is governed by the Personal Data Protection Law (PDPL), supervised by SDAIA. Without going into the law itself, a few principles apply to any analysis:
Collect and keep only what the decision needs (data minimisation). The churn model needs recent activity, not names or phone numbers;
member_idis a code, not an identity.Use data for the purpose it was collected for, and say so when you report.
Report in aggregate: averages by branch or by month, not lists of individuals, and avoid groups so small that a person can be recognised.
Never paste personal data into a public AI tool or a shared notebook.
For your capstone, use public, synthetic or anonymised data, and say which.
9. Fairness: check the decisions group by group¶
A model can be accurate on average and still treat groups differently. The check is simple: compute its decisions and its errors for each group. Here is Week 7’s voucher model again (same data, same split, same model), with its profit-maximising rule: send a retention voucher when the churn probability is above 1/6.
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
members = load("qahwa_members_2025.csv")
Xm = pd.get_dummies(members.drop(columns=["member_id", "churned"]), columns=["branch"], drop_first=True, dtype=int)
y = members["churned"]
X_train, X_test, y_train, y_test = train_test_split(Xm, y, test_size=0.3, random_state=631, stratify=y)
def voucher_report(features):
"""Fit the Week 7 model on the given features; send a voucher when p > 1/6; report by branch."""
model = LogisticRegression(max_iter=1000).fit(X_train[features], y_train)
send = model.predict_proba(X_test[features])[:, 1] > 1 / 6
t = pd.DataFrame({"branch": members.loc[X_test.index, "branch"], "churned": y_test, "send": send})
by = t.groupby("branch").apply(lambda d: pd.Series({
"members": len(d), "churn rate": d["churned"].mean(), "voucher rate": d["send"].mean(),
"leavers reached (recall)": d.loc[d["churned"] == 1, "send"].mean()}), include_groups=False)
by["members"] = by["members"].astype(int)
profit = 50 * (t["send"] & (t["churned"] == 1)).sum() - 10 * (t["send"] & (t["churned"] == 0)).sum()
return by, profit
with_branch, profit_with = voucher_report(list(Xm.columns))
print(f"profit on the test set: {profit_with:,} SAR")
with_branch.round(3)profit on the test set: 10,050 SAR
The rule earns 10,050 SAR on the test set, as in Week 7. By branch, it reaches 90.6% of the University members who leave but only 68.0% of those at Corniche and 69.3% at Olaya. Branch is not a protected characteristic, but here it stands in for one: most University members are students, so a gap between branches is partly a gap between age groups.
Is the gap a problem? That is a question for management, not for the model. Part of it is earned (University members do leave more often). But the analyst’s job is to measure it and show it, and to check the obvious alternatives. One is to leave the branch out of the model:
no_branch = [c for c in Xm.columns if not c.startswith("branch_")]
without_branch, profit_without = voucher_report(no_branch)
print(f"profit on the test set: {profit_without:,} SAR")
without_branch.round(3)profit on the test set: 10,320 SAR
Without the branch column the gap in recall narrows from 22.6 points (68.0% to 90.6%) to 14.3 points (73.7% to 88.0%), and on this test set the profit is even slightly higher (10,320 SAR). Here fairness costs nothing; often it costs something, and then the trade-off itself is a decision to show the managers, like the weights of Section 6. Two cautions:
Dropping a column does not make a model fair: other columns can carry the same information (a proxy). Always check the outcomes, not only the inputs.
One test set is one sample. Before changing a rule, check the difference with cross-validation, as in Week 7.
10. Documenting a recommendation¶
A recommendation memo for a manager fits on two pages. A structure that works:
The decision and who makes it. One sentence.
The recommendation. One sentence, with the key number.
The evidence. The model, the data and the main results, with numbers.
What would change it. The sensitivity analysis: the flip points, the scenarios.
Assumptions and limits. What the model leaves out (Section 7).
Data and people. Where the data comes from, personal data, groups treated differently (Sections 8 and 9).
Use of AI. What you used it for, and how you checked it.
For the importer decision, items 2 and 4 could read: “Sign with Red Sea Traders: with the board’s weights it ranks first under both the weighted sum (0.655) and TOPSIS (0.639), and it costs 350,000 SAR a year less than Jazan Highlands. If the board weighs sustainability at 14% or more instead of 8%, Jazan Highlands becomes the better choice.”
11. Generative AI, honestly¶
The course policy is in the syllabus: you may use AI assistants to write code, not to make the decision. In practice:
Log it. What you asked, what you kept, what you changed: the AI-use log at the end of each lab and of your capstone memo.
Check every number. An assistant can write code that runs and computes the wrong thing. Re-derive key results by another route, as the
check()cells do.Own the reasoning. The formulation, the weights, the interpretation and the recommendation are yours, and you defend them alone in the oral session, where AI is not allowed.
Protect data. Never paste personal or confidential data into a public assistant.
12. A checklist for your capstone¶
Before your defence, make sure you can answer each of these in a sentence or two, with a number where one fits:
| # | Question |
|---|---|
| 1 | Which decision does your app support, and which manager makes it? |
| 2 | What are the alternatives, and what does the manager care about (the objective or the criteria)? |
| 3 | Where does the data come from, how did you clean it, and does it contain personal data? |
| 4 | What does the predictive part predict, and how large is its error on data it has not seen? |
| 5 | What does the decision model (optimization, simulation, decision tree or multi-criteria) recommend? |
| 6 | Which inputs or weights would change the recommendation, and by how much? |
| 7 | What does the model leave out, and what could go wrong if it is wrong? |
| 8 | Does the recommendation affect groups of people differently? |
| 9 | What did you use AI for, and how did you check it? |
| 10 | In one sentence, with a number: what should the manager do? |
Lab 15 ends with this checklist for your own team.
Summary¶
With several criteria, screen first: drop dominated options and any that fail a must-have.
Normalise the criteria to one scale, then rank with a weighted sum (compensatory, simple) or TOPSIS (closeness to an ideal option). When two methods agree, the answer does not depend on the method.
AHP turns pairwise judgments into weights, and its consistency ratio (below 0.10) tells whether the judgments hang together.
The weights are the decision. Report how far each weight can move before the winner changes: here, sustainability from 8% to about 14%, or cost from 31% to about 26%.
Responsible analytics: state assumptions and limits, protect personal data, check decisions group by group, document the recommendation, and log and check any use of AI.
This is the last reading of the course. The path you followed (describe the data, predict, optimize, decide under uncertainty and with several criteria) is the one your capstone follows, and the one most real decisions follow too.