# Diagnostic accuracy calculator

- Human page: https://happytails.ai/en/calculators/diagnostic-accuracy-calculator/
- Markdown: https://happytails.ai/en/calculators/diagnostic-accuracy-calculator.md
- Structured JSON: https://happytails.ai/agents/en/calculators/diagnostic-accuracy-calculator/index.json
- Visibility: public

## Tool capabilities

| Property | Value |
| --- | --- |
| Tool ID | `diagnostic-accuracy-calculator` |
| Category | calculators |
| Implementation | Registered implementation. Registration alone is not a production-quality guarantee. |
| Browser execution | Use the visible action or interactive controls. |
| Browser processing | Browser; see tool notes for network behavior. |
| HTTP API | Not callable through HTTP. |
| Browser-agent interface | run_current_tool |

### Implementation notes

Runs on your device. Enter confusion counts or up to 1,000,000 characters of labelled CSV. Results describe the supplied data and are not clinical advice.

### Inputs and settings

No free-text input is required. Use the file inputs and/or settings below.

| Setting | Meaning | Control type | Default | Constraints |
| --- | --- | --- | --- | --- |
| `data` | Data | select | "counts" | Allowed: counts, labels |
| `tp` | True positives | text | "90" |  |
| `fp` | False positives | text | "15" |  |
| `fn` | False negatives | text | "10" |  |
| `tn` | True negatives | text | "185" |  |
| `csv` | Labelled CSV | textarea | "actual,predicted\npositive,positive\npositive,negative\nnegative,negative\nnegative,positive\nnegative,negative" |  |
| `positiveLabel` | Positive label | text | "positive" |  |
| `prevalence` | Declared prevalence (optional) | text | "0.05" |  |
| `interval` | Interval method | select | "wilson" | Allowed: wilson, clopper-pearson |
| `confidence` | Confidence level | text | "0.95" |  |

### Browser-agent workflow

1. Open the human page in a browser that supports WebMCP.
2. Discover the interface exposed by that page; use its actual schema.
3. Select files on the page first when the tool requires files.
4. Call `run_current_tool` with valid input and settings.
5. Inspect the returned result or error and the displayed output. Retrieve files from the displayed download links.

Calls do not automatically copy or download results. Browser permissions still apply. Interface availability alone is not proof of successful execution.

### Planning specification

Runs locally in your browser; nothing is uploaded. Counts are whole numbers from 0 to 2,500,000 with at least one actual positive and one actual negative. Labelled CSV uses the headers actual and predicted, no blank cells and exactly two labels that match exactly, including capital letters and spaces, up to 10,000 rows and 1,000,000 characters. Declared prevalence is strictly between 0 and 1. Downloads: a JSON report plus CSV metrics and confusion tables.

This describes intended requirements. Use the implementation notes, interface schema and observed output to determine current support.

### Complete machine-readable capability record

