confusion-mapper 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- confusion_mapper-1.0.0.dist-info/METADATA +231 -0
- confusion_mapper-1.0.0.dist-info/RECORD +7 -0
- confusion_mapper-1.0.0.dist-info/WHEEL +5 -0
- confusion_mapper-1.0.0.dist-info/entry_points.txt +2 -0
- confusion_mapper-1.0.0.dist-info/licenses/LICENSE +6 -0
- confusion_mapper-1.0.0.dist-info/top_level.txt +1 -0
- confusion_mapper.py +1474 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: confusion-mapper
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Human-AI hybrid inter-rater reliability tool for cognitive error taxonomy classification in MCQ distractors.
|
|
5
|
+
Author-email: Manik Maurya <manikmaurya.in@gmail.com>
|
|
6
|
+
Maintainer-email: Manik Maurya <manikmaurya.in@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 Manik Maurya
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files...
|
|
13
|
+
Project-URL: Homepage, https://github.com/Manik-Maurya/Confusion-Mapper
|
|
14
|
+
Project-URL: Repository, https://github.com/Manik-Maurya/Confusion-Mapper
|
|
15
|
+
Project-URL: Source, https://github.com/Manik-Maurya/Confusion-Mapper
|
|
16
|
+
Project-URL: Documentation, https://github.com/Manik-Maurya/Confusion-Mapper#readme
|
|
17
|
+
Project-URL: Issues, https://github.com/Manik-Maurya/Confusion-Mapper/issues
|
|
18
|
+
Project-URL: Changelog, https://github.com/Manik-Maurya/Confusion-Mapper/blob/main/CHANGELOG.md
|
|
19
|
+
Project-URL: Archive, https://doi.org/10.5281/zenodo.20807432
|
|
20
|
+
Keywords: inter-rater-reliability,cohens-kappa,weighted-kappa,bootstrap-confidence-interval,cognitive-science,educational-assessment,multiple-choice-questions,distractor-classification,human-ai-collaboration,preregistration
|
|
21
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
22
|
+
Classifier: Intended Audience :: Science/Research
|
|
23
|
+
Classifier: Intended Audience :: Education
|
|
24
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
25
|
+
Classifier: Natural Language :: English
|
|
26
|
+
Classifier: Operating System :: OS Independent
|
|
27
|
+
Classifier: Programming Language :: Python
|
|
28
|
+
Classifier: Programming Language :: Python :: 3
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
33
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
34
|
+
Classifier: Topic :: Scientific/Engineering
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
36
|
+
Classifier: Topic :: Education :: Testing
|
|
37
|
+
Requires-Python: >=3.9
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Requires-Dist: openai>=1.0.0
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
43
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
44
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# ConfusionMapper
|
|
48
|
+
|
|
49
|
+
A Python tool for classifying wrong answer choices in multiple-choice questions by the type of cognitive error they represent, and for computing how well a human researcher and an AI rater agree on those labels.
|
|
50
|
+
|
|
51
|
+
[](https://doi.org/10.5281/zenodo.20807432)
|
|
52
|
+
[](https://github.com/Manik-Maurya/Confusion-Mapper/actions/workflows/tests.yml)
|
|
53
|
+
[](https://opensource.org/licenses/MIT)
|
|
54
|
+
[](https://www.python.org/)
|
|
55
|
+
|
|
56
|
+
## What it does
|
|
57
|
+
|
|
58
|
+
In educational research, you cannot use qualitative labels in a statistical analysis unless two independent raters can produce roughly the same labels on the same items. The usual way to check this is Cohen's kappa.
|
|
59
|
+
|
|
60
|
+
ConfusionMapper handles the full workflow. You go through a set of distractors one by one and pick a label for each. If you have an OpenAI API key, an AI rater labels the same distractors in parallel. At the end, the program computes Cohen's kappa, draws a 4x4 confusion matrix of where the two raters agreed and disagreed, and saves everything to JSON.
|
|
61
|
+
|
|
62
|
+
It was built as the reliability check for a preregistered RCT on cognitive error feedback in government junior high schools (OSF: https://doi.org/10.17605/OSF.IO/YU6P5). Data collection in that study could only start once kappa cleared 0.70.
|
|
63
|
+
|
|
64
|
+
## The four error types
|
|
65
|
+
|
|
66
|
+
The taxonomy is called the Confusion Fingerprint Index (CFI). It splits wrong answers into four categories:
|
|
67
|
+
|
|
68
|
+
| Code | Name | What it looks like |
|
|
69
|
+
|------|------|---------------------|
|
|
70
|
+
| RF | Recall Failure | No memory trace at all; the answer is essentially random |
|
|
71
|
+
| PK | Partial Knowledge | Almost right; the direction is correct but the model is incomplete |
|
|
72
|
+
| CF | Confabulation | A coherent misconception held with confidence |
|
|
73
|
+
| INT | Interference | A correct answer pulled from the wrong topic |
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
Once a versioned release is on PyPI:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install confusion-mapper
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
From source (until the first PyPI release, this is the recommended path):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git clone https://github.com/Manik-Maurya/Confusion-Mapper.git
|
|
87
|
+
cd Confusion-Mapper
|
|
88
|
+
pip install -e .
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The only runtime dependency is `openai>=1.0.0`. `tkinter` ships with Python on most systems; on a minimal Debian or Ubuntu image install it with `sudo apt-get install python3-tk`. If `tkinter` is missing, ConfusionMapper drops to console output instead of the GUI.
|
|
92
|
+
|
|
93
|
+
Python 3.9 or higher.
|
|
94
|
+
|
|
95
|
+
For the test extras:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install -e ".[dev]"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Run
|
|
102
|
+
|
|
103
|
+
Without an API key (you label everything by hand):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
python confusion_mapper.py
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
With the AI rater on:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# macOS / Linux
|
|
113
|
+
export OPENAI_API_KEY="your-key-here"
|
|
114
|
+
python confusion_mapper.py
|
|
115
|
+
|
|
116
|
+
# Windows
|
|
117
|
+
set OPENAI_API_KEY=your-key-here
|
|
118
|
+
python confusion_mapper.py
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For each distractor, type `1` for RF, `2` for PK, `3` for CF, or `4` for INT. When you finish, the dashboard opens and the session writes itself to JSON.
|
|
122
|
+
|
|
123
|
+
## Case study
|
|
124
|
+
|
|
125
|
+
A fully reproducible worked example lives in [`case_study/`](case_study/). It runs the entire
|
|
126
|
+
pipeline (nominal kappa, weighted kappa under linear and quadratic schemes, BCa
|
|
127
|
+
bootstrap 95% CI, confusion matrix, per-category stats) on the bundled 30-item
|
|
128
|
+
paired-label set with a fixed seed, then writes a publication-ready bundle to
|
|
129
|
+
`case_study/results/` (JSON summary, CSV matrix, CSV per-type stats, full bootstrap
|
|
130
|
+
distribution, and a Markdown report). Regenerate with one command:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python case_study/run_case_study.py
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Headline result on the bundled data: nominal kappa = 0.8653, BCa 95% CI = (0.6856, 1.0000),
|
|
137
|
+
pre-registration gate PASSES at the 0.70 threshold.
|
|
138
|
+
|
|
139
|
+
## Headless example
|
|
140
|
+
|
|
141
|
+
A non-interactive demo runs the three core functions on 30 pre-labelled distractors in under a second. No API key, no display:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python examples/demo.py
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
It prints kappa, the full confusion matrix, per-category agreement, and a PASS / HOLD verdict against the 0.70 gate. Swap in your own paired labels by replacing `sample_data/example_labels.csv`.
|
|
148
|
+
|
|
149
|
+
## Tests
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pip install -e ".[dev]"
|
|
153
|
+
pytest tests/ -v
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
55 tests, runs in under a second. Covers the kappa formula (with hand-verified worked examples), weighted kappa (nominal / linear / quadratic), bootstrap confidence intervals (percentile + BCa, seedable), custom-taxonomy loading, the confusion matrix, and the mathematical invariants that tie everything together. Doesn't need an API key or a display.
|
|
157
|
+
|
|
158
|
+
## Advanced features
|
|
159
|
+
|
|
160
|
+
All three are stdlib-only and tested.
|
|
161
|
+
|
|
162
|
+
**Weighted kappa for ordinal taxonomies.** Pass `weights="linear"` or
|
|
163
|
+
`weights="quadratic"` to penalise far-apart disagreements more than adjacent ones:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from confusion_mapper import compute_cohens_kappa
|
|
167
|
+
r = compute_cohens_kappa(human, ai, weights="linear")
|
|
168
|
+
print(r["kappa"], r["weights"])
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Bootstrap 95% confidence interval (BCa or percentile).** Cohen's kappa is a point
|
|
172
|
+
estimate; this gives you uncertainty around it. The `seed` makes the interval
|
|
173
|
+
bit-identically reproducible:
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from confusion_mapper import bootstrap_kappa_ci
|
|
177
|
+
ci = bootstrap_kappa_ci(human, ai, n_resamples=10000, method="bca", seed=42)
|
|
178
|
+
print(f"kappa = {ci['point_estimate']} (95% CI {ci['ci_lower']} to {ci['ci_upper']})")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Custom taxonomy via JSON.** Swap the default CFI categories for any 2-or-more
|
|
182
|
+
category nominal scheme. A working example sits at
|
|
183
|
+
`sample_data/custom_taxonomy.json`:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from confusion_mapper import load_taxonomy_from_json, compute_cohens_kappa
|
|
187
|
+
codes, tax = load_taxonomy_from_json("sample_data/custom_taxonomy.json")
|
|
188
|
+
r = compute_cohens_kappa(human, ai, categories=codes)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Why a 4x4 confusion matrix instead of just kappa
|
|
192
|
+
|
|
193
|
+
The single kappa number tells you how much you and the AI agree overall. It does not tell you which category boundary is causing the disagreement. CF vs INT is the hardest distinction in the CFI taxonomy (a confident wrong belief looks a lot like a correct answer applied to the wrong topic), and the [CF, INT] cell of the confusion matrix is where most disagreement tends to land. Looking at the full 4x4 matrix lets you see exactly that, and rewrite the AI prompt or your own rubric until the cell stops glowing.
|
|
194
|
+
|
|
195
|
+
## A note on ethics
|
|
196
|
+
|
|
197
|
+
The AI rater is a starting point, not a substitute for a second human. For published research you should still run kappa between two trained human raters on the same calibration set. Treat the AI labels as a way to surface boundaries that need rubric work, not as a replacement for human judgment.
|
|
198
|
+
|
|
199
|
+
## How to cite
|
|
200
|
+
|
|
201
|
+
Archived release on Zenodo: https://doi.org/10.5281/zenodo.20807432
|
|
202
|
+
|
|
203
|
+
APA:
|
|
204
|
+
|
|
205
|
+
> Maurya, M. (2026). *ConfusionMapper: A Python Tool for AI-Assisted Distractor Classification and Inter-Rater Reliability Computation in Cognitive Error Taxonomy Research* (Version 1.0.0) [Software]. Zenodo. https://doi.org/10.5281/zenodo.20807432
|
|
206
|
+
|
|
207
|
+
BibTeX:
|
|
208
|
+
|
|
209
|
+
```bibtex
|
|
210
|
+
@software{maurya2026confusionmapper,
|
|
211
|
+
author = {Maurya, Manik},
|
|
212
|
+
title = {ConfusionMapper: A Python Tool for AI-Assisted Distractor Classification
|
|
213
|
+
and Inter-Rater Reliability Computation in Cognitive Error Taxonomy Research},
|
|
214
|
+
year = {2026},
|
|
215
|
+
version = {1.0.0},
|
|
216
|
+
doi = {10.5281/zenodo.20807432},
|
|
217
|
+
url = {https://doi.org/10.5281/zenodo.20807432}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Contributing
|
|
222
|
+
|
|
223
|
+
Bug reports, feature requests, and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
|
|
224
|
+
|
|
225
|
+
## Acknowledgements
|
|
226
|
+
|
|
227
|
+
Initial development was completed as part of Stanford Code in Place 2026. The tool is used in the Confusion Fingerprint Index research programme at the Department of Cognitive Science, IIT Kanpur.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT License © 2026 Manik Maurya. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
confusion_mapper.py,sha256=Un1VnxlnQtAjp5ntvxabzeKcOHEdBRenKvZLMI0BWlk,57987
|
|
2
|
+
confusion_mapper-1.0.0.dist-info/licenses/LICENSE,sha256=bOR2g4PGKUQ2UGHVJh4PqxcYZisd4V6lS0N96XSgdeY,177
|
|
3
|
+
confusion_mapper-1.0.0.dist-info/METADATA,sha256=hIHLL3DYs-w2r_6YVK1heMHELWXJmyfqwBqZ7cBFQE8,10318
|
|
4
|
+
confusion_mapper-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
confusion_mapper-1.0.0.dist-info/entry_points.txt,sha256=lPkQiGvcb9oWNBzRJD_Lx4of_m-aWX7Fcr0s319t7-w,59
|
|
6
|
+
confusion_mapper-1.0.0.dist-info/top_level.txt,sha256=HnRr0UFrCj2af0gfDzhA1HyOlcTY234juG9489dnhcc,17
|
|
7
|
+
confusion_mapper-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
confusion_mapper
|