ForHosting KIT · Math

Matthews correlation (MCC)

With 50 true positives, 40 true negatives, 5 false positives and 5 false negatives, the Matthews correlation coefficient is 0.79798. Enter the four counts of your confusion matrix and get one balanced score for a yes-or-no classifier. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Tp
50
Tn
40
Fp
5
Fn
5
Decimal places
6
You get
Mcc
0.79798

MCC from TP/TN/FP/FN confusion counts. Search intent: matthews correlation coefficient calculator. No network calls or random seeds are required. Failed jobs are not billed.

Four counts, one score

A binary classifier sorts each case into yes or no, and comparing its calls with the truth gives four counts. True positives are the yes cases it caught, true negatives the no cases it cleared, false positives the no cases it wrongly flagged and false negatives the yes cases it missed. The Matthews correlation coefficient folds all four into one number. Multiply the true positives by the true negatives, subtract the false positives times the false negatives, and divide by the square root of the product of the four sums. With 50, 40, 5 and 5 the score is 0.79798.

Reading the result and rounding it

Because the formula uses every cell of the confusion matrix, both kinds of mistake, false positives and false negatives, weigh on the result. The coefficient behaves like a correlation between predictions and reality and runs from −1 to 1: the closer to 1, the better they agree. If you ask for a number of decimals, the raw value is rounded half-up once, at the end, so no error builds up. The four counts are shown next to the score, which makes it easy to confirm that the right figures went in.

Teaching

Pinned goldens.

What do I need to calculate the Matthews correlation coefficient?

Only the four counts of a confusion matrix: true positives, true negatives, false positives and false negatives. You do not need the individual predictions, just how many cases fell into each cell.

What is the formula for MCC?

Multiply TP by TN, subtract FP times FN, then divide by the square root of (TP+FP)(TP+FN)(TN+FP)(TN+FN). The calculator applies that formula directly to the counts you enter.

How is MCC different from an ordinary correlation coefficient?

An ordinary correlation compares two lists of paired measurements. MCC starts instead from the four counts of a yes-or-no classification, so it measures how well the predicted labels agree with the true ones.

Does the calculator round the result?

Only when you choose a number of decimals. The unrounded result is then rounded half-up exactly once, at the end, so small rounding errors never pile up between steps.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/matthews-corr

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/matthews-corr \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tp":50,"tn":40,"fp":5,"fn":5}'
{
  "tp": 50,
  "tn": 40,
  "fp": 5,
  "fn": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.matthews_corr",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

How it works

MCC from TP/TN/FP/FN confusion counts. MCC=(TP·TN−FP·FN)/√((TP+FP)(TP+FN)(TN+FP)(TN+FN)). No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

Inputs, limits and rounding

Optional decimals use half-up once. Outputs echo inputs. No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. Provide required JSON fields. Invalid types raise invalid_input. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

When to use it

Use when search intent matches. MCC from TP/TN/FP/FN confusion counts. No network calls or random seeds are required. Failed jobs are not billed. No network calls or random seeds are required. Failed jobs are not billed. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos. The calculator is free in the browser, deterministic, and identical on the API path. Inputs are validated before arithmetic so invalid payloads fail with invalid_input. Half-up rounding is applied once from raw IEEE values when decimals are requested. Use the same JSON from spreadsheets, CMS, automation, or teaching demos.

Quick check

Free widget.

Automation

Same JSON via API.

Free?

Yes tier A.

Network?

No.

Bad input?

invalid_input.

API?

Yes.

Locales?

EN-only; Nitro hydrates.

Read the full KIT documentation →