# Real classifiers on public banking queries

A sixth page, [text-classifier.html](text-classifier.html), replaces the simulated ticket classifier of the support metrics page
([support-metrics.html](support-metrics.html)) with working classifiers on public labelled text: a plain bag of words with logistic
regression and four language models, reported separately. It groups the 77 intents of BANKING77 into six contact drivers written
before the run, measures each classifier's confusion matrix on 100, 400 and 800 labelled messages, compares raw label shares and
corrected shares with the dataset's own shares, and shows what deleting the driver definitions from the prompt does to a driver series.

The design, with its taxonomy and eleven predictions, and the frozen protocol
([textclass/protocol.json](textclass/protocol.json)) were committed before the main run. The results rebuild from the stored labels with no
key and no network, and with only the Python standard library:

```sh
python3 -B -m textclass.analysis --verify   # rebuilds the results from the stored labels; contents must match exactly
python3 -B tests/test_text_classifier.py    # taxonomy, draws, correction, alarm rule, replay and pinned results
python3 -B -m textclass.check_page          # every number on the page, recounted or traced to a stored figure
python3 -B -m textclass.protocol_check      # every pinned file still hashes to the frozen protocol (needs the full project: the design file is not in the download)
python3 -B -m textclass.after_results --verify   # rebuilds the readings added after the results
python3 -B tests/test_text_classifier_after.py   # tests for those readings
python3 -B -m textclass.render              # rewrites the page from the results
```

What each file holds:

- `textclass/data/messages.csv.gz`: every message in the study by row number, with the dataset's intent and my driver. No message text.
- `textclass/data/responses.jsonl.gz`: batch rows and each model's answer as number and letter. No message text.
- `textclass/data/repeated-requests.jsonl.gz`: the prompt version 2 answers that came back a second time; they are set aside under the duplicate-answer rule on the page. `textclass/data/collection-notes.json` records their counts and what using them instead would change.
- `textclass/data/independent-grouping.json`: the second grouping of the 77 intents, written by an independent author who never saw mine.
- `textclass/data/example.json`: the one quoted message.
- `textclass/results/`: the summary with each prediction's verdict, the baseline's count matrices per draw, and `after-results.json`,
  the readings added after the results and declared in [DESIGN-text-classifier-followup.md](DESIGN-text-classifier-followup.md).
- `textclass/SOURCES.json`: the dataset's URLs and hashes, the terms it was checked against, and the provenance sentences.

Rebuilding the baseline needs the dataset's two CSV files (URLs and hashes in `textclass/SOURCES.json`) and scikit-learn, and no key:
`python -m textclass.baseline <folder with the CSV files>`. Results depend on the scikit-learn version; this run used 1.9.1, the version also
named in the page's method section.

The model calls themselves are not re-run by this download. Prompts, batches and answers are all here, so a reader with their own model access can repeat the calls from
`textclass/taxonomy.py` and `textclass/plan.py`.

Data credit: BANKING77 by Casanueva, Temcinas, Gerz, Henderson and Vulic, Creative Commons Attribution 4.0 International, from
https://github.com/PolyAI-LDN/task-specific-datasets. Change made: the 77 intents are grouped into six drivers; the message text is not
redistributed, apart from one quoted message on the page.

The AI agent page is described in [README-agent-resolutions.md](README-agent-resolutions.md), the service levels page in
[README-service-levels.md](README-service-levels.md), the support metrics page in [README-support-metrics.md](README-support-metrics.md), and the
main page of this study in [README.md](README.md).
