8 Accounting and Auditing
In October 1929, the New York Stock Exchange lost roughly a quarter of its value in a week. Congress spent the next several years arguing about why, and produced two statutes (the Securities Act of 1933 and the Securities Exchange Act of 1934) that required publicly traded companies to file financial statements examined by an independent auditor. The external audit went from a discretionary service a firm might commission to reassure its banker to a legally mandated act of public verification. The profession that performed it acquired, as part of the bargain, a public interest mandate. A certified public accountant’s client is the company paying the invoice. The duty of care runs to shareholders, lenders, regulators, and everyone downstream of the company’s claims about itself.
That bargain has been renegotiated since. Arthur Andersen signed off on Enron’s financial statements for years before Enron collapsed in 2001; its consulting practice had been earning more from Enron than its audit practice, and its shredded workpapers became the emblem of audit failure. Congress responded with the Sarbanes-Oxley Act of 2002, which tightened independence rules and created the Public Company Accounting Oversight Board to audit the auditors. The mandate was recertified under closer supervision.
Keegan (2026) codes accounting as a lineage of oversight: it formalizes “legible records, standardized controls, and independent verification.” Engineering, its partner in this book’s account of assurance, adds testing and incident learning (Chapter 10). The pressure both answer is exemption (Chapter 4) in a particular costume. Lee (1995) describes accountancy’s professional history as “protecting the public interest in a self-interested way,” and Baker (2005) finds the profession’s own pronouncements invoking “the public” as a legitimating abstraction while serving the paying client. Algorithmic auditing is about to repeat that history unless it studies it.
The worked example is national. Securities law, the Government Accountability Office (GAO), and the inspectors general are federal institutions, and federal agencies now report thousands of uses of AI in their own operations. This chapter’s audit therefore runs on national data, and its frame is the federal government’s own ledger of the algorithms it uses.
8.1 Audit-washing: exemption in oversight’s clothes
Raji and colleagues (2020) propose an internal algorithmic auditing framework borrowed from accounting, aerospace, and medicine. It names five stages (scoping, mapping, artifact collection, testing, reflection) and insists on durable, dated workpapers. A good audit produces documents a reasonable outsider could read a year later and use to reconstruct what was examined, what was found, and what was decided. A bad one produces a one-paragraph attestation.
The federal government has built the first layer of such a record. Executive Order 13960, signed in December 2020, required agencies to inventory their uses of artificial intelligence (Executive Office of the President 2020). OMB Memorandum M-25-21, issued in April 2025, keeps the annual inventory and requires agencies to apply minimum risk-management practices to use cases they judge “high-impact” (Office of Management and Budget 2025). The consolidated 2025 inventory, published on GitHub, lists 3,611 use cases from 41 agencies, 445 of them self-designated high-impact (Office of Management and Budget 2026). The federal auditor has also written the standard such records should meet. GAO’s AI accountability framework organizes its key practices under governance, data, performance, and monitoring, with questions written for auditors and third-party assessors (US Government Accountability Office 2021). When GAO examined the first round of inventories, it found that 15 of the 20 agencies reporting use cases had submitted incomplete or inaccurate information (US Government Accountability Office 2023).
Compare the city and the state. New York City’s Local Law 144, enforced since July 2023, requires employers using automated employment decision tools to commission an independent “bias audit” and publish a summary of selection rates and impact ratios by sex and race/ethnicity (NYC Department of Consumer and Worker Protection 2023). Goodman and Trehu (2023) use it to illustrate audit-washing: audits whose institutional form looks like oversight but whose content is shallow enough to credential almost any system. Some published LL144 audits are serious. Others are short PDFs that say which tool was audited and little about which data, metric choices, or population. A regime that accepts both as compliant has granted an exemption while appearing to deny one.
Colorado’s AI Act (SB 24-205) went further on paper, placing risk-management and impact-assessment duties on developers and deployers of “high-risk” systems (Colorado General Assembly 2024). It never took effect. A 2025 special session delayed it, and in May 2026 the legislature repealed and reenacted it as SB 26-189, effective January 1, 2027, which drops the impact assessments and risk-management programs and keeps notices, explanations of adverse decisions, rights to correction and human review, and Attorney General enforcement (Colorado General Assembly 2026). Chapter 7 reads that sequence as state lawmaking. Here it is a lesson in assurance: audit duties are negotiated, delayed, and narrowed long before anyone audits anything.
Oversight, as Chapter 4 develops it, needs authority and remedy that an audit cannot supply by itself. Accounting adds what an audit must supply on its own: dated workpapers, separation of audit from consulting, standards fixed before the numbers are seen, and a credential that can be revoked. An algorithmic audit that lacks all four performs oversight rather than providing it, and that performance is how exemption survives inside a regime that looks like regulation. The continuity element of the installed base (Chapter 2) matters for the same reason: an audit that cannot be rerun next quarter because the analyst’s laptop was wiped is, for public purposes, an audit that did not happen. The specific claim of this chapter is that a manifest, a thresholds file, and a changelog are the minimum installed base for independent verification.
8.2 Tutorial, part 1: reading the federal ledger
Begin where an auditor begins: with the client’s own books. The inventory is a CSV, and its high-impact columns record whether each minimum practice was carried out.
import pandas as pd
INV = ("https://raw.githubusercontent.com/ombegov/"
"2025-Federal-Agency-AI-Use-Case-Inventory/main/Data/"
"2025_individually_reported_AI_use_cases.csv")
inv = pd.read_csv(INV, low_memory=False)
print(inv.shape)
# => (3611, 36) (repository as of May 2026)
hi = inv.query("is_high_impact == 'High-impact' and development_stage == 'Deployed'")
print(len(hi), hi["hi_assessment_completed"].fillna("(blank)").value_counts().to_dict())
# => 227 {'(blank)': 101, 'In-progress': 90, 'Yes': 36}
print(hi.loc[hi["hi_assessment_completed"].isna(), "agency_name"].value_counts().head(2))
# => Department of Veterans Affairs 94
# => National Credit Union Administration 5Of 227 deployed high-impact uses, 36 report a completed impact assessment. Do not write “101 have no assessment.” A blank is not a “No”; 94 of the blanks come from one agency, which suggests a reporting format rather than 94 separate decisions. An auditor’s next move is a request for the agency’s own inventory and its supporting documents, not a headline.
8.3 Tutorial, part 2: a disaggregated audit on national data
Gender Shades (Buolamwini and Gebru 2018) showed that a single accuracy number can hide large disparities across intersectional groups. The disaggregated audit is the technique that refuses the single number. You will run one on folktables (Ding et al. 2021), which packages American Community Survey (ACS) microdata into prediction tasks, using fairlearn for disaggregated metrics. The task, ACSIncome, predicts whether a working adult’s income exceeds $50,000. It is deliberately banal. Load it state by state, keeping only the task’s columns, so the national file fits on a laptop.
# pip install folktables fairlearn scikit-learn pandas pyyaml joblib
import pandas as pd
from folktables import ACSDataSource, ACSIncome, state_list
source = ACSDataSource(survey_year="2018", horizon="1-Year", survey="person")
frames = []
for st in state_list: # 50 states and Puerto Rico
raw = source.get_data(states=[st], download=True)
X, y, _ = ACSIncome.df_to_pandas(raw)
frames.append(X.assign(label=y.squeeze().to_numpy(), state=st))
acs = pd.concat(frames, ignore_index=True)
print(acs.shape, round(acs["label"].mean(), 3))
# => (1664500, 12) 0.369The first run downloads about 2 GB. state_list has no District of Columbia, so “national” here means fifty states and Puerto Rico. Write that into the manifest. Now recode race from the ACS RAC1P code and sex from SEX:
RAC1P = {1: "White", 2: "Black", 3: "AIAN", 4: "AIAN", 5: "AIAN",
6: "Asian", 7: "NHPI", 8: "Some other race", 9: "Two or more"}
race = acs["RAC1P"].map(RAC1P).fillna("Unknown")
sex = acs["SEX"].map({1: "Male", 2: "Female"})
features = acs.drop(columns=["label", "state"])Check every key against the ACS PUMS data dictionary for your vintage. Codes 3 through 5 are three American Indian and Alaska Native categories, which this map collapses. Hispanic origin is a separate variable (HISP) and is not in the task. RAC1P and SEX are also model features in ACSIncome, which is itself a choice an auditor should question. Write all of these down. Then fit the simplest defensible model:
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
X_tr, X_te, y_tr, y_te, r_tr, r_te, s_tr, s_te, st_tr, st_te = train_test_split(
features, acs["label"], race, sex, acs["state"],
test_size=0.3, random_state=42, stratify=acs["label"])
model = make_pipeline(StandardScaler(), LogisticRegression(max_iter=1000))
model.fit(X_tr, y_tr)
y_pred = model.predict(X_te)The model is crude (occupation and birthplace codes are treated as numbers), which is fine: the audit should be method-agnostic.
from sklearn.metrics import accuracy_score
from fairlearn.metrics import (MetricFrame, count, selection_rate,
false_positive_rate, false_negative_rate,
demographic_parity_difference, equalized_odds_difference)
sensitive = pd.DataFrame({"race": r_te, "sex": s_te})
mf = MetricFrame(
metrics={"n": count, "accuracy": accuracy_score,
"selection_rate": selection_rate,
"fpr": false_positive_rate, "fnr": false_negative_rate},
y_true=y_te, y_pred=y_pred, sensitive_features=sensitive)
print(mf.by_group.sort_values("n").round(3))
# => n accuracy selection_rate fpr fnr
# => NHPI Female 436.0 0.846 0.128 0.057 0.566
# => NHPI Male 450.0 0.758 0.282 0.155 0.436
# => ... (14 cells in all)
# => White Male 205533.0 0.754 0.461 0.224 0.271
dpd = demographic_parity_difference(y_te, y_pred, sensitive_features=sensitive)
eod = equalized_odds_difference(y_te, y_pred, sensitive_features=sensitive)
print(f"DPD {dpd:.3f} EOD {eod:.3f}")
# => DPD 0.481 EOD 0.545These numbers come from one run with fairlearn 0.14.0, scikit-learn 1.9.1, and pandas 3.0.6. The two summaries are not “the” fairness score. Each is the gap between two cells: Asian men, selected at 0.541, and women of some other race, at 0.061, for parity; the false-negative rates of the same two groups, 0.184 and 0.729, for equalized odds. MetricFrame.by_group is the centerpiece, and its n column tells your reader whether any other number means anything.
A national auditor also asks whether one model serves every state equally. Pass st_te as the sensitive feature and the gap in accuracy between the best and worst state is 0.073 (Utah at 0.809, Wyoming at 0.736).
fairlearn will not tell you which parity metric is defensible. Demographic parity asks whether positive predictions are allocated at the same rate across groups; equalized odds asks whether error rates are balanced given the true label. With unequal base rates they cannot both be satisfied, which is a mathematical result, not a political one. Two quieter surprises. First, demographic_parity_difference is the gap between the highest and lowest group, computed over every cell you pass in. Cross state, race, and sex and you get 714 cells, 244 of them with fewer than thirty people, and a parity difference of exactly 1.0: somewhere a tiny cell had everyone selected and another had no one. The headline is set by your smallest group. Second, nothing in the library warns you about small cells. Report n beside every metric, suppress cells below a documented minimum, and say in prose which groups the audit cannot speak to.
Save the evaluation set and the model so the workpaper can verify them:
import joblib
X_te.assign(label=y_te.values, race=r_te.values, sex=s_te.values,
state=st_te.values).to_csv("data/acs_2018_test.csv", index=False)
joblib.dump(model, "models/logit-v1.joblib")8.4 Tutorial, part 3: from notebook to workpaper
A notebook produced those numbers once. An audit has to produce them on demand, with a record of every decision and a log of what changed between runs. Build this layout:
audit-pipeline/
├── CHANGELOG.md Makefile manifest.yaml thresholds.yaml audit.py
├── data/ models/ reports/
manifest.yaml is the input contract. A reviewer a year from now should be able to reconstruct the run without guessing.
audit:
name: "ACSIncome national disaggregated audit"
run_id: "2027-03-04-001"
analyst: "your.name@colorado.edu"
dataset:
source: "ACS PUMS 2018 1-Year, 50 states and Puerto Rico, via folktables ACSIncome"
local_path: "data/acs_2018_test.csv"
sha256: "<output of sha256sum>"
retrieved_on: "2027-03-04"
recoding: "RAC1P 3-5 collapsed to AIAN; HISP not used; DC not in state_list"
model:
path: "models/logit-v1.joblib"
sha256: "<output of sha256sum>"
description: "StandardScaler + LogisticRegression, random_state=42"
protected_attributes: [race, sex]
strata: [state] # carried in the file, never passed to the model
min_cell_size: 100
thresholds_file: "thresholds.yaml"thresholds.yaml carries the decision rules separately, because they change on a different cadence and need their own authority:
demographic_parity_difference: {warn: 0.05, fail: 0.10}
equalized_odds_difference: {warn: 0.05, fail: 0.10}
adopted: "2027-03-04"
authority: >
Teaching values. A real audit cites the statute, rule, policy,
or contract clause that set them, and who may change them.Most algorithmic audits skip the authority field, which is how thresholds drift without anyone deciding to move them.
audit.py reads the manifest, verifies the hashes, runs the disaggregation, applies the thresholds, and writes a dated report:
import hashlib, json, pathlib, sys
from datetime import datetime, timezone
import joblib, pandas as pd, yaml
from fairlearn.metrics import (MetricFrame, count, selection_rate,
false_positive_rate, false_negative_rate,
demographic_parity_difference, equalized_odds_difference)
SUMMARIES = {"demographic_parity_difference": demographic_parity_difference,
"equalized_odds_difference": equalized_odds_difference}
def sha256_of(path):
return hashlib.sha256(pathlib.Path(path).read_bytes()).hexdigest()
def verify(m):
pairs = [("dataset", m["dataset"]["local_path"]), ("model", m["model"]["path"])]
bad = [k for k, p in pairs if sha256_of(p) != m[k]["sha256"]]
if bad:
sys.exit(f"hash mismatch: {bad}") # no report for unverified inputs
def run_audit(df, model, m):
attrs = m["protected_attributes"]
y_true = df["label"]
X = df.drop(columns=["label"] + attrs + m.get("strata", []))
y_pred = model.predict(X)
mf = MetricFrame(metrics={"n": count, "selection_rate": selection_rate,
"fpr": false_positive_rate, "fnr": false_negative_rate},
y_true=y_true, y_pred=y_pred, sensitive_features=df[attrs])
by_group = mf.by_group[mf.by_group["n"] >= m["min_cell_size"]]
summaries = {k: float(f(y_true, y_pred, sensitive_features=df[attrs]))
for k, f in SUMMARIES.items()}
return by_group, summaries
def evaluate(summaries, thresholds):
out = []
for name, value in summaries.items():
rule = thresholds[name]
level = ("FAIL" if value >= rule["fail"]
else "WARN" if value >= rule["warn"] else "PASS")
out.append({"metric": name, "value": round(value, 4), "level": level})
return out
def main():
m = yaml.safe_load(open("manifest.yaml"))
thresholds = yaml.safe_load(open(m["thresholds_file"]))
verify(m)
df = pd.read_csv(m["dataset"]["local_path"])
by_group, summaries = run_audit(df, joblib.load(m["model"]["path"]), m)
report = {"run_id": m["audit"]["run_id"],
"generated_at": datetime.now(timezone.utc).isoformat(),
"manifest": m, "findings": evaluate(summaries, thresholds),
"by_group": by_group.reset_index().to_dict(orient="records")}
pathlib.Path("reports").mkdir(exist_ok=True)
out = pathlib.Path(f"reports/{m['audit']['run_id']}.json")
out.write_text(json.dumps(report, indent=2, default=str))
print(json.dumps(report["findings"], indent=2))
if __name__ == "__main__":
main()
# => [{"metric": "demographic_parity_difference", "value": 0.4806, "level": "FAIL"},
# => {"metric": "equalized_odds_difference", "value": 0.5449, "level": "FAIL"}]The script refuses to run on inputs whose hashes do not match the manifest, suppresses small cells by a rule written down in advance, and stamps the run in UTC. Each behavior is borrowed from financial audit practice, where a workpaper exists to be legible to someone who was not in the room.
The Makefile is the one-command interface: an audit target that runs python audit.py and a clean target that removes reports/*.json. If a reviewer cannot type make audit and get a report, the pipeline is not reproducible. clean removes generated reports, never inputs. You do not delete workpapers. You archive them. CHANGELOG.md is the narrative companion to the numbers: one dated entry per run_id, recording the input hashes, the threshold adoption date, the fairlearn and scikit-learn versions, and any change in findings with its root cause.
Commit the directory, run make audit, and read the report for what it does not say: which columns were features, whether the model was evaluated on a holdout. A week later, update run_id and run again. Usually nothing moves. Sometimes a library release changes a default and a metric shifts in the third decimal place. The discipline is not preventing drift. It is noticing it, logging it, and deciding whether it changes the conclusion.
8.5 Writing the audit for a non-technical reader
The JSON report is raw material. The audit is what you write around it, and it is the seed of the report genre in Chapter 15. Use four sections.
- What the model is, and is not. A logistic regression trained on one year of national ACS data. A teaching artifact, not a procurement recommendation.
- Who is in the data. The per-cell counts, with the smallest cells named in prose, including those below
min_cell_sizethat the audit cannot speak to. Audits that silently drop small cells pretend to a completeness they lack. - What the metrics show. The disaggregated table with a plain-language reading of each gap, its threshold level, and its direction, plus the by-state spread.
- What the audit rests on. The recoding, the omitted Hispanic-origin variable, the missing District of Columbia, self-reported and sampled survey data, a single vintage and a single holdout. Name each choice and how a second auditor might make it differently.
Section 4 is where audit-washing hides. If the next auditor cannot reproduce your table from your manifest, the audit is not an instrument of oversight. It is a press release.
8.6 Exercises
Exercise 8.1 (Guided, laptop, real public data). Run the national ACSIncome audit above end to end, then build the audit-pipeline/ directory, fill manifest.yaml with real hashes from sha256sum, commit it, and run make audit. Submit the repository URL and the generated report. If your numbers differ from the chapter’s, record your library versions and say where the difference enters.
Exercise 8.2 (Guided). One week later, rerun with a new run_id. Write a changelog entry stating the exact fairlearn and scikit-learn versions and what changed, even if nothing did.
Exercise 8.3 (Analytic, real public data). Load the 2025 federal AI use case inventory. For one agency with at least five high-impact use cases, tabulate every hi_ column. In 400 words, assess the agency’s entries against the four principles of GAO’s accountability framework (US Government Accountability Office 2021). Which workpaper is missing? Distinguish blanks from answers, and name the document you would request to resolve each blank.
Exercise 8.4 (Comparative). In 500 words, compare a published LL144 bias audit summary, the Colorado Act as reenacted by SB 26-189, and M-25-21’s high-impact practices on three dimensions: which systems are covered, who performs the assessment, and what is published. Quote each text. Is the LL144 summary audit-washing in Goodman and Trehu’s (2023) sense? Say what evidence would change your verdict.
Exercise 8.5 (Open-ended; submittable artifact). Extend your pipeline with a second folktables task (ACSEmployment or ACSPublicCoverage) or a second sensitive attribute, still national. Rewrite thresholds.yaml so its authority field names a real federal body and the instrument it could use to adopt such thresholds (an OMB memorandum, a NIST standard, a GAO recommendation). Then write the four-section audit memo (about 800 words). It becomes the methods and findings of a report addressed to that body (Chapter 15).
8.7 Looking ahead
A workpaper records what you did. It does not prove that the code does what the workpaper says. Chapter 10 puts this pipeline under test: shape and range checks on a fixture, a regression snapshot, a deliberately introduced bug, a post-incident review, and continuous integration. Engineering also asks who keeps the record when the audited party will not, which is where worker observatories enter.
8.8 Further Reading and Resources
- C. Richard Baker (2005), “What is the meaning of ‘the public interest’? Examining the ideology of the American public accounting profession,” Accounting, Auditing & Accountability Journal 18(5). The close reading of AICPA language this chapter leans on.
- Inioluwa Deborah Raji et al. (2020), “Closing the AI accountability gap,” Proceedings of FAccT 2020. Audit as a practice rather than a metric.
- Bryce Goodman and Julia Trehu (2023), “AI audit washing and accountability.” The term in its useful form.
- U.S. GAO (2021), Artificial Intelligence: An Accountability Framework for Federal Agencies and Other Entities, GAO-21-519SP: https://www.gao.gov/products/gao-21-519sp. The federal auditor’s own questions for AI.
- OMB, 2025 Federal Agency AI Use Case Inventory: https://github.com/ombegov/2025-Federal-Agency-AI-Use-Case-Inventory. Read the data dictionary and standardization report in
Validation/before you count anything. - NYC Department of Consumer and Worker Protection, Local Law 144 page: https://www.nyc.gov/site/dca/about/automated-employment-decision-tools.page. Read the final rule, not only the FAQ.
- Colorado General Assembly, SB 26-189: https://leg.colorado.gov/bills/sb26-189, with SB 24-205 at https://leg.colorado.gov/bills/sb24-205. Read the two side by side.
folktablesrepository and paper: https://github.com/socialfoundations/folktables. Read the documentation on the limits of ACS tasks as benchmarks.fairlearnuser guide: https://fairlearn.org/main/user_guide/. The sections onMetricFrameand on disagreement between parity metrics.