payoff
Decide whether an AI system is worth using, and how much of its output people should check.
Most AI work is funded on a model metric (accuracy, F1, AUC) and a business
case that assumes the model does all the work. Neither says whether the
system is worth having: the model, the cut-off someone chose, the people who
check some of its output, and the capacity they have. payoff prices every
outcome of that system, finds the best share of work to send to people, and
shows which uncertain inputs are worth measuring before you decide.
The name is the decision-theory term. Every way a decision can turn out has a payoff, and the best design is the one with the highest expected payoff once the model's errors, the reviewers' time, and the build are all counted.
It is the code companion to two articles:
- Is It Possible, and Is It Worth It? covers what to do with the costs and benefits.
- Where the Numbers Come From covers how to get them.
The same calculations are in a workbook for readers who prefer a spreadsheet. The tests check that this package and the workbook give the same numbers.
Install
With uv:
uv add payoff
or with pip: pip install payoff.
Python 3.10 or later. No runtime dependencies.
Quick start
import payoff
# A refund team: 100,000 requests a year, dollars per request.
hourly = 50.0 # loaded cost per hour of a support rep
params = payoff.Params(
value=10.0, # a correct decision is worth what it costs to make today
error_cost=50.0, # a wrong decision that reaches a customer
hand_cost=payoff.cost_of_minutes(12, hourly),
confirm_cost=payoff.cost_of_minutes(3, hourly),
fix_cost=payoff.cost_of_minutes(6, hourly),
accuracy=0.80,
separation=1.5,
catch_rate=0.90,
overturn_rate=0.02,
capacity=0.40,
run_cost=0.50,
)
best = payoff.best_within_capacity(params)
best.share_reviewed # 0.40: check 40% of requests
payoff.advantage(params) # 4.81: dollars saved per request versus today
payoff.payback_months(200_000, payoff.advantage(params) * 100_000) # 5.0
examples/quickstart.py adds sensitivity, simulation, and the value of
measuring each input:
$ uv run python examples/quickstart.py
Check 40% of items.
Advantage over doing it by hand: $4.81 per item,
$480,911 per year.
Pays back the build 5.0 months after launch, 9.0 after funding.
One more point of capacity is worth $4,375 per year.
What to measure first (advantage per year, low to high):
error_cost $646,782 to -$348,443 <- can change the answer
hand_cost $230,911 to $730,911
...
Beats the current process in 66% of 2,000 draws.
Knowing error_cost exactly is worth about $71,054 per year.
What it answers
| Question | Function |
|---|---|
| What is each design worth per item? | expected_value_by_hand, expected_value_full_automation, expected_value_review_all, evaluate |
| What accuracy does each design need? | break_even_accuracy_full_automation, break_even_accuracy_review_all |
| What share should people check, given their capacity? | best_within_capacity, advantage |
| What is more review capacity worth? | capacity_value |
| When does the build pay back, and what is it worth over its life? | payback_months, net_value |
| Which inputs could change the answer? | Range, sensitivity |
| How likely is the system to beat the current process? | simulate |
| Which measurement is worth paying for? | value_of_information |
| What are reviewers' catch and overturn rates? | beta_posterior_mean, wilson_interval, seeded_errors_needed |
| What error rate do the edits imply? | implied_error_rate |
| The numbers say no: proceed, wait, or stop? | decide |
Every public function has a docstring with its arguments and return value.
The model
Each item gets a confidence score. Items at or above a cut-off go straight through; the rest go to a person, up to the review capacity. A person confirms a correct draft, fixes a wrong one they catch, misses the rest, and now and then changes a correct draft into a wrong one.
| Input | Meaning |
|---|---|
value |
Value of one correct result |
error_cost |
Cost of an error that gets through, on top of the value lost |
hand_cost |
Cost of doing one item from scratch |
confirm_cost, fix_cost |
Cost of confirming a correct draft, fixing a wrong one |
accuracy |
Share of outputs that are right |
separation |
How well the score tells right from wrong, in standard deviations |
catch_rate |
Share of wrong drafts people catch |
overturn_rate |
Share of correct drafts people change to wrong |
capacity |
Share of items people can check |
run_cost |
Cost of running the system, per item |
Money inputs can be in any one unit. The articles, the workbook, and these
examples use dollars, with a refund team as the running example. Setting
value=1 instead measures everything relative to the value of a correct
result, which is handy for comparing very different systems.
Assumptions, stated so you can judge whether they fit:
- Scores are normal with unit variance: mean
separationfor correct outputs, mean 0 for wrong ones. Calibrate against your own score distributions before relying on the routing result. - One error cost per item. Systems with several kinds of error should price them separately and use a weighted average, or extend the model.
- Reviewers' catch and overturn rates do not depend on the cut-off. In practice they move when the review queue changes; the articles explain how to measure them per queue.
How it matches the workbook
best_within_capacity searches a grid of cut-offs and then checks the
cut-off that fills capacity exactly, found by bisection. The workbook does the
same with formulas (201 cut-offs, 60 bisection steps).
tests/test_workbook.py reads the workbook's computed values and recomputes
each one from its inputs.
Project layout
src/payoff/
model.py outcomes, routing, break-even, capacity value, payback
measure.py ranges, sensitivity, simulation, reviewer statistics
discretion.py proceed, wait, or stop
tests/
test_model.py properties that hold for any inputs
test_measure.py measurement helpers
test_workbook.py parity with the published workbook
test_repo.py every text file is plain ASCII
data/payoff-workbook.xlsx
examples/quickstart.py
Development
uv sync # creates .venv from uv.lock
uv run pytest # tests
uv run ruff check # lint (Google docstring convention)
uv run ruff format --check # formatting
uv run mypy # strict type checks
CI runs all four on Python 3.10 to 3.13. Releases go to PyPI from a version tag; see RELEASING.md.
Design choices
- No runtime dependencies. The math needs only the standard library, so there is nothing to audit or pin for users.
- Frozen dataclasses with validation. Bad inputs fail when they are created, with a message naming the field.
- Repeatable randomness.
simulatetakes a seed and defaults to 0. - Plain text. A test keeps every text file ASCII, so nothing renders differently from one terminal or editor to the next.
Roadmap
The articles climb a ladder, and the package will follow it:
- A classic model: two kinds of error, thresholds from costs, ranking under fixed capacity.
- Extraction: many fields per document and many documents per case, where correctness compounds.
- AI agents: a sequence of steps that take actions, with approval at irreversible ones.
- Several AI agents: handoffs, and AI agents checking each other.
Citing
See CITATION.cff, or use GitHub's "Cite this repository" button.
License
MIT. See LICENSE.
Metadata
Release files for payoff 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| payoff-0.1.0.tar.gz | 187.7 kB | Without provenance | Details for payoff-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| payoff-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for payoff-0.1.0-py3-none-any.whl |
Total release size: 201.3 kB
Release files / payoff-0.1.0.tar.gz
| Download URL | payoff-0.1.0.tar.gz |
|---|---|
| Size | 187.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6e809bd85bd9f2c5ee11d4d9baa8faf29ee90f683a621a5d730de32faf0fa3a
|
|
BLAKE2b-256 checksum How to use checksums |
a5fb012aeab059229c9b71f87c166a244ec1a5f5063725d85acc3f338b508dc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / payoff-0.1.0-py3-none-any.whl
| Download URL | payoff-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
967f1b16065f55fac369e22458e9e3a3ae1f01c6bf68e1c3dce491108a1d4cd3
|
|
BLAKE2b-256 checksum How to use checksums |
b36c3af2ad8cc9d0dc13dc2b1de06a2b18fe41590b479d6ab7949a603e529dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for payoff 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.