```json
{
  "id": "diagnostic-accuracy-calculator",
  "category": "calculators",
  "built": true,
  "requirements": "Runs locally in your browser; nothing is uploaded. Counts are whole numbers from 0 to 2,500,000 with at least one actual positive and one actual negative. Labelled CSV uses the headers actual and predicted, no blank cells and exactly two labels that match exactly, including capital letters and spaces, up to 10,000 rows and 1,000,000 characters. Declared prevalence is strictly between 0 and 1. Downloads: a JSON report plus CSV metrics and confusion tables.",
  "implementation": {
    "fields": [
      {
        "key": "data",
        "label": "Data",
        "value": "counts",
        "type": "select",
        "values": [
          "counts",
          "labels"
        ],
        "labels": {
          "counts": "Confusion counts",
          "labels": "Labelled CSV rows"
        }
      },
      {
        "key": "tp",
        "label": "True positives",
        "value": "90",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of zero or more.",
        "showWhen": {
          "data": [
            "counts"
          ]
        }
      },
      {
        "key": "fp",
        "label": "False positives",
        "value": "15",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of zero or more.",
        "showWhen": {
          "data": [
            "counts"
          ]
        }
      },
      {
        "key": "fn",
        "label": "False negatives",
        "value": "10",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of zero or more.",
        "showWhen": {
          "data": [
            "counts"
          ]
        }
      },
      {
        "key": "tn",
        "label": "True negatives",
        "value": "185",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of zero or more.",
        "showWhen": {
          "data": [
            "counts"
          ]
        }
      },
      {
        "key": "csv",
        "label": "Labelled CSV",
        "value": "actual,predicted\npositive,positive\npositive,negative\nnegative,negative\nnegative,positive\nnegative,negative",
        "type": "textarea",
        "maxLength": 1000000,
        "help": "Headers actual and predicted, one case per row, exactly two labels in total. Up to 10,000 rows and 1,000,000 characters.",
        "showWhen": {
          "data": [
            "labels"
          ]
        }
      },
      {
        "key": "positiveLabel",
        "label": "Positive label",
        "value": "positive",
        "type": "text",
        "maxLength": 80,
        "help": "The exact label that means the condition is present.",
        "showWhen": {
          "data": [
            "labels"
          ]
        }
      },
      {
        "key": "prevalence",
        "label": "Declared prevalence (optional)",
        "value": "0.05",
        "type": "text",
        "maxLength": 40,
        "help": "A proportion between 0 and 1 for predictive values in another population. Leave blank to use only the sample."
      },
      {
        "key": "interval",
        "label": "Interval method",
        "value": "wilson",
        "type": "select",
        "values": [
          "wilson",
          "clopper-pearson"
        ],
        "labels": {
          "wilson": "Wilson score",
          "clopper-pearson": "Clopper-Pearson exact"
        }
      },
      {
        "key": "confidence",
        "label": "Confidence level",
        "value": "0.95",
        "type": "text",
        "maxLength": 40,
        "help": "A proportion from 0.5 to 0.9999, for example 0.95."
      }
    ],
    "registrationFamily": "statistical-analysis-reference",
    "input": false,
    "note": "Runs on your device. Enter confusion counts or up to 1,000,000 characters of labelled CSV. Results describe the supplied data and are not clinical advice.",
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 1000000,
      "inputMode": "text",
      "label": "Confusion counts",
      "placeholder": "Enter counts in the form fields",
      "help": "Use the fields for counts, or choose Labelled CSV rows to paste data. Up to 1,000,000 characters. Review the settings before running.",
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}
```

## Page guide

Compute sensitivity, specificity, predictive values, likelihood ratios and other accuracy metrics with confidence intervals from a confusion matrix or labelled rows. It describes test performance on your data and gives no clinical advice.

How can we improve this tool?

Report a problem or share an idea.

Please leave out private information. Your message and the tool name go to our team via PostHog.

### How to use Diagnostic accuracy calculator

1. Enter the four confusion counts, or switch to labelled CSV rows with actual and predicted columns.
2. Optionally enter a declared prevalence to see predictive values for another population.
3. Choose Wilson or Clopper-Pearson intervals and the confidence level.
4. Calculate and download the JSON report or the CSV metrics table.

## Useful next steps

- [Confidence interval calculator](https://happytails.ai/en/calculators/confidence-interval-calculator/) ([Markdown](https://happytails.ai/en/calculators/confidence-interval-calculator.md))

- [Agreement analysis](https://happytails.ai/en/calculators/agreement-analysis/) ([Markdown](https://happytails.ai/en/calculators/agreement-analysis.md))

- [Probability calculator](https://happytails.ai/en/calculators/probability-calculator/) ([Markdown](https://happytails.ai/en/calculators/probability-calculator.md))

## What is computed

Sensitivity, specificity, PPV, NPV, accuracy and sample prevalence are proportions with Wilson score intervals (Wilson 1927, JASA 22:209) or Clopper-Pearson exact intervals (Clopper and Pearson 1934, Biometrika 26:404). Likelihood ratios use log intervals (Simel, Samsa and Matchar 1991, J Clin Epidemiol 44:763). Balanced accuracy, F1, Youden J, the diagnostic odds ratio and the Matthews correlation (Matthews 1975) are point estimates.

### Prevalence changes predictive values

PPV and NPV from the table use the sample prevalence. If you declare a prevalence, the tool also reports predictive values from Bayes' rule with your sensitivity and specificity, which is how a test behaves where the condition is more or less common. No interval is given for those adjusted values.

### Limits

A ratio with a zero denominator is reported as not defined. A likelihood ratio interval is also not defined when the ratio is 0, or when sensitivity and specificity are both 0 or 1 (its log standard error is then zero). Results describe the supplied cases only; they are not clinical advice and do not interpret any patient's result.
