Classification metrics compute
classification-metrics-compute · version 1.0.0 · Numbers & math · free, no key needed
Compute exact binary-classification metrics from integer confusion-matrix counts as reduced fractions or null.
Use when you need to: compute binary classification metrics · confusion matrix precision recall and f1 · exact accuracy from tp fp tn fn.
Decide before calling
Read the versioned contract and the supported scope below. Reuse classification-metrics-compute@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use classification-metrics-compute@1.0.0 for compute binary classification metrics. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- compute binary classification metrics
- confusion matrix precision recall and f1
- exact accuracy from tp fp tn fn
- calculate sensitivity and specificity
- negative predictive value from counts
- balanced accuracy as a fraction
- classification prevalence from confusion matrix
Not supported
- multiclass confusion matrices
- confidence intervals or hypothesis tests
- threshold selection or ROC curves
Behavior
- Counts tp, fp, tn and fn are required non-negative integers at most 1000000000.
- Metrics use standard confusion-matrix definitions and return reduced n/d strings; an exactly zero numerator is 0/1.
- A metric with a zero denominator is null; the all-zero matrix is valid and makes every metric null.
- balanced_accuracy is the exact arithmetic mean of recall and specificity and is null if either component is undefined.
- No decimal approximation or rounding occurs; output field order is fixed and input is not mutated.
Input
tp(integer, required): min 0; max 1000000000fp(integer, required): min 0; max 1000000000tn(integer, required): min 0; max 1000000000fn(integer, required): min 0; max 1000000000
Output
total(integer, required): min 0; max 4000000000accuracy(string or null, required)precision(string or null, required)recall(string or null, required)specificity(string or null, required)f1(string or null, required)negative_predictive_value(string or null, required)prevalence(string or null, required)balanced_accuracy(string or null, required)
Limits
- max count: 1000000000
- max input bytes: 256
Example
Request input:
{
"tp": 42,
"fp": 8,
"tn": 45,
"fn": 5
}
Response:
{
"result": {
"total": 100,
"accuracy": "87/100",
"precision": "21/25",
"recall": "42/47",
"specificity": "45/53",
"f1": "84/97",
"negative_predictive_value": "9/10",
"prevalence": "47/100",
"balanced_accuracy": "4341/4982"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "classification-metrics-compute",
"version": "1.0.0",
"input": {
"tp": 42,
"fp": 8,
"tn": 45,
"fn": 5
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/classification-metrics-compute/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"tp":42,"fp":8,"tn":45,"fn":5}'
The machine-readable contract is at /v1/tools/classification-metrics-compute/versions/1.0.0.
CLI
node cli.mjs run classification-metrics-compute 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Number engineering format: Format an exact decimal in scientific or engineering notation with explicit precision and rounding.
- Rational power: Raise a rational number to an integer exponent and return the exact reduced result.
- Rational reciprocal: Invert a rational number given as a numerator/denominator integer-string pair.
- Roman numeral convert: Convert integers 1–3999 to canonical Roman numerals and strictly parse canonical numerals back to integers.
- Array integer clamp: Clamp an array of canonical integer strings to optional inclusive min and max bounds.
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.