Exercise: Audit a fabricated AI coding system#

A research team uses an automated text coder. The following frozen, invented labels are a teaching fixture, not output from a real model. Determine whether aggregate agreement hides a subgroup failure and whether correction improves inference.

See the shared submission guidance and rubric. Run from book/exercises; the setup below supplies data, not completed answers.

# Shared simulator and small utility functions; no live service is called.
source("../R/course.R")
audit <- data.frame(id=1:24, style=rep(c("direct","indirect"),each=12),
 reference=rep(c(1,1,1,1,1,1,0,0,0,0,0,0),2),
 predicted=c(1,1,1,1,1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0))
# Reference labels are assumed correct for this toy audit, not infallible in real research.

1. Locate the error pattern#

Calculate overall and style-specific confusion matrices, sensitivity, specificity, and positive-label prevalence. Identify which metric reveals the failure concealed by aggregate agreement. State the denominators and report undefined ratios explicitly if you encounter them.

# Compute counts before rates for the overall sample and each style.

Your explanation and evidence:

2. Trace errors into a research claim#

Compare the style difference in reference-positive prevalence with the difference from predicted labels. Explain how a measurement error pattern can create an apparent substantive group difference. Identify assumptions needed to use these reference labels as ground truth.

# Quantify the difference-of-prevalences distortion.

Your explanation and evidence:

3. Design the next audit#

Propose a blinded human reannotation sample with style stratification, an ambiguity/adjudication policy, and a held-out set for evaluating any revised coding prompt. Specify what should be logged about model version and prompt changes. Explain why fixing the listed errors and rescoring these same 24 cases would not estimate future performance.

# Optional uncertainty calculation; state the sampling unit and the toy sample limitation.

Your explanation and evidence:

What to submit#

An overall/subgroup error table, a measurement-to-inference comparison, and a prospective audit protocol. No live AI service, private text, or fabricated claim of actual model performance is needed.