-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
975 lines (951 loc) · 86.3 KB
/
Copy pathcontent.js
File metadata and controls
975 lines (951 loc) · 86.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
// =============================================================
// content.js — Course content for Ethical Data Science
// University of Barcelona · MSc Fundamental Principles of DS
// =============================================================
//
// HOW TO EDIT
// -----------
// • This file contains ALL course content: lectures, sections,
// text blocks, and quiz cards.
// • Edit text freely — HTML tags (<strong>, <em>, <code>, <br>)
// are allowed inside string values.
// • For LaTeX maths, wrap inline formulas in $...$ and display
// formulas in $$...$$. Use String.raw (aliased as `tex` below)
// to write LaTeX without escaping backslashes:
// e.g. tex`P(\hat{Y}=1 | X \in G^+)`
// This avoids writing \\hat, \\in, etc.
// • Block types: paragraph · callout · case-study · list ·
// grid · formula · table · blockquote
// • Do NOT edit ethical-data-science.css (styles) or
// ethical-data-science.js (renderer) unless you want to
// change layout or colours.
// =============================================================
// Helper: write LaTeX without escaping backslashes
const tex = String.raw;
const COURSE_DATA = {
// ── Course metadata ─────────────────────────────────────────
course: {
title: "Ethical Data Science",
subtitle: "MSc in Fundamental Principles of Data Science · University of Barcelona",
year: "2025–26",
authors: ["Jordi Vitrià"],
intro: "Click <strong>Reveal answer</strong> on each card to check understanding, then mark it <em>Remembered</em> or <em>Forgot</em>. Progress is tracked in the sidebar.",
references: [
{ title: "fairmlbook.org", url: "https://fairmlbook.org" },
{ title: "Interpretable ML Book", url: "https://christophm.github.io/interpretable-ml-book/" },
{ title: "Google PAIR: Hidden Bias",url: "https://pair.withgoogle.com/explorables/hidden-bias/" }
]
},
// ── Lectures ─────────────────────────────────────────────────
lectures: [
// ══════════════════════════════════════════════════════════
// LECTURE 0 — Data Science in Context
// ══════════════════════════════════════════════════════════
{
id: "lec0",
number: "0",
title: "Data Science in Context",
subtitle: "Why ethics matters from the very first line of code.",
sections: [
{
heading: "What is Data Science?",
blocks: [
{ type: "paragraph", html: `Data science is the <strong>systematic study and application of scientific, computational, and analytical methods</strong> used to process data and extract information, knowledge, and insights that support decision-making or enable automated actions. It intersects with <em>data-centric AI</em> — the discipline of systematically engineering the data used to develop AI tools.` },
{ type: "paragraph", html: `Insights and conclusions arise from <strong>models</strong> — abstractions of the real world. Models may be <strong>transparent</strong> (humans can understand how inputs produce outputs) or <strong>opaque/black-box</strong> (internal workings are not understandable, even if inputs and outputs are visible).` },
{ type: "callout", variant: "default", label: "Core tension",
html: `Data science and AI can be both <strong>beneficial</strong> (improved decision-making, personalized services, efficiency, automation) and <strong>detrimental</strong> (privacy concerns, bias and fairness issues, security risks, job loss, data manipulation) — to individuals and to society as a whole.` }
]
},
{
heading: "Why data is never neutral",
blocks: [
{ type: "paragraph", html: `A common misconception: <em>"Data is a matter of describing things as they are. We want to be objective and let things speak for themselves."</em>` },
{ type: "paragraph", html: `This is naïve. Data, in its raw form, consists of numbers, text, or other symbols. Without context and analysis, these representations lack meaning. It's the role of data scientists to interpret data — analysing patterns, trends, and anomalies — to derive insights and conclusions. And every such interpretation involves choices.` },
{ type: "paragraph", html: `Two additional problems: (1) for <strong>small groups</strong>, even an abundance of data can result in high error rates; (2) ML can inadvertently reinforce stereotypes due to biases in training data.` },
{ type: "blockquote", text: `"Technology is neither good nor bad; nor is it neutral."`, cite: "— Melvin Kranzberg, Technology and Culture (1986)" },
{ type: "paragraph", html: `Kranzberg's point: technology's interaction with its social ecology produces consequences far beyond the immediate purpose of the system. The same algorithm can produce very different results in different contexts.` }
]
},
{
heading: "Privacy leaks — a concrete example",
blocks: [
{ type: "case-study", label: "Example · Privacy Leak", title: `When a model "remembers" people`,
paragraphs: [
`An ML model is supposed to learn rules: "People with these symptoms often have this disease." A privacy leak happens when it instead <em>memorises</em> specific people from training data.`,
`A language model trained on scraped data containing "John Smith, born 12/04/1981, lives at 27 Green Street, has diabetes" outputs that fact when asked — a clear privacy breach through verbatim memorisation.`
]
}
]
},
{
heading: "Real consequences: two major case studies",
blocks: [
{ type: "case-study", label: "Case Study · Netherlands, 2012–2022", title: "The SyRI Child Benefit Scandal",
paragraphs: [
`In 2012, the Dutch Tax Agency began using ML to create fraud risk profiles for child care benefit claims. The algorithm categorised families as debtors if they filled out documents incorrectly. Dual nationality, low socioeconomic status, immigrant background, and ethnic minority status were characteristics that led the algorithm to disproportionately penalise these groups.`,
`<strong>Outcome:</strong> Over <strong>30,000 families</strong> affected. More than 10,000 fell into poverty; some died by suicide after receiving impossible debt bills; over 1,100 children separated from their families. The acting government resigned in 2022.`
]
},
{ type: "case-study", label: "Case Study · United Kingdom, 2020", title: "A-Level Grades Algorithm",
paragraphs: [
`During COVID-19, the UK replaced A-level exams with an algorithm using each school's historical grade distribution and teacher rankings within schools. A student's rank within their cohort was mapped to the school's historical distribution — designed to correct schools that previously overestimated grades.`,
`<strong>Outcome:</strong> Nearly <strong>40% of students</strong> received lower grades than expected; only 2% received higher grades. State-school students were disproportionately downgraded. After public protests, the government reversed course within days.`
]
}
]
},
{
heading: "Ethics in Data Science is not abstract",
blocks: [
{ type: "paragraph", html: `Ethical dilemmas rarely appear as big moral crises. They appear as <strong>small, technical, seemingly harmless decisions</strong> in practice:` },
{ type: "list", ordered: false, items: [
"Choosing a decision threshold",
"Selecting which variables to include",
"Using historical data",
"Automating a decision",
`Accepting "default" settings`
]
},
{ type: "case-study", label: "Decision Point", title: `"The model works… but not for everyone"`,
paragraphs: [
`You build a credit-scoring model that significantly improves default prediction. During validation, applicants from one minority group are rejected much more often, even when controlling for income and education. The business team is satisfied and asks you to deploy as-is.`,
`<strong>Tensions:</strong> accuracy vs. fairness · apparent neutrality vs. active correction · accept performance loss or do nothing?`
]
}
]
},
{
heading: "Ethical benefits of data practices",
blocks: [
{ type: "grid", columns: 3, items: [
{ title: "Human understanding", body: "Revealing unseen patterns — e.g., the smoking–lung cancer link discovered via large-dataset analysis in the 1950s." },
{ title: "Efficiency", body: "Better-designed interventions — e.g., AI-powered smart grids predicting demand and reducing energy waste." },
{ title: "Personalisation", body: "Context-sensitive care — e.g., personalized treatment plans from patient genetics, history, and real-time health data." }
]
}
]
},
{
heading: "Ethical harms of data practices",
blocks: [
{ type: "grid", columns: 3, items: [
{ title: "Privacy & security", variant: "accent", body: `Most people don't realise how exposed their lives are through common data practices — the "lakes and rivers of personal data" pooling across the digital landscape.` },
{ title: "Fairness & justice", variant: "accent", body: "We have a strong interest in being treated fairly across law enforcement, employment, education, healthcare, and financial services." },
{ title: "Transparency & autonomy", variant: "accent", body: "Transparency: the ability to see how a system works and inquire about the basis of decisions. Autonomy: the ability to make informed, free decisions." }
]
}
]
},
{
heading: "AI Governance: responding to these harms",
blocks: [
{ type: "paragraph", html: `AI governance refers to the frameworks, policies, and mechanisms that guide the responsible development, deployment, and oversight of AI systems — encompassing ethical, legal, and technical considerations to ensure alignment with human values.` },
{ type: "paragraph", html: `<strong>The EU has taken a regulation-first approach.</strong> The GDPR (General Data Protection Regulation, enforced since May 2018) regulates how personal data is collected, processed, stored, and shared. Key provisions:` },
{ type: "list", ordered: true, items: [
`<strong>Personal Data</strong> — Name, address, location, health info, income, cultural profile.`,
`<strong>Communication</strong> — Who gets the data, why, for how long? No use for incompatible purposes.`,
`<strong>Consent</strong> — Clear informed consent required.`,
`<strong>Access</strong> — Individuals have the right to access their own data.`,
`<strong>Right to be forgotten</strong> (not for research purposes).`,
`<strong>Right to explanation</strong> — For automated decisions affecting you, plus the right to have a human decide.`,
`<strong>Marketing</strong> — Right to opt out.`,
`<strong>Legal</strong> — EU legislation must be maintained when transferring data abroad.`,
`<strong>Data Protection Officer</strong> — Required in organisations performing high-risk processing.`,
`<strong>Impact assessment</strong> — Required prior to high-risk processing involving new technology, surveillance, or sensitive data.`
]
},
{ type: "paragraph", html: `The <strong>EU AI Act</strong> adds six principles for AI providers:` },
{ type: "grid", columns: 2, items: [
{ title: "1 · Human agency & oversight", body: "AI should assist humans; humans must be able to override decisions." },
{ title: "2 · Technical robustness & safety", body: "Systems must be predictable, well-functioning, and comply with quality management." },
{ title: "3 · Privacy & data governance", body: "Systems must be designed with data privacy in mind; datasets must be properly governed." },
{ title: "4 · Transparency", body: "Providers must disclose system capabilities, limitations, and data sources." },
{ title: "5 · Non-discrimination & fairness", body: "Systems must avoid discrimination and bias; promote diversity." },
{ title: "6 · Social & environmental well-being", body: "Systems should contribute to sustainable and inclusive growth." }
]
}
]
},
{
heading: "Responsible model development",
blocks: [
{ type: "paragraph", html: `Responsible model development refers to building models in a manner that <strong>prioritises ethical, fair, and accountable considerations throughout the entire lifecycle</strong> of the model — from design and training to deployment and maintenance. The goal is to minimise harm, maximise benefits, and adhere to societal norms and values.` }
]
}
],
quiz: [
{ id: "q0-1",
question: "What is Kranzberg's First Law, and why does it matter for data scientists?",
answer: `<strong>Technology is neither good nor bad, nor neutral.</strong> Its interaction with its social ecology produces consequences far beyond the device's immediate purpose, and the same technology behaves differently in different contexts. For data scientists: deploying a model is never an ethically neutral act — it enters a social context with pre-existing inequalities and power structures.`
},
{ id: "q0-2",
question: "In the Dutch SyRI scandal, what characteristics caused the algorithm to disproportionately penalise families?",
answer: `Having <strong>dual nationality</strong>, low socioeconomic status, <strong>immigrant background</strong>, or belonging to an <strong>ethnic minority</strong>. These demographic attributes were used as proxies for fraud risk, though they are ethically impermissible — they do not reflect any relevant behaviour of the individual but encode structural inequalities.`
},
{ id: "q0-3",
question: "Name the three ethical harms of data practices and briefly explain each.",
answer: `<strong>(1) Privacy & security</strong> — Personal data pooled across digital systems exposes lives in ways people don't realise. <strong>(2) Fairness & justice</strong> — Systems treat people unequally across law, employment, healthcare, and finance. <strong>(3) Transparency & autonomy</strong> — Opaque systems prevent people from understanding and contesting decisions that affect them.`
},
{ id: "q0-4",
question: "What went wrong with the UK A-level algorithm in 2020, and what was the main structural problem?",
answer: `The algorithm assigned grades based on each student's rank within their school, mapped to the school's historical grade distribution. The structural problem: students in schools with historically lower grades were penalised not for their own performance, but for their school's history. This produced <strong>40% of students receiving lower grades than expected</strong> and disproportionately harmed state-school students.`
}
]
},
// ══════════════════════════════════════════════════════════
// LECTURE 1 — Ethical Foundations
// ══════════════════════════════════════════════════════════
{
id: "lec1",
number: "1",
title: "Ethical Foundations",
subtitle: "What makes an action right or wrong? Frameworks for reasoning under epistemic automation.",
sections: [
{
heading: "Is there a common ethical ground?",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "Ethical relativism", body: "Morality is relative to one's culture; whether an action is right depends on the norms of the society where it's practiced." },
{ title: "Ethical absolutism", body: "Universal moral principles apply to all people, at all times, in all cultures — without exception." },
{ title: "Ethical universalism", body: "Some moral principles are universally valid, but allow for contextual variation in application. A flexible middle path." },
{ title: "Ethical pluralism", body: "Multiple ethical perspectives can coexist; societies find common ground through discussion, compromise, and shared values." }
]
},
{ type: "paragraph", html: `This course assumes a common ground based on a <strong>revision of the Enlightenment</strong> — a framework encompassing rationality, science, humanism, and progress. This is a working assumption, not an absolute claim.` },
{ type: "paragraph", html: `Common grounds include: the evaluation of actions by their impact on <strong>human flourishing</strong> and harm reduction; <strong>reciprocity</strong> ("Treat others as you wish to be treated"), found in nearly every major religion and ethical system; and research showing that <strong>empathy, fairness, and reciprocity</strong> are innate human tendencies supported by neuroscience and primatology.` }
]
},
{
heading: "Pinker's three propositions (the common ground)",
blocks: [
{ type: "list", ordered: true, items: [
`<strong>The basis:</strong> In the very act of asking "why should I live?", you are committed to reason as the means to discover and justify what is important to you. A reason is an explanation that provides a logical basis for a conclusion.`,
`<strong>You as an individual:</strong> As a sentient being, you have the potential to flourish. You can refine your faculty of reason, seek explanations through science, and make the most of your capacity for pleasure and satisfaction.`,
`<strong>You as a member of society:</strong> Because reason tells you none of this is particular to you, you have the responsibility to provide to others what you expect for yourself — enhancing life, health, knowledge, freedom, safety, and peace.`
]
},
{ type: "callout", variant: "accent", label: "Important caveat",
html: `Not everyone agrees with Enlightenment assumptions. Some religions embrace ethical codes based on God's character. Certain technocratic worldviews can function similarly — with <em>data and technical expertise</em> as the source of normativity rather than God. This course proceeds with the Enlightenment framework while acknowledging its limitations.`
}
]
},
{
heading: "How do we make decisions?",
blocks: [
{ type: "paragraph", html: `Our decisions are shaped by:` },
{ type: "list", ordered: false, items: [
`<strong>Purpose</strong> — Our reason for being; what we want to leave behind.`,
`<strong>Principles</strong> — Lines we will never cross.`,
`<strong>Values</strong> — The things we hold good (justice, knowledge, equality, liberty).`,
`<strong>Knowledge</strong> — Our beliefs about how the world works.`,
`<strong>Law</strong> — Formal, enforceable standards of behaviour (can be just or unjust).`,
`<strong>Moral system</strong> — The informal social framework of values, beliefs, customs inherited (often unconsciously) from family, community, or culture.`
]
},
{ type: "paragraph", html: `Law and morality alone are insufficient. Ethics is a process of <strong>conscious, rational reflection</strong> that asks: <em>What should I do?</em> The role of ethics is not to be a soft version of the law, even if laws are based on ethical principles. <strong>The real application of ethics lies in challenging the status quo, seeking its deficits and blind spots.</strong>` }
]
},
{
heading: "The three traditional normative theories",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "Utilitarianism (Bentham, Mill)",
body: `An action is right if it maximises happiness and well-being for all affected parties. Judges by <em>consequences</em>. Utilitarian calculus opens the possibility that some might justly be sacrificed for the greater good.` },
{ title: "Deontology (Kant)",
body: `An action is right if it follows a moral rule — regardless of consequences. "Treat others as ends, never merely as means." Asimov's Three Laws of Robotics are a canonical example of deontological AI ethics.` },
{ title: "Virtue Ethics (Aristotle, Buddhism)", variant: "full",
body: `Instead of "What should I do?", ask "What kind of person should I become?" Cultivate fairness, honesty, prudence, and care; practical wisdom (<em>phronesis</em>) guides each situation. A virtuous robot would express enduring traits across different situations using context-sensitive judgment — rather than optimising each action in isolation.` }
]
},
{ type: "case-study", label: "Comparison — All three theories applied",
title: "Someone in need should be helped. Why?",
paragraphs: [
`<strong>Utilitarian:</strong> Because the consequences of doing so maximise general well-being.`,
`<strong>Deontologist:</strong> Because it acts in accordance with the moral rule "Do unto others as you would be done by."`,
`<strong>Virtue ethicist:</strong> Because helping the person would be charitable or benevolent.`
]
}
]
},
{
heading: "Political philosophy: ethics at societal scale",
blocks: [
{ type: "paragraph", html: `Traditional normative ethics is framed from an individual perspective. When AI operates at scale, <strong>political philosophy</strong> — which extends ethical reasoning to institutions and power structures — becomes crucial. The central idea is <em>justice</em>.` },
{ type: "grid", columns: 2, items: [
{ title: "Rawlsians (John Rawls)",
body: "Justice is fairness. Inequalities are only justified if they benefit the <em>least advantaged</em> members of society. Central to: algorithmic bias debates, fairness metrics, distribution of risks and benefits, institutional justice." },
{ title: "Libertarians (John Locke)",
body: "Individual rights to life, liberty, and property are paramount. The only limit: respecting others' similar rights. Central to: data protection, consent and privacy, ownership of personal data, AI surveillance regulation." },
{ title: "Utilitarians (J.S. Mill)",
body: `Secure "the greatest good for the greatest number." Often used implicitly to justify AI: "It improves efficiency and saves more lives." Central to: cost-benefit analysis, optimisation systems, public policy AI decisions.` },
{ title: "Communitarians (Michael Sandel)",
body: `Everyone derives their identity from the broader community. Justice must be rooted in society (common good), not determined behind a "veil of ignorance." Raises: democratic legitimacy of AI, moral limits of automation, risk of technocracy.` }
]
}
]
},
{
heading: "Non-Western perspectives",
blocks: [
{ type: "paragraph", html: `Most AI ethics guidelines are written in Western countries, dominating the field with Western values like individual autonomy. <strong>Buddhist ethics</strong> offers a different frame: an action is good if it leads to freedom from suffering. Key concepts include compassion — the desire and commitment to eliminate suffering in others.` },
{ type: "paragraph", html: `This points to the need for <strong>value diversity and ethical pragmatism</strong> — a flexible, context-based approach that prioritises practical consequences and problem-solving over rigid moral rules or abstract principles.` }
]
},
{
heading: "Ethics Under Epistemic Automation",
blocks: [
{ type: "paragraph", html: `This course focuses on the case where algorithms (1) turn data into evidence for a given outcome, and (2) trigger and motivate an action with ethical consequences. Both steps may be fully automated, complicating the attribution of moral responsibility.` },
{ type: "paragraph", html: `Five types of ethical concern arise:` },
{ type: "table",
headers: ["#", "Type", "Description"],
rows: [
["1", "<strong>Inconclusive evidence</strong>", "The data does not strongly support a single conclusion."],
["2", "<strong>Inscrutable evidence</strong>", "The system's reasoning cannot be meaningfully examined (opacity)."],
["3", "<strong>Misguided evidence</strong>", "The evidence is distorted, biased, or based on flawed assumptions."],
["4", "<strong>Unfair outcomes</strong>", `Even if the system works "as designed," results may distribute harms unjustly.`],
["5", "<strong>Transformative effects</strong>", "Over time, systems reshape institutions and power structures in ways that may not promote the common good."]
]
},
{ type: "paragraph", html: `Types 1–3 are <strong>epistemic factors</strong> (about the quality of knowledge). Types 4–5 are <strong>normative concerns</strong> (about moral impact). <em>Even technically accurate systems can produce unfair or harmful consequences.</em>` }
]
},
{
heading: "Applied ethics: three time frames",
blocks: [
{ type: "grid", columns: 3, items: [
{ title: "Short-term / person", body: "What is the impact of [privacy, transparency, fairness] in my specific application? → GDPR issues." },
{ title: "Mid-term / society", body: "How will [military use, medical care, justice, education] applications change our social organisation? → Autonomous weapons, predictive policing." },
{ title: "Long-term / humans", body: "What are the ethical goals of these technologies? → Singularity, convergence, existential risk." }
]
}
]
}
],
quiz: [
{ id: "q1-1",
question: "What is the key difference between deontological and utilitarian ethics? Give an example of how a robot would be designed differently under each approach.",
answer: `<strong>Deontology</strong> judges actions by whether they follow a moral rule, regardless of consequences. <strong>Utilitarianism</strong> judges by outcomes — whether they maximise overall well-being.<br><br>A <em>deontological robot</em> (Asimov's Laws): "A robot may not injure a human being" — this is a rule that holds regardless of consequences.<br>A <em>utilitarian robot</em>: evaluates actions by predicted outcomes through a defined utility function (e.g., minimise harm), selects the highest expected value.`
},
{ id: "q1-2",
question: "From a Rawlsian perspective, when are social and economic inequalities justified?",
answer: `Only when they are arranged to <strong>benefit the least advantaged members of society</strong>. Rawls distinguishes natural inequalities (talent, strength) from social and economic inequalities — the latter are only just if they improve the position of those at the bottom. Applied to AI: algorithmic systems must be evaluated by whether their benefits are distributed in a way that improves the position of the most disadvantaged.`
},
{ id: "q1-3",
question: "What are the five types of ethical concern that arise from \"epistemic automation\"? Classify them into epistemic and normative.",
answer: `<strong>Epistemic (about the quality of knowledge):</strong> (1) Inconclusive evidence; (2) Inscrutable evidence (opacity); (3) Misguided evidence (bias, flawed assumptions). <strong>Normative (about moral impact):</strong> (4) Unfair outcomes; (5) Transformative effects (long-term reshaping of institutions and power structures). Both matter and interact: weak evidence → weak justification → questionable moral legitimacy of actions.`
},
{ id: "q1-4",
question: "Why is the Communitarian (Sandel) critique particularly powerful when AI systems make decisions at scale?",
answer: `Communitarians argue that justice cannot be determined "behind a veil of ignorance" — it must be rooted in the community and common good. When AI scales up decision-making, it can: erode civic responsibility by replacing human judgment, reduce moral agency ("the algorithm decides"), weaken democratic legitimacy ("we didn't vote on these values encoded in AI"), and risk technocracy — governance by technical experts rather than democratic deliberation.`
}
]
},
// ══════════════════════════════════════════════════════════
// LECTURE 2 — Legitimacy, Values & Decision-Making
// ══════════════════════════════════════════════════════════
{
id: "lec2",
number: "2",
title: "Legitimacy, Values & Decisions",
subtitle: `Before asking "Is the AI fair?", ask "Should AI be making this decision at all?"`,
sections: [
{
heading: null, // intro block before first h3
blocks: [
{ type: "callout", variant: "default", label: "The mother of all ethical AI questions",
html: `<strong>Does it make sense to use AI here?</strong><br>For it to make sense, the use of AI/DS must first be <em>legitimate</em> — that is, normatively justified, socially acceptable, and appropriate given the stakes of the decision. <strong>If the delegation itself is not legitimate, technical performance becomes irrelevant.</strong>`
}
]
},
{
heading: "What is legitimacy?",
blocks: [
{ type: "paragraph", html: `In political-institutional theory, legitimacy means that an organisation's actions <strong>align with the values, norms, and expectations</strong> of the society it operates in. The legitimacy of a system depends on:` },
{ type: "list", ordered: true, items: [
`How well the system <strong>achieves its stated goals</strong>.`,
`Whether those affected <strong>participate in developing the rules</strong>.`,
`Whether the decision subject can <strong>challenge decisions</strong> (due process).`
]
},
{ type: "paragraph", html: `Legitimacy is the central problem of politics — and now a central problem of AI governance. <strong>The legitimacy question must precede</strong> analysis of other ethical issues like discrimination or privacy.` }
]
},
{
heading: "Three scenarios with legitimacy failures",
blocks: [
{ type: "case-study", label: "Scenario A", title: "Essay graded by a computer",
paragraphs: [
`A student is proud of the creative essay she wrote. She receives a perfect score, but is disappointed to learn it was graded by a computer. <strong>Issue:</strong> People tend to trust human evaluators for subjective assessments. Relying entirely on AI reduces confidence in the grading system — even when the outcome is good.`
]
},
{ type: "case-study", label: "Scenario B", title: "Criminal risk prediction system",
paragraphs: [
`A defendant finds he was categorised as "high risk for failure to appear in court" based on the behaviour of <em>others like him</em>, despite having every intention of appearing. <strong>Issue:</strong> People expect justice systems to recognise them as unique individuals, not reduce them to statistical data points that prioritise error minimisation over personal circumstances.`
]
},
{ type: "case-study", label: "Scenario C", title: "Automated platform ban with no appeal",
paragraphs: [
`A social media user is locked out for "violating policy" with no explanation and no appeal process. <strong>Issue:</strong> People expect due process — the ability to understand and challenge decisions that affect them. Without a clear dispute mechanism, the system appears unjust.`
]
}
]
},
{
heading: "Values, principles and technology",
blocks: [
{ type: "paragraph", html: `Organisations define their AI values by aligning with their mission, engaging stakeholders (employees, customers, affected communities), adopting ethical principles (transparency, fairness, accountability, privacy, non-harm), and complying with regulatory standards.` },
{ type: "paragraph", html: `A widely cited framework uses <strong>five core principles</strong>:` },
{ type: "grid", columns: 2, items: [
{ title: "Justice", body: "Impartiality · Equality · Proportionality" },
{ title: "Autonomy", body: "Explainability · Privacy · Literacy" },
{ title: "Non-maleficence", body: "Reliability · Controllability · Accountability" },
{ title: "Transparency", body: "Comprehensibility · Interactivity · Traceability" },
{ title: "Beneficence", variant: "full", body: "Security · Sustainability · Responsibility" }
]
}
]
},
{
heading: "Three kinds of automated decision-making systems",
blocks: [
{ type: "grid", columns: 1, items: [
{ title: "Type 1 · Converting human-designed rules into software",
body: `Rules set down by hand are encoded in software. Example: the kidney dialysis committee (1962) made allocation decisions using human judgment; the 2022 US kidney transplant system converts these rules into a transparent, annually-audited algorithm. <em>Allows procedural regularity</em> but risks: vague policies forcing subjective programming choices, software errors, reduced accountability, inflexibility for unexpected cases.` },
{ title: "Type 2 · ML to emulate human decision-making",
body: `Human decision-makers have primarily relied on informal judgment rather than formally specified rules. ML formalises and fixes a decision-making scheme similar to what humans used in the past. This can smooth inconsistencies in human decisions — but models could also learn to base themselves on criteria humans would find troubling, even if overall decisions are similar.` },
{ title: "Type 3 · Predictive optimisation",
body: `Learning decision-making rules from labelled data using a proxy loss function. Example: selecting students who will "benefit most from studying at your university" using proxy variables (academic performance, engagement, socioeconomic impact). <em>But it has flaws:</em> good predictions may not lead to good decisions (causality); proxy loss functions don't capture what we really care about; training data rarely matches deployment distribution; social outcomes are not precisely predictable.` }
]
}
]
},
{
heading: "Arbitrariness: two types",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "Procedural arbitrariness", body: "Decision-making is executed inconsistently — the same person would receive different decisions at different times. Automation addresses this through procedural regularity." },
{ title: "Rational arbitrariness", body: "Decisions are made without reasoning, even if consistently. Rational justification requires that decisions are grounded in reasons — not just consistently applied random choices." }
]
},
{ type: "paragraph", html: `Bureaucracies arose to counteract the subjectivity and inconsistency in human decision-making. AI systems can extend this logic — but also introduce new forms of arbitrariness if their criteria are opaque or ethically unjustified.` }
]
},
{
heading: "Legitimacy criteria for automated decisions",
blocks: [
{ type: "paragraph", html: `An automated decision system can be considered legitimate if:` },
{ type: "grid", columns: 2, items: [
{ title: "Results must be:", body: `<strong>Accurate</strong> — correct in most cases, defined in a way compatible with the values of those affected.<br><strong>Reliable</strong> — stable and consistent across different scenarios.<br><strong>Effective</strong> — actually impacts the real world in the expected way.` },
{ title: "Process must be:", body: `<strong>Well executed</strong> — correctly implemented, validated, and tested.<br><strong>Well justified</strong> — there are sound reasons for using this approach rather than alternatives, including human-designed rule systems.` }
]
},
{ type: "paragraph", html: `<strong>Irreducibility condition:</strong> A legitimate automated decision system must show that there is no comparable solution based on human-designed algorithms — otherwise the system should be based on converting human-designed decision rules into software.` }
]
}
],
quiz: [
{ id: "q2-1",
question: "Why must the legitimacy question precede other ethical questions like bias or privacy?",
answer: `Because if the <strong>delegation itself is not legitimate</strong> — not normatively justified, not socially acceptable, not appropriate given the stakes — then fixing the bias or privacy issues doesn't resolve the underlying problem. Technical performance cannot redeem an illegitimate use of AI. Example: before asking whether a predictive policing system is biased, we must ask whether it is legitimate in principle to delegate crime prediction to an automated system at all.`
},
{ id: "q2-2",
question: "What are the three criteria for the legitimacy of a political or AI system, and which of the three legitimacy scenarios violates each?",
answer: `(1) <strong>Achieves its goals</strong> — the essay scenario (even achieving the goal of accurate grading doesn't satisfy legitimacy if the process is not accepted); (2) <strong>Subjects involved in developing rules</strong> — all three scenarios involve rules imposed without participation of those affected; (3) <strong>Ability to challenge decisions</strong> — most clearly violated in Scenario C (no appeal process), but also in B (risk score with no recourse).`
},
{ id: "q2-3",
question: "What are the main flaws of predictive optimisation (Type 3 automation) that affect its legitimacy?",
answer: `(1) <strong>Good predictions ≠ good decisions</strong> — a model predicting which patients miss appointments may identify low-income patients as high-risk, but the causal reason (transportation barriers) means the right response is support, not penalisation; (2) <strong>Proxy loss functions</strong> — we can't measure what we really care about; (3) <strong>Distribution drift</strong> — training data rarely matches deployment conditions; (4) <strong>Unpredictability</strong> — social outcomes are not precisely predictable with or without ML.`
}
]
},
// ══════════════════════════════════════════════════════════
// LECTURE 4 — Bias & Fairness I
// ══════════════════════════════════════════════════════════
{
id: "lec4",
number: "4",
title: "Bias & Fairness I",
subtitle: "From statistical bias to ethical bias — and why accuracy alone isn't enough.",
sections: [
{
heading: "Two meanings of 'bias'",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "Statistical bias", body: "The available data is <em>not representative</em> of the population or phenomenon being studied. Except for carefully randomised samples, most organically produced datasets are biased." },
{ title: "Ethical bias", variant: "accent", body: "Data or algorithms that contain content discriminating against specific groups of people — even if statistically accurate." }
]
},
{ type: "callout", variant: "accent", label: "Critical insight",
html: `<strong>Not all statistically biased behaviours are ethically problematic.</strong><br><strong>Not all statistically unbiased behaviours are ethically acceptable.</strong><br>An AI hiring system trained on historical data can be statistically unbiased — and still reproduce structural inequality.`
},
{ type: "paragraph", html: `<strong>Algorithmic bias</strong> describes a systematic deviation in output, performance, or impact relative to some norm or standard. An algorithm can be:` },
{ type: "list", ordered: false, items: [
`<strong>Statistically biased</strong> — predictions differ systematically from previously observed data.`,
`<strong>Ethically biased</strong> — predictions depend on a protected characteristic like gender, race, or nationality.`
]
}
]
},
{
heading: "Sources of bias across the ML lifecycle",
blocks: [
{ type: "paragraph", html: `Bias can enter at every stage of the pipeline:` },
{ type: "table",
headers: ["Stage", "Bias type", "Description"],
rows: [
["World → Data generation", "<strong>Structural bias</strong>", "Social/institutional patterns that confer advantage on some and disadvantage to others based on identity (sexism, racism, socioeconomic status)."],
["Data generation → Sample", "<strong>Representation bias</strong>", "The data we collect does not represent the whole population."],
["Sample → Dataset", "<strong>Measurement bias</strong>", "The features we use do not represent the phenomenon we are studying. <em>The features we use determine what real patterns can be detected.</em>"],
["Dataset", "<strong>Aggregation bias</strong>", "Groups are inappropriately combined, resulting in a model that doesn't perform well for any group (→ Simpson's Paradox)."],
["Training & test", "<strong>Inductive / evaluation bias</strong>", "The tendency to prefer certain generalisations; metrics against the whole test set don't always reflect group-specific performance."],
["Deployment", "<strong>Deployment bias</strong>", "The system is used or interpreted in unintended ways."],
["Feedback loop", "<strong>Feedback bias</strong>", "The model's outputs influence future training data — reinforcing original bias indefinitely."]
]
},
{ type: "case-study", label: "Example · Structural bias in practice", title: "Street Bump (Boston)",
paragraphs: [
`Boston crowdsourced pothole data using smartphone sensors. Infrastructure seems far from ethical quandaries — but the data reflects smartphone ownership, which is higher in wealthier areas. Low-income areas and areas with large elderly populations are underrepresented, biasing the city's maintenance priorities.`
]
},
{ type: "paragraph", html: `Some patterns in training data ("smoking is associated with cancer") represent knowledge we wish to mine. Others ("girls like pink and boys like blue") represent stereotypes we might wish to avoid. <strong>Learning algorithms have no general way to distinguish between these two types</strong> — because that distinction is a social and moral judgment, not a mathematical one.` }
]
},
{
heading: "Discrimination: not all differential treatment is wrong",
blocks: [
{ type: "paragraph", html: `To treat some persons in a worse way is not necessarily bad — it can be good. Progressive taxes are designed to reduce income inequality by imposing higher rates on those with higher incomes. The ethical question is whether the differential treatment is <em>justified</em> by relevant reasons.` }
]
},
{
heading: "Formalising fairness",
blocks: [
{ type: "paragraph", html: `Two major approaches:` },
{ type: "grid", columns: 2, items: [
{ title: "Individual fairness", body: `<em>Similar entities should be treated similarly.</em> Requires a distance metric between entities and a distance metric between outputs. X discriminates against Y (vs. Z) in relation to characteristic P if: Y has P, Z does not; X treats Y worse than Z because of P.` },
{ title: "Group fairness", body: `<em>All groups should be treated similarly.</em> Requires defining protected groups (protected attributes). The challenge: how to partition entities into groups.` }
]
},
{ type: "paragraph", html: `Let <strong>G+</strong> = protected group (e.g. women), <strong>G−</strong> = non-protected group (e.g. men), <strong>Y</strong> = true outcome, <strong>Ŷ</strong> = predicted outcome, <strong>S</strong> = predicted probability score. Binary classifier: 1 = favourable (loan approved, admitted to school).` }
]
},
{
heading: "Statistical group fairness definitions",
blocks: [
{ type: "callout", variant: "default", label: "Demographic parity (base rate fairness)",
html: `The probability of a favourable outcome must be equal for both groups:<br>
$$P(\\hat{Y}=1 \\mid X\\in G^+) \\approx P(\\hat{Y}=1 \\mid X\\in G^-)$$
Equivalently, $\\hat{Y}$ is statistically independent of the protected characteristic. <strong>Limitation:</strong> ignores whether group members actually qualify — requires the same proportion of women in the positive class even when fewer are well-qualified.`
},
{ type: "paragraph", html: `The <strong>80% Rule</strong>: companies should hire protected groups at a rate of at least 80% of that of the reference group. Used by the US Equal Employment Opportunity Commission to detect unwitting discrimination.` },
{ type: "callout", variant: "default", label: "Equal opportunity (accuracy-based)",
html: `The True Positive Rate (TPR) must be equal across groups:
$$P(\\hat{Y}=1 \\mid Y=1, X\\in G^+) = P(\\hat{Y}=1 \\mid Y=1, X\\in G^-)$$
Both groups have the same chance of a favourable outcome, but only when they qualify ($Y=1$).`
},
{ type: "callout", variant: "default", label: "Equalized odds",
html: `Both the True Positive Rate <em>and</em> the False Positive Rate must be equal across groups:
$$P(\\hat{Y}=1 \\mid Y=1, G^+) = P(\\hat{Y}=1 \\mid Y=1, G^-)$$
$$P(\\hat{Y}=1 \\mid Y=0, G^+) = P(\\hat{Y}=1 \\mid Y=0, G^-)$$
All groups experience the same TPR and same FPR.`
},
{ type: "callout", variant: "default", label: "Calibration",
html: `For any score $p$, the probability of being truly positive must be equal across groups:
$$P(Y=1 \\mid S=p, X\\in G^+) = P(Y=1 \\mid S=p, X\\in G^-)$$
Scores "mean the same thing" regardless of group membership.`
}
]
},
{
heading: "The impossibility result",
blocks: [
{ type: "callout", variant: "accent", label: "Fundamental impossibility",
html: `If (1) the outcome $Y$ is binary, (2) the protected attribute is not independent of $Y$, and (3) $\\hat{Y}$ is not independent of $Y$ — then <strong>independence (demographic parity) and separation (equal opportunity / equalized odds) cannot both hold simultaneously.</strong><br><br>It is impossible to satisfy all definitions of group fairness at once. Data scientists must choose which definition is appropriate for the specific use case — based on what harms they most want to prevent.`
}
]
},
{
heading: "Case study: COMPAS and the ProPublica debate",
blocks: [
{ type: "case-study", label: "Case Study · USA · Criminal Justice", title: "COMPAS Recidivism Risk Tool",
paragraphs: [
`COMPAS (Correctional Offender Management Profiling for Alternative Sanctions) outputs numerical scores for "risk of recidivism," "risk of violent recidivism," and "risk of failure to appear." These scores inform bail, jail, and sentencing decisions.`,
`<strong>ProPublica (May 2016) — "Machine Bias":</strong> COMPAS does not satisfy equal false positive rates — Black defendants who did NOT reoffend were <em>nearly twice as likely</em> to be classified as high risk as white defendants. COMPAS does not satisfy equal false negative rates — white defendants who DID reoffend were nearly twice as likely to be misclassified as low risk.`,
`<strong>Northpointe/Equivant response:</strong> COMPAS satisfies calibration — among defendants with a score of 7, 60% of white and 61% of Black defendants were rearrested. Scores mean the same thing regardless of race.`,
`<strong>The root of the conflict:</strong> Base rates of recidivism differ between racial groups in the data. <em>When base rates differ, calibration and equal error rates cannot both be satisfied simultaneously.</em> This is not a technical failure — it is the mathematical impossibility result applied to a real system.`
]
}
]
},
{
heading: "Counterfactual fairness",
blocks: [
{ type: "paragraph", html: `An output is fair toward an entity if it is the same in both the actual world and a counterfactual world where the entity belonged to a different group. Given that Alice did not get promoted, and given that she is a woman, what is the probability she would have been promoted if she were a man instead? <strong>Causal inference</strong> is used to formalise this notion.` }
]
}
],
quiz: [
{ id: "q4-1",
question: "What is the critical insight about statistical bias vs. ethical bias? Give an example of each failure direction.",
answer: `<strong>Insight:</strong> Not all statistically biased behaviours are ethically problematic, and not all statistically unbiased behaviours are ethically acceptable.<br><br><strong>Statistically biased but ethically OK:</strong> A model predicting umbrella sales from weather data may be statistically biased (overestimates rain) but causes no ethical harm.<br><strong>Statistically unbiased but ethically problematic:</strong> A hiring model trained on historical data where 90% of successful hires were men accurately predicts "who will be hired" — but perpetuates structural discrimination.`
},
{ id: "q4-2",
question: "Explain the mathematical impossibility result regarding fairness metrics. What does it imply for practitioners?",
answer: `When (1) the outcome is binary, (2) the protected attribute correlates with the outcome (different base rates across groups), and (3) the classifier is non-trivial — <strong>demographic parity and equalized odds (separation) cannot both be satisfied simultaneously.</strong><br><br>For practitioners: you cannot have a "fair by all measures" classifier when base rates differ. You must choose which fairness metric to prioritise based on the specific harms you most want to avoid — this is an ethical decision, not a technical one.`
},
{ id: "q4-3",
question: "In the COMPAS case, what did ProPublica find and how did Northpointe respond? Who was right?",
answer: `<strong>ProPublica:</strong> Black defendants were twice as likely to be falsely flagged as high risk (equal false positive rate violated); white defendants who reoffended were twice as likely to be classified as low risk (equal false negative rate violated).<br><strong>Northpointe:</strong> COMPAS satisfies calibration — scores mean the same thing regardless of race.<br><strong>Both were right</strong> about their respective metrics. The conflict is not about facts but about which fairness metric to use. Calibration and equal error rates cannot both hold when base rates differ — a mathematical necessity. The deeper question is: which definition of fairness is ethically appropriate for criminal justice?`
},
{ id: "q4-4",
question: "Name four distinct sources of bias in the ML lifecycle and explain how each arises.",
answer: `<strong>Structural bias</strong>: social patterns (racism, sexism) in the world enter the data. <strong>Representation bias</strong>: the sample doesn't represent the population (e.g., smartphone poverty gap in Boston pothole data). <strong>Measurement bias</strong>: the features used don't capture the real phenomenon (e.g., arrest rate as a proxy for crime rate encodes policing bias). <strong>Feedback bias</strong>: model outputs influence future training data — e.g., predictive policing concentrating in minority areas generates more arrests there, reinforcing the model indefinitely.`
}
]
},
// ══════════════════════════════════════════════════════════
// LECTURE 5 — Bias, Discrimination & Causality
// ══════════════════════════════════════════════════════════
{
id: "lec5",
number: "5",
title: "Causality & Fairness",
subtitle: "Why observational statistics alone cannot determine whether a system is discriminatory.",
sections: [
{
heading: "The Berkeley admissions paradox",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "Within departments",
body: "4 of the 6 largest departments showed a <em>higher</em> acceptance rate for women. Demographic parity largely held within departments. → Women are not discriminated against." },
{ title: "Aggregate data", variant: "accent",
body: "Overall: men 44% (1157/2651), women 30% (556/1835) — a significant difference. → Women are discriminated against." }
]
},
{ type: "callout", variant: "default", label: "Simpson's Paradox",
html: `A trend that holds for all subgroups can <strong>reverse</strong> when those subgroups are combined. Such reversals caused by aggregation operations are called Simpson's Paradox. It is not a true paradox — it is a consequence of the data-generating process. The correct analysis depends on understanding the causal structure of the situation.`
}
]
},
{
heading: "Why did the paradox arise at Berkeley?",
blocks: [
{ type: "list", ordered: true, items: [
`<strong>Gender influences department choice</strong> — women and men had different preferences for different fields of study.`,
`<strong>Departments have different admission rates</strong> — some departments were more competitive (lower acceptance rates).`,
`<strong>Pattern:</strong> Women disproportionately applied to more competitive departments (higher-acceptance-rate departments were chosen more by men).`
]
},
{ type: "paragraph", html: `Therefore, one explanation: women chose more competitive departments, hence got rejected at higher overall rates — not due to discrimination within any department. <strong>The within-department analysis is correct here because department choice is a variable chosen by applicants, not by the institution.</strong>` }
]
},
{
heading: "Kidney stone study: another case",
blocks: [
{ type: "case-study", label: "Classic Medical Example", title: "Treatment A vs. Treatment B",
paragraphs: [
`Treatment A had a higher success rate for <em>both small and large kidney stones</em>. Yet when patients were combined, Treatment B appeared superior overall.`,
`<strong>Resolution:</strong> Doctors assigned more severe cases (large stones) to Treatment A. Stone size is a <em>confounder</em>. The correct analysis uses disaggregated data — but this depends on understanding the causal structure, not just the statistics.`
]
}
]
},
{
heading: "From association to causality",
blocks: [
{ type: "paragraph", html: `Two fundamentally different types of questions:` },
{ type: "grid", columns: 2, items: [
{ title: "Association (observational)",
body: `What is the expected outcome $Y$ that would have been observed if an individual had $X=x$ and $Z=z$?<br>$E[Y \\mid X, Z]$<br>All we need: a large dataset and inference tools.` },
{ title: "Causal intervention", variant: "accent",
body: `What is the expected outcome if we <em>set</em> $X=x$ for all individuals?<br>$E[Y \\mid do(X=x)]$<br>Cannot be derived from passive observation alone. Requires data + analytic techniques + exogenous domain knowledge.` }
]
},
{ type: "callout", variant: "accent", label: "Key distinction",
html: `The answer to $E[Y \\mid do(x=1)] - E[Y \\mid do(x\\neq 1)]$ is <strong>NOT</strong> the same as $E[Y \\mid x=1] - E[Y \\mid x\\neq 1]$. The observed difference between groups may be confounded by education, socioeconomic background, and other variables. The causal effect requires controlling for confounders.`
}
]
},
{
heading: "Directed Acyclic Graphs (DAGs)",
blocks: [
{ type: "paragraph", html: `We represent the data-generating process with a <strong>Directed Acyclic Graph (DAG)</strong>. Each node is a variable; directed edges represent causal relationships. The key requirement: causal relationships must be acyclic.` },
{ type: "paragraph", html: `Three generating scripts that are indistinguishable from observational data $p(X,Y)$ alone:` },
{ type: "list", ordered: false, items: [
`<strong>X causes Y</strong> — intervening on X changes Y.`,
`<strong>Y causes X</strong> — intervening on X does not change Y.`,
`<strong>X and Y share a common cause Z (confounder)</strong> — they are associated but not causally related.`
]
},
{ type: "paragraph", html: `To simulate an intervention, you <strong>mutilate the graph</strong> by removing all edges pointing into the variable on which you intervene. Interventional distributions are NOT equivalent to observational distributions — you generally cannot infer one from the other without the causal structure.` }
]
},
{
heading: "Confounders",
blocks: [
{ type: "case-study", label: "Classic example", title: "Coffee and heart disease",
paragraphs: [
`Coffee drinkers may smoke more cigarettes. Smoking is a <em>confounding variable</em> in the study of the association between coffee drinking and heart disease. The observed association between coffee and heart disease may be due to: (i) smoking alone; (ii) coffee alone; (iii) both. Without measuring the confounder, we cannot distinguish these cases from observational data.`
]
}
]
},
{
heading: "The do-calculus",
blocks: [
{ type: "paragraph", html: `Do-calculus is an axiomatic system for replacing probability formulas containing the $do$ operator with ordinary conditional probabilities. Given a causal query for a certain DAG, we say it is <strong>identifiable</strong> if we can derive a statistical estimand (using only observational terms) using the rules of do-calculus.` },
{ type: "formula",
lines: [
tex`Example: Y \leftarrow X \rightarrow Z, where X is given.`,
tex`Pr(z \mid do(x)) = \sum_y Pr(y) \cdot Pr(z \mid x, y)`,
`This estimand can be estimated from observational data using statistical / ML methods.`
]
}
]
},
{
heading: "Causal fairness",
blocks: [
{ type: "paragraph", html: `Causal fairness asks: does the protected attribute itself do causal work in the prediction? This is a much deeper question than statistical parity.` },
{ type: "paragraph", html: `For a hiring classifier, check whether gender $A$ causally influences the hiring decision $\\hat{Y}$:` },
{ type: "formula",
lines: [ tex`ATE = E[\hat{Y} \mid do(A=\text{man})] - E[\hat{Y} \mid do(A=\text{woman})]` ]
},
{ type: "paragraph", html: `If $ATE \\neq 0$, the classifier is causally influenced by the protected attribute → possible causal discrimination.` },
{ type: "grid", columns: 2, items: [
{ title: "Statistical parity asks:",
body: "Are positive rates equal across groups?<br>But ignores: qualification differences, structural inequalities, Simpson's paradox, confounding." },
{ title: "Causal fairness asks:", variant: "accent",
body: "Is the protected attribute itself doing causal work?<br>Controls for confounders, distinguishes direct vs. mediated effects, handles Simpson's paradox correctly." }
]
}
]
},
{
heading: "Graphical discrimination analysis",
blocks: [
{ type: "paragraph", html: `Three real applications of causal graphs:` },
{ type: "grid", columns: 3, items: [
{ title: "COMPAS",
body: "The causal graph reveals hidden (unobserved) confounders between race and recidivism — historical policing patterns that affect both the input features and the true outcome." },
{ title: "UCI Adult Census",
body: "Gender $X$ → Education $W_1$ → Income $Y$. Gender may affect income directly or through education. The DAG determines which paths constitute discrimination." },
{ title: "Berkeley admissions",
body: tex`Sex A → Department Z → Admission Y. Computing Pr(Y|do(A=a)) = \sum_z Pr(Z=z)\cdot Pr(Y|A=a,Z=z) shows no discrimination.` }
]
}
]
}
],
quiz: [
{ id: "q5-1",
question: "What is Simpson's Paradox, and why does its resolution require causal knowledge rather than just more data?",
answer: `Simpson's Paradox is the phenomenon where a trend holding for all subgroups <strong>reverses when subgroups are combined</strong>. More data from the same source won't resolve it — because the paradox arises from the <em>causal structure</em> of the situation, not from sample size. The correct level of analysis (aggregated or disaggregated) depends on whether the variable you're controlling for is a resolving variable (the person's own choice → control for it) or a non-resolving variable (an institutional factor reflecting discrimination → don't control for it).`
},
{ id: "q5-2",
question: "What is the fundamental difference between E[Y | X=x] and E[Y | do(X=x)]?",
answer: `$E[Y \\mid X=x]$ is an <strong>observational quantity</strong>: the expected value of Y among those we <em>observe</em> to have X=x. This may be confounded by variables that cause both X and Y.<br><br>$E[Y \\mid do(X=x)]$ is an <strong>interventional quantity</strong>: the expected value of Y if we <em>set</em> X=x for all individuals — breaking the natural relationship between X and its causes. This captures the true causal effect. Example: observing that Black applicants have lower incomes tells us about correlation; intervening on race in a counterfactual world measures discrimination.`
},
{ id: "q5-3",
question: "Why is the ATE (Average Treatment Effect) of gender on hiring a better measure of discrimination than a simple comparison of hiring rates?",
answer: `The simple comparison of hiring rates may reflect differences in qualifications, application patterns, or job types — confounders that don't constitute discrimination. The ATE $E[\\hat{Y} \\mid do(A=\\text{man})] - E[\\hat{Y} \\mid do(A=\\text{woman})]$ estimates what hiring decisions would be if we <em>intervened</em> on gender alone, keeping everything else in the causal graph equal. If ATE ≠ 0, the protected attribute is <strong>causally</strong> driving the outcome — genuine causal discrimination.`
}
]
},
// ══════════════════════════════════════════════════════════
// LECTURE 6 — Transparency, Interpretability & Explainability
// ══════════════════════════════════════════════════════════
{
id: "lec6",
number: "6",
title: "Transparency & Explainability",
subtitle: "What does it mean to explain an AI decision — and why does the audience matter?",
sections: [
{
heading: "What is an explanation?",
blocks: [
{ type: "paragraph", html: `An explanation is a statement that clarifies the <strong>reasons or causes</strong> behind something. When someone asks "Why did the AI make this decision?", they are not just requesting facts — they are seeking information that fills a gap between what they observed and what they expected.` },
{ type: "paragraph", html: `This implies the <em>explainee</em> already has: (1) a mental model of how the world works, and (2) certain expectations about causes, consequences, and intentions. To make an explanation understandable and meaningful, the explainer must tailor it to align with or reshape the explainee's model.` },
{ type: "case-study", label: "Self-driving car example", title: `"Why did the car slow down here?"`,
paragraphs: [
`A good explanation must consider: (1) what the user expected ("no obstacle → no slowdown"); (2) the user's background knowledge (traffic rules, sensor limitations, physics); (3) the user's causal model (agents follow rules, objects obey physics).`,
`Good explanation: <em>"The car detected radar reflections from a wet road surface ahead, which triggers a speed reduction to maintain safe stopping distance."</em> This bridges expectation with the system's actual causal model.`
]
},
{ type: "blockquote",
text: `"When you ask why something happens, you have to be in some framework that allows something to be without explanation — otherwise you go on and on, deeper and deeper."`,
cite: "— Richard Feynman"
}
]
},
{
heading: "Three related but distinct concepts",
blocks: [
{ type: "grid", columns: 3, items: [
{ title: "Transparency",
body: "The ability to make the operational elements of an AI system visible — algorithms, input data, parameters. A <em>property of the system itself</em>, addressable with concrete tools: code documentation, training strategies, traceability rules." },
{ title: "Interpretability",
body: "The degree to which a human can understand how a model's internal structure and representations relate to its inputs and outputs — such that the model's behaviour can be reasoned about, anticipated, scrutinised, or intervened upon." },
{ title: "Explainability",
body: `Providing clear, coherent explanations for specific model predictions or decisions. Answers "Why did the AI make <em>this particular</em> prediction?" with human-understandable justifications. A <em>communicative act</em> directed at a specific audience.` }
]
}
]
},
{
heading: "Properties of a good explanation (Miller, 2017)",
blocks: [
{ type: "list", ordered: true, items: [
`<strong>Contrastive.</strong> Humans don't ask "Why this prediction?" They ask "Why this prediction <em>rather than that one</em>?" A good explanation answers a contrastive question: "You were denied a loan rather than approved because…"`,
`<strong>Selected.</strong> People don't want the complete causal chain. We select one or two salient causes from a larger set — "THE explanation."`,
`<strong>Focused on the abnormal.</strong> People focus more on causes that had a small probability but nevertheless happened.`,
`<strong>Aligned with prior beliefs</strong> of the person receiving the explanation.`,
`<strong>General and probable.</strong> A cause that can explain many events is more useful than a highly specific one.`
]
}
]
},
{
heading: "The ethical dimension of explainability",
blocks: [
{ type: "paragraph", html: `It is unfair that people can receive a low credit score, end up on a police watchlist, or get longer prison sentences <em>without explanation</em> about the considerations that led to those decisions. Getting algorithms to provide explanations allows us to keep <strong>"meaningful human control"</strong> over the decision.` },
{ type: "paragraph", html: `The GDPR includes an indirect "right to explanation" for fully automated decisions that significantly affect someone — at least the right to obtain human intervention, to express a point of view, and to contest the decision. A <strong>principle of explicability</strong> is an ethical principle that should help bring us closer to acceptable uses of algorithms.` },
{ type: "paragraph", html: `We do <em>NOT</em> need interpretability when: (a) the model has no significant impact; (b) the problem is well-studied and validated (e.g. OCR); (c) interpretability would enable gaming of a critical system.` }
]
},
{
heading: "Four types of opacity in ML",
blocks: [
{ type: "grid", columns: 2, items: [
{ title: "(a) Opacity by entanglement", variant: "accent", body: "When a model fails, we don't know where the error lies: code, data, model design, or hardware." },
{ title: "(b) Opacity by complexity", variant: "accent", body: "Even if we could inspect all connections in a neural network, the human mind cannot grasp how they all interact simultaneously." },
{ title: "(c) Opacity by behavioural unpredictability", variant: "accent", body: `If we don't understand how a model "thinks," we cannot anticipate its outputs or make reliable mental estimates.` },
{ title: "(d) Opacity by lack of explanation", variant: "accent", body: `In ML, we often have the <em>what</em> (the output) but not the <em>why</em> — nor an explanation of how the result would change with slightly different input.` }
]
},
{ type: "paragraph", html: `Opacity is caused by an <strong>epistemic wall</strong>: the way models process information does not resemble how the human mind forms concepts, making it impossible to extract a simple explanation or general "law" of behaviour. The problem is not just hiddenness — it may be <em>structural limits to intelligibility</em>. A high-dimensional non-linear function cannot be "opened up" and understood by a human mind.` }
]
},
{
heading: "Lessons from computer simulation",
blocks: [
{ type: "paragraph", html: `The philosopher Paul Humphreys argued that computer simulation is opaque — it produces knowledge that cannot be fully reconstructed by human reasoning. Simulations are opaque because they involve too many interacting calculations, uncertain error sources, and emergent behaviour.` },
{ type: "paragraph", html: `But in computer simulation, humans did not eliminate opacity. They learned to <strong>manage it</strong> through:` },
{ type: "grid", columns: 2, items: [
{ title: "Verification & Validation (V&V)",
body: `<strong>Verification</strong> ("Are we building the model correctly?"): check that code and math are correct. <strong>Validation</strong> ("Are we building the right model?"): compare outputs with empirical reality.` },
{ title: "Computational Reliabilism",
body: "Justification shifts from human comprehension to methodological rigour. We trust systems because they have passed stress tests, sensitivity analyses, and auditing — not because we understand every calculation." }
]
},
{ type: "paragraph", html: `Analogy: "I don't understand how a jet engine operates internally in real time, but I trust it because it has passed strict safety protocols and flown thousands of times without failure."` }
]
},
{
heading: "Problems caused by opacity in deployed AI",
blocks: [
{ type: "list", ordered: true, items: [
`<strong>Lack of accountability</strong> — If the model fails, who is responsible? The programmer? The data? The hardware? This creates <em>technological impunity</em>.`,
`<strong>Bias and invisible discrimination</strong> — A hiring algorithm might learn to reject women not because of an explicit rule, but because historically successful employees were predominantly men. If the model is opaque, we may not detect this until damage is done.`,
`<strong>Loss of human autonomy</strong> — <em>Algorithmic deference</em>: doctors or judges stop questioning the system because "the algorithm is smarter," eroding critical judgment.`,
`<strong>Difficulty in improvement and safety</strong> — If an autonomous car causes an accident and we cannot understand why, we cannot prevent the same failure from occurring again.`
]
}
]
},
{
heading: "Interpretable models",
blocks: [
{ type: "paragraph", html: `Models that are assumed to "explain themselves" — linear regression, logistic regression, decision trees, naive Bayes, k-NN. But this assumption has limits:` },
{ type: "case-study", label: "Linear regression",
title: tex`y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_n x_n`,
paragraphs: [
`An increase of feature $x_i$ by one unit (all others fixed) increases the outcome by $\\beta_i$ units. Feature importance: $t_{\\beta_j} = \\beta_j / SE(\\beta_j)$ — larger weight with less uncertainty = more important.`,
`<strong>Limitation — multicollinearity:</strong> if two variables are highly correlated, the model can assign a zero weight to one and capture the effect through the other, making the coefficients unstable and hard to interpret causally. Also: coefficients are only meaningful relative to how variables were scaled.`
]
},
{ type: "case-study", label: "Decision trees",
title: "Feature importance via Gini reduction",
paragraphs: [
`For each split on feature $x_j$, measure how much it reduced the Gini index (classification) or variance (regression) compared to the parent node. Sum all reductions for that feature across all splits. Scale to 100%.`,
`Individual predictions can be explained by decomposing the decision path: the prediction is the mean target value plus the sum of contributions at each split node from root to leaf.`
]
},
{ type: "paragraph", html: `But even for "interpretable" models: <em>Is this the kind of explanation we are looking for?</em> Does it make sense to increase the value of one feature while holding all others fixed? What about explanations requiring complex combinations of features?` }
]
},
{
heading: "Model-agnostic explanation methods",
blocks: [
{ type: "paragraph", html: `Model-agnostic methods work with any ML model — the most interesting when the goal is to understand, discuss, and contest decisions (not explain how a specific model works).` },
{ type: "grid", columns: 3, items: [
{ title: "Partial Dependence Plots (PDP)",
body: "Shows the marginal effect of one (or two) features on the predicted outcome by averaging predictions across all combinations of other features. Problem: produces unlikely data instances when features are correlated." },
{ title: "Permutation importance",
body: `Feature importance = increase in model error after permuting (shuffling) that feature's values, breaking its relationship with the outcome. "Important" = shuffling increases error. Problem: same correlation issue as PDP.` },
{ title: "LIME",
body: "Local Interpretable Model-Agnostic Explanations. Generates perturbed samples around a point of interest, gets predictions from the black box, trains an interpretable model weighted by proximity. Gives locally faithful (but not globally faithful) explanations." }
]
}
]
},
{
heading: "Counterfactual explanations",
blocks: [
{ type: "paragraph", html: `A counterfactual explanation describes a causal situation in the form:` },
{ type: "formula",
lines: [
`"Score s was returned because variables V = {Vi} had values {vi}.`,
` If V had instead been {v'i}, score s' would have been returned."`
]
},
{ type: "paragraph", html: `Example: <em>"Your loan was denied because your annual income is $30,000 and current balance is $200. If your income had instead been $35,000 and your balance $400, your loan would have been approved."</em>` },
{ type: "paragraph", html: `Counterfactual explanations are human-friendly because they are <strong>contrastive</strong> (compare to an alternative) and <strong>selective</strong> (focus on a small number of changes). But they suffer from the <strong>Rashomon effect</strong>: there are usually multiple different valid counterfactual explanations — a multiplicity of descriptions giving about the same minimum error rate.` }
]
},
{
heading: "Causal counterfactuals",
blocks: [
{ type: "paragraph", html: `Standard counterfactuals (Wachter, 2018) say "if you had feature value $v'$ and all others remain constant" — but this is NOT a causal counterfactual, because in reality features are not independent. A causal counterfactual asks: "If your data had looked like this, you would have received this score instead" — where the alternative is a realistic, causally coherent scenario.` },
{ type: "paragraph", html: `The problem: find a (set of) counterfactual(s) that is <em>both close to the actual datapoint</em> and <em>likely to occur in the real world</em>. Causal counterfactual queries are the base of truly good explanations.` }
]
},
{
heading: "Three notions of feature importance",
blocks: [
{ type: "grid", columns: 3, items: [
{ title: "1 · Face-value impact",
body: `Which feature $x_i$ has a big impact on the output value $y$? Used in linear models: $\\beta_j$ measures impact.` },
{ title: "2 · Predictive accuracy",
body: `How much does $x_j$ contribute to predictive accuracy? Used in decision trees (Gini reduction) and permutation tests.` },
{ title: "3 · Causal effect",
body: `What is the causal effect of intervening on $x_j$? Requires do-calculus / causal inference. The most meaningful for understanding real-world impact.` }
]
}
]
}
],
quiz: [
{ id: "q6-1",
question: "What is the difference between transparency, interpretability, and explainability?",
answer: `<strong>Transparency</strong>: a property of the system — making operational elements (code, data, parameters) visible. Addressable with documentation and traceability tools.<br><strong>Interpretability</strong>: a property of the model — the degree to which humans can understand how internal structure relates to inputs and outputs. High for linear models; low for deep nets.<br><strong>Explainability</strong>: a communicative act — producing a specific explanation of a specific decision for a specific audience. Requires understanding the explainee's mental model and tailoring the explanation accordingly.`
},
{ id: "q6-2",
question: "What are the four types of opacity in ML systems? Which is the hardest to solve and why?",
answer: `(a) <strong>Entanglement</strong>: unclear where failures originate; (b) <strong>Complexity</strong>: too many interactions for the human mind to grasp; (c) <strong>Behavioural unpredictability</strong>: we cannot anticipate outputs; (d) <strong>Lack of explanation</strong>: we have the "what" but not the "why."<br><br><strong>Hardest:</strong> (b) complexity — this is a structural limit to intelligibility, not just a hiddenness problem. A neural network with billions of parameters is not even in principle "openable and understandable" by a human mind.`
},
{ id: "q6-3",
question: "What is the Rashomon effect in the context of counterfactual explanations, and why is it a problem?",
answer: `The Rashomon effect refers to the fact that the same event can be described in different, contradictory ways. In ML: there are usually <strong>multiple different valid counterfactual explanations</strong> for the same prediction. This is a problem because: (1) different stakeholders can cherry-pick the counterfactual that suits their narrative; (2) it's unclear which counterfactual is the "real" explanation; (3) it undermines trust if two people receive contradictory explanations for the same decision.`
},
{ id: "q6-4",
question: "What is the key limitation of multicollinearity for interpreting linear models?",
answer: `When two features are highly correlated, they encode the same information. The model can assign a large weight to one and zero (or negative) to the other — both solutions have the same predictive power. The resulting coefficients may not reflect real causal influence: the model's choice of which variable to "use" is arbitrary and unstable. This means <strong>mechanistic interpretability does not imply causal or semantic interpretability</strong> — you may correctly understand <em>what the model does</em> but still be wrong about <em>what causes the outcome in the real world</em>.`
},
{ id: "q6-5",
question: "What lesson does computer simulation offer for managing opacity in ML systems?",
answer: `In computer simulation, opacity was not eliminated — it was <strong>managed</strong> through methodological rigour rather than full comprehension. The key strategy: <strong>Verification & Validation (V&V)</strong> — verify that the code correctly implements the intended logic; validate that outputs match empirical reality. <strong>Computational Reliabilism</strong>: trust justified not by understanding every calculation, but by passing stress tests, sensitivity analyses, and audits.<br><br>Applied to ML: we can trust opaque models when they have been rigorously validated, stress-tested across distributions, audited for bias, and subjected to ongoing monitoring — even without fully understanding their internal computation.`
}
]
}
] // end lectures
}; // end COURSE_DATA