Trust, Reliance, and Automation Bias › Code: Measuring Agreement in Decision Logs

Michael BrenndoerferDecember 2, 20267 min read
Language AI HandbookAll chapters
Part 62 of 67Human-AI Interaction and Governance
Chapter 473Trust, Reliance, and Automation Bias › Code: Measuring Agreement in Decision Logs
Reading section 9 of 13 · Code: Measuring Agreement in Decision Logs · 7 minSection 9 of 13 · 7 min

Section 9 of 13 · 7 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A production log of the AI suggestion, final decision and reference label can estimate their agreement and final accuracy on labeled cases. The four cells tell you whether the final answer matches the suggestion and whether the suggestion is correct. They do not identify whether the AI changed the human's mind.

A person whose decision agrees with the suggestion could have selected it independently, or could have used the suggestion as a check. Instrument current user actions or collect an answer before advice if you need to observe different mechanisms.

Below we simulate a log and derive the matched and unmatched cells. The result describes the joint distribution of recorded answers. A historical pre-launch comparison can be confounded by case mix, which limits what it tells us about causal changes.

A randomly assigned no-advice condition creates a comparison workflow. Keep the time allowed for review and the outcome definition alike where possible, and analyze cases according to the assigned condition. Compare each design using the same decision metric, and retain the uncertainty in estimates from small samples.

The analyzer below expects a nonempty set of fully labeled binary decisions. It returns an error for a missing field, an empty log, or values other than 0 and 1. When records are only partly labeled, measure coverage and decide which subset can support the audit before calling the analyzer.

PythonIn [31]
CollapseExpand
def analyze_reliance_log(log: pd.DataFrame) -> dict:
    """Summarize agreement for nonempty, fully labeled binary records."""
    required = ["ai_a", "human_d", "y"]
    missing = sorted(set(required) - set(log.columns))
    if missing:
        return {"error": f"missing columns: {missing}"}
    if log.empty or not log[required].isin([0, 1]).all().all():
        return {"error": "expected nonempty, fully labeled binary records"}

    followed = log["human_d"] == log["ai_a"]
    ai_correct = log["ai_a"] == log["y"]
    final_correct = log["human_d"] == log["y"]
    n = len(log)

    cells = {
        "n": n,
        "ai_accuracy": ai_correct.mean(),
        "team_accuracy": final_correct.mean(),
        "follow_rate": followed.mean(),
        "false_acceptance": (followed & ~ai_correct).sum() / n,
        "false_override": (~followed & ai_correct).sum() / n,
        "correct_agreement": (followed & ai_correct).sum() / n,
        "correct_override": (~followed & ~ai_correct).sum() / n,
        "discrimination": followed[ai_correct].mean()
        - followed[~ai_correct].mean(),
    }
    return cells


log = make_trials(
    5000,
    ai_accuracy=0.78,
    cue_strength=0.5,
    cue_availability=0.8,
    time_pressure=False,
    seed=7,
)
log = log.rename(columns={"ai_correct": "ai_correct_flag"})
# Build the minimal log columns
log_public = pd.DataFrame(
    {
        "ai_a": log["ai_a"],
        "human_d": log["human_d"],
        "y": log["y"],
    }
)
cells = analyze_reliance_log(log_public)
assert "error" in analyze_reliance_log(log_public.drop(columns="y"))
assert "error" in analyze_reliance_log(log_public.iloc[:0])
assert "error" in analyze_reliance_log(log_public.assign(y=np.nan))
assert "error" in analyze_reliance_log(log_public.assign(human_d=2))
Out[32]:
value
n 5000.00000
ai_accuracy 0.78120
team_accuracy 0.57440
follow_rate 0.52120
false_acceptance 0.08280
false_override 0.34280
correct_agreement 0.43840
correct_override 0.13600
discrimination 0.18276

The difference between agreement on correct and incorrect advice is descriptive. When both subsets have observations, it can be zero at any shared agreement rate. If every AI answer is correct or every answer is wrong, the missing conditional rate makes the difference undefined, and the analyzer returns NaN for that metric. The full-sample proportions still have values. Log initial answers or explicit accept actions to study reliance behavior.

The figure collects the four cells and the discrimination score from the simulated log. The first four bars use the full sample as denominator. The fifth subtracts the two conditional agreement rates.

PythonIn [33]
CollapseExpand
import numpy as np

log_metric_names = [
    "correct_agreement",
    "false_acceptance",
    "false_override",
    "correct_override",
    "discrimination",
]
log_metric_labels = [
    "Correct agreement",
    "False acceptance",
    "False override",
    "Correct override",
    "Discrimination",
]
log_metric_values = np.array([float(cells[n]) for n in log_metric_names])
VisualizationOut [34]
CollapseExpand
Bar chart of five log-derived reliance metrics including the discrimination score.
Reliance metrics derived from a simulated production log. Four answer-matching outcomes use the full-sample denominator. Discrimination is the difference of the two conditional match rates.

The log cells describe observed agreement. To estimate how showing advice changes outcomes, use randomized access and compare the assigned groups under the same outcome definition. If decision labels are missing, report the number of unlabeled rows and inspect how the audited sample was selected.

