# propublica/compas-analysis architecture

> Architecture diagram of the GitHub repository propublica/compas-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/propublica/compas-analysis
- Repository: https://github.com/propublica/compas-analysis

## Overview

This repository packages data and analysis for ProPublica’s COMPAS recidivism investigation. The principal workflow is an analyst following the Jupyter analysis against the supplied defendant and risk-score data; a separate Python utility groups parsed records by person, filters them to two-year populations, and writes analysis-ready CSVs. The README identifies the notebook, SQLite database, and investigation, but the notebook itself was not excerpted, so its internal analysis steps and data connections cannot be verified here.

Main entry points: [`truth_tables.py`](https://github.com/propublica/compas-analysis/blob/master/truth_tables.py) (Two-year preparation), [`cox-parsed.csv`](https://github.com/propublica/compas-analysis/blob/master/cox-parsed.csv) (Parsed Cox records), [`Compas Analysis.ipynb`](https://github.com/propublica/compas-analysis/blob/master/Compas%20Analysis.ipynb) (COMPAS analysis), [`compas-scores-two-years.csv`](https://github.com/propublica/compas-analysis/blob/master/compas-scores-two-years.csv) (Two-year scores)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis"]
  node_notebook["COMPAS analysis"]
end

subgraph group_preparation["Data preparation"]
  node_truth_tables["Two-year preparation<br/>[truth_tables.py]"]
end

subgraph group_data["Research data"]
  node_database[("Defendant database<br/>[compas.db]")]
  node_cox_parsed["Parsed Cox records<br/>[cox-parsed.csv]"]
  node_cox_violent["Parsed violent records"]
  node_scores_raw["Raw COMPAS scores"]
  node_scores["COMPAS scores<br/>[compas-scores.csv]"]
  node_two_year["Two-year scores"]
  node_two_year_violent["Two-year violent scores"]
end

node_analyst(("Analyst"))

node_analyst -->|"follows"| node_notebook
node_cox_parsed -->|"reads"| node_truth_tables
node_truth_tables -->|"writes"| node_two_year
node_truth_tables -->|"writes"| node_two_year_violent

click node_notebook "https://github.com/propublica/compas-analysis/blob/master/Compas%20Analysis.ipynb"
click node_truth_tables "https://github.com/propublica/compas-analysis/blob/master/truth_tables.py"
click node_database "https://github.com/propublica/compas-analysis/blob/master/compas.db"
click node_cox_parsed "https://github.com/propublica/compas-analysis/blob/master/cox-parsed.csv"
click node_cox_violent "https://github.com/propublica/compas-analysis/blob/master/cox-violent-parsed.csv"
click node_scores_raw "https://github.com/propublica/compas-analysis/blob/master/compas-scores-raw.csv"
click node_scores "https://github.com/propublica/compas-analysis/blob/master/compas-scores.csv"
click node_two_year "https://github.com/propublica/compas-analysis/blob/master/compas-scores-two-years.csv"
click node_two_year_violent "https://github.com/propublica/compas-analysis/blob/master/compas-scores-two-years-violent.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_notebook toneBlue
class node_truth_tables toneAmber
class node_database,node_cox_parsed,node_cox_violent,node_scores_raw,node_scores,node_two_year,node_two_year_violent toneMint
class node_analyst toneIndigo
```

## Components

### Analysis

- [COMPAS analysis](https://github.com/propublica/compas-analysis/blob/master/Compas%20Analysis.ipynb): `Compas Analysis.ipynb`

### Data preparation

- [Two-year preparation](https://github.com/propublica/compas-analysis/blob/master/truth_tables.py): `truth_tables.py`

### Research data

- [Defendant database](https://github.com/propublica/compas-analysis/blob/master/compas.db): `compas.db`
- [Parsed Cox records](https://github.com/propublica/compas-analysis/blob/master/cox-parsed.csv): `cox-parsed.csv`
- [Parsed violent records](https://github.com/propublica/compas-analysis/blob/master/cox-violent-parsed.csv): `cox-violent-parsed.csv`
- [Raw COMPAS scores](https://github.com/propublica/compas-analysis/blob/master/compas-scores-raw.csv): `compas-scores-raw.csv`
- [COMPAS scores](https://github.com/propublica/compas-analysis/blob/master/compas-scores.csv): `compas-scores.csv`
- [Two-year scores](https://github.com/propublica/compas-analysis/blob/master/compas-scores-two-years.csv): `compas-scores-two-years.csv`
- [Two-year violent scores](https://github.com/propublica/compas-analysis/blob/master/compas-scores-two-years-violent.csv): `compas-scores-two-years-violent.csv`

### Other components

- **Analyst**

## Connections

- Analyst → COMPAS analysis: follows (evidence: `README`)
- Parsed Cox records → Two-year preparation: reads (evidence: `truth_tables.py`)
- Two-year preparation → Two-year scores: writes (evidence: `truth_tables.py`)
- Two-year preparation → Two-year violent scores: writes (evidence: `truth_tables.py`)
