AI & Machine Learning calculator

Confusion matrix, Precision, Recall, and F1 calculator

Calculate classification performance metrics including Accuracy, Precision, Recall (Sensitivity), Specificity, F1-Score, F-beta, and Matthews Correlation Coefficient (MCC).

Run this test live in StatLab npm i @statlab/core

When to use it

Use when evaluating binary or multi-class classifier model performance.

Required Inputs

  • True Positives (TP)
  • False Positives (FP)
  • True Negatives (TN)
  • False Negatives (FN)

Mathematical Formula

Precision = TP/(TP+FP), Recall = TP/(TP+FN), F1 = 2*P*R/(P+R), MCC = (TP*TN - FP*FN)/√((TP+FP)(TP+FN)(TN+FP)(TN+FN))

Reporting Cautions

  • Do not rely solely on Accuracy when class distributions are severely imbalanced.
  • MCC provides a reliable single-number metric even under extreme class imbalance.

Code Snippets (Python, R, TypeScript)

Python (SciPy / Statsmodels)
from sklearn.metrics import classification_report, matthews_corrcoef
# Compute precision, recall, f1-score, and MCC
R Language
library(caret)
confusionMatrix(factor(preds), factor(actuals))
TypeScript (@statlab/core)
import { confusionMetrics } from '@statlab/core';
const m = confusionMetrics({ tp: 450, fp: 50, fn: 100, tn: 1400 });

Developer Use Cases & Production Integrations

  • Evaluating classification model precision/recall tradeoffs in VoxelAssurance AI quality sprints.
  • Benchmarking automated moderation and anomaly detection classifiers.

VoxelPulse Telemetry Control Plane

Continuous A/B testing, statistical telemetry analysis, and automated feedback loops for live backend services.

Explore VoxelPulse →

VoxelAssurance Release Readiness

Fixed-price AI release-readiness sprints, automated regression testing, and reliability statistical benchmarks.

Explore VoxelAssurance →

Related Statistical Test Calculators

Explore static calculators across the StatLab inference engine suite.