Labels can be wrong. Then even measured accuracy and measured AI correctness depend on that noise. Compare agreement and final outcomes in an audited subset with reliable reference labels. Retain discrepancies and annotate cases that genuinely lack a single correct answer.

A paired record of actual switches

The selector above generates an alternate answer from the AI's label. It has no unaided human baseline. Here a separate toy exercise records what the person initially chose. On an initial disagreement, switching to correct advice improves the answer and switching to wrong advice worsens it. Agreement on an unchanged answer is neither kind of switch. For binary choices with a required answer, a person who disagrees with the AI must initially hold the only other label.

Suppose the help desk only needs to answer one question for each ticket: “Is the requested remedy eligible under the current policy?” Generate 12,000 fictional tickets split between standard and exception cases. We choose the AI and human accuracies by case type. On standard tickets the AI is more likely to be right. On exception tickets the human is more likely to be right. These starting accuracies are settings of the simulation.

The fixture stores one draw for each decision input. Both policies therefore face the same ticket labels, initial answers, and suggestions. The noise, inspection draw and fallback draw are also shared. Changing the chance of inspecting the cue leaves every other sampled input in place.

PythonIn [35]
CollapseExpand
import numpy as np
import pandas as pd

n = 12_000
rng = np.random.default_rng(19)

exception = rng.random(n) < 0.30
truth = rng.integers(0, 2, size=n)
ai_right = rng.random(n) < np.where(exception, 0.55, 0.82)
human_right = rng.random(n) < np.where(exception, 0.82, 0.68)

trials = pd.DataFrame(
    {
        "task": np.where(exception, "Exception", "Standard"),
        "truth": truth,
        "initial": np.where(human_right, truth, 1 - truth),
        "advice": np.where(ai_right, truth, 1 - truth),
        "cue_noise": rng.normal(size=n),
        "check_draw": rng.random(n),
        "fallback_draw": rng.random(n),
    }
)


def choose(trials, cue_strength, check_probability, default_adoption=0.60):
    cue = cue_strength * np.where(trials.advice == trials.truth, 1, -1)
    cue = cue + trials.cue_noise
    checked = trials.check_draw < check_probability
    adopt = np.where(checked, cue > 0, trials.fallback_draw < default_adoption)
    final = np.where(adopt, trials.advice, trials.initial)
    return trials.assign(final=final, checked=checked)

The rule compares a score with zero. The score has mean cue_strength for correct advice and its negative for wrong advice, with standard normal noise in both cases. When a trial is uninspected, the policy chooses the suggestion with probability 0.60. The person can match the suggestion without switching when their initial answer already agrees.

PythonIn [36]
CollapseExpand
def summarize(decisions):
    advice_right = decisions.advice == decisions.truth
    initial_right = decisions.initial == decisions.truth
    final_right = decisions.final == decisions.truth
    agree = decisions.final == decisions.advice
    dispute = decisions.initial != decisions.advice
    help_opportunity = dispute & advice_right
    harm_opportunity = dispute & ~advice_right
    return pd.Series(
        {
            "N": len(decisions),
            "AI accuracy": advice_right.mean(),
            "Initial accuracy": initial_right.mean(),
            "Final accuracy": final_right.mean(),
            "Final agreement": agree.mean(),
            "Helpful opportunities": help_opportunity.sum(),
            "Helpful switches": (help_opportunity & agree).sum(),
            "Helpful switch rate": agree[help_opportunity].mean(),
            "Harmful opportunities": harm_opportunity.sum(),
            "Harmful switches": (harm_opportunity & agree).sum(),
            "Harmful switch rate": agree[harm_opportunity].mean(),
        }
    )


normal = choose(trials, cue_strength=0.7, check_probability=0.85)
limited = choose(trials, cue_strength=0.7, check_probability=0.25)
comparison = pd.DataFrame(
    {
        "More inspection": summarize(normal),
        "Less inspection": summarize(limited),
    }
).T
print(comparison.round(3).to_string())
# In the separate 200-trial worked example, a net gain of 6 gives 3 percentage points.
assert (16 - 10) * 100 / 200 == 3
ConsoleOut [36]
CollapseExpand
                       N  AI accuracy  Initial accuracy  Final accuracy  Final agreement  Helpful opportunities  Helpful switches  Helpful switch rate  Harmful opportunities  Harmful switches  Harmful switch rate
More inspection  12000.0        0.742              0.73           0.820            0.806                 2511.0            1812.0                0.722                 2369.0             735.0                0.310
Less inspection  12000.0        0.742              0.73           0.764            0.828                 2511.0            1609.0                0.641                 2369.0            1204.0                0.508

Interpret the helpful switch rate as the share of helpful opportunities taken. Interpret the harmful switch rate as the share of harmful opportunities taken. Each rate uses its own denominator and is undefined if there were no opportunities. If 16 helpful and 10 harmful switches occurred in 200 trials, final accuracy is 3 percentage points higher than initial accuracy. The AI baseline on those same trials is a separate comparison. Schemmer and colleagues use these same opportunity sets. In this binary exercise with a required final answer, relative AI reliance equals the helpful switch rate. Relative self-reliance equals the share of harmful opportunities on which the reviewer keeps their correct initial answer, which is one minus the harmful switch rate. Schemmer et al..

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy