# Classifier Metrics API
> Classifier-evaluation maths as an API, computed locally and deterministically. The confusion endpoint turns the four cells of a binary confusion matrix — true and false positives and negatives — into the full metric suite: accuracy, precision, recall (sensitivity), specificity, the F1 score, the Matthews correlation coefficient (robust to class imbalance), balanced accuracy, negative predictive value, the false-positive and false-negative rates and the prevalence. The diagnostic endpoint applies Bayes' theorem to a medical or screening test: from its sensitivity, specificity and the prevalence (pre-test probability) it gives the positive and negative predictive values, the positive and negative likelihood ratios and the diagnostic odds ratio. The fbeta endpoint computes the Fβ score from precision and recall (or from the raw counts) for any β — β = 1 is F1, larger β weights recall, smaller β weights precision. Metrics whose denominator is zero are returned as null rather than erroring. Everything is computed locally and deterministically, so it is instant and private. Ideal for machine-learning, data-science, medical-testing and analytics app developers, model-evaluation and screening tools, and statistics education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is classifier evaluation; for descriptive statistics and regression use a statistics API and for hypothesis tests an inference API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/classifier-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($18/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($59/Mo) — 1,500,000 calls/Mo, 40 req/s

## Endpoints

### Classifier

#### `GET /v1/confusion` — Confusion-matrix metrics

**Parameters:**
- `tp` (query, required, string) — True positives Example: `90`
- `fp` (query, required, string) — False positives Example: `10`
- `fn` (query, required, string) — False negatives Example: `5`
- `tn` (query, required, string) — True negatives Example: `95`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/classifier-api/v1/confusion?tp=90&fp=10&fn=5&tn=95"
```

**Response:**
```json
{
    "data": {
        "mcc": 0.851064,
        "npv": 0.95,
        "note": "From a binary confusion matrix. MCC (Matthews correlation, −1…1) is robust to class imbalance.",
        "inputs": {
            "fn": 5,
            "fp": 10,
            "tn": 95,
            "tp": 90,
            "total": 200
        },
        "recall": 0.947368,
        "accuracy": 0.925,
        "f1_score": 0.923077,
        "precision": 0.9,
        "prevalence": 0.475,
        "sensitivity": 0.947368,
        "specificity": 0.904762,
        "balanced_accuracy": 0.926065,
        "false_negative_rate": 0.052632,
        "false_positive_rate": 0.095238
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:02.520Z",
        "request_id": "befbf95c-e77f-40fc-b03f-2073cac0138a"
    },
    "status": "ok",
    "message": "Confusion metrics",
    "success": true
}
```

#### `GET /v1/diagnostic` — Diagnostic test

**Parameters:**
- `sensitivity` (query, required, string) — Sensitivity (0–1) Example: `0.95`
- `specificity` (query, required, string) — Specificity (0–1) Example: `0.90`
- `prevalence` (query, required, string) — Prevalence / pre-test probability (0–1) Example: `0.01`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/classifier-api/v1/diagnostic?sensitivity=0.95&specificity=0.90&prevalence=0.01"
```

**Response:**
```json
{
    "data": {
        "npv": 0.999439,
        "ppv": 0.087558,
        "note": "Bayesian PPV/NPV combine the test's sensitivity/specificity with the prevalence (pre-test probability). LR+ = sens/(1−spec).",
        "inputs": {
            "prevalence": 0.01,
            "sensitivity": 0.95,
            "specificity": 0.9
        },
        "diagnostic_odds_ratio": 171,
        "likelihood_ratio_negative": 0.055556,
        "likelihood_ratio_positive": 9.5
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:02.607Z",
        "request_id": "7bb04f2e-9255-4a0f-a2d0-c40eeb1e85d0"
    },
    "status": "ok",
    "message": "Diagnostic test",
    "success": true
}
```

#### `GET /v1/fbeta` — F-beta score

**Parameters:**
- `precision` (query, optional, string) — Precision (0–1) Example: `0.9`
- `recall` (query, optional, string) — Recall (0–1) Example: `0.947`
- `tp` (query, optional, string) — Or true positives
- `fp` (query, optional, string) — False positives
- `fn` (query, optional, string) — False negatives
- `beta` (query, optional, string) — Beta (1 = F1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/classifier-api/v1/fbeta?precision=0.9&recall=0.947&beta=1"
```

**Response:**
```json
{
    "data": {
        "note": "Fβ = (1+β²)·P·R / (β²·P + R). β = 1 is the F1 score; β > 1 weights recall, β < 1 weights precision.",
        "inputs": {
            "beta": 1,
            "recall": 0.947,
            "precision": 0.9
        },
        "fbeta_score": 0.922902
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:02.691Z",
        "request_id": "02505d3c-9447-4a49-9f73-bd9dee3bad2a"
    },
    "status": "ok",
    "message": "F-beta",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/classifier-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "Counts are non-negative integers; rates and probabilities are 0–1. Metrics with a zero denominator are returned as null.",
        "service": "classifier-api",
        "formulae": {
            "f1": "2·P·R/(P+R)",
            "mcc": "(TP·TN − FP·FN)/√((TP+FP)(TP+FN)(TN+FP)(TN+FN))",
            "ppv": "(sens·prev)/(sens·prev + (1−spec)(1−prev))",
            "recall": "TP/(TP+FN)",
            "precision": "TP/(TP+FP)"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/fbeta": "F-beta score from precision & recall (or tp/fp/fn) for any beta.",
            "GET /v1/confusion": "Accuracy, precision, recall, F1, MCC and more from tp/fp/fn/tn.",
            "GET /v1/diagnostic": "PPV, NPV and likelihood ratios from sensitivity, specificity and prevalence."
        },
        "description": "Classifier-evaluation metrics: a full metric suite from a confusion matrix, Bayesian diagnostic-test statistics (PPV/NPV, likelihood ratios), and the F-beta score."
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:02.760Z",
        "request_id": "d0e26edb-baa4-4c53-8da7-649522f850b6"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/classifier-api
OpenAPI spec: https://www.oanor.com/api/classifier-api/openapi.json
