# ML Metrics Threshold Sweep

> ML Metrics Threshold Sweep is a paid API for AI agents from ml-metrics.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-11-02).

Sweeps every score threshold for binary classification and returns the best F1, Youden J, and accuracy thresholds with full confusion matrix metrics at each point.

## Facts

- Endpoint: GET https://ml-metrics.x402tookit.com/threshold-sweep?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/ml-metrics-threshold-sweep-c56fba5d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_eTFF_JEhLHWYZTSbajkAw

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability ml-metrics-threshold-sweep-c56fba5d
```

Example prompt: Sweep all classification thresholds for my binary model and tell me the best F1, Youden J, and accuracy cutoffs — my true labels are 0,1,0,1,1,0,1,0 and my model scores are 0.1,0.9,0.2,0.8,0.75,0.3,0.85,0.4.

## When to prefer this

Choose this endpoint when you need to systematically find the optimal decision threshold for a binary classifier rather than evaluating at a single fixed threshold. It is ideal for model deployment decisions, comparing operating points (F1-optimal vs. specificity-sensitivity balanced via Youden J), or validating that a chosen threshold is truly optimal. Prefer over the confusion-matrix endpoint when you don't yet know which threshold to use, and over manual ROC analysis when you want directly actionable best-threshold recommendations.

## Known failure modes

- Mismatched array lengths between labels and scores returns an error
- Non-binary labels (values other than 0/1) cause invalid input error
- Scores outside expected range may produce degenerate thresholds
- All-positive or all-negative label sets yield undefined metrics for some thresholds
- Input exceeding 10,000 values may be rejected or truncated
- Malformed comma-separated or JSON array inputs return parse errors

## How this service works

Sweep every score threshold for binary labels and return the best F1, Youden J and accuracy thresholds with their metrics.

## Output

Returns a full threshold sweep array with TP, FP, TN, FN, precision, recall, specificity, F1, Youden J, and accuracy at every threshold, plus highlighted best-threshold objects for F1, Youden J, and accuracy. Also includes total positive and negative counts, a summary verdict, and degraded-mode flags if computation was partial.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "labels",
      "scores"
     ],
     "properties": {
      "labels": {
       "type": "string",
       "description": "True binary labels 0/1, comma-separated or JSON array, up to 10000 values"
      },
      "scores": {
       "type": "string",
       "description": "Model scores (higher = more positive); a sample is predicted positive when score >= threshold"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "sweep": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "object",
        "properties": {
         "f1": {
          "type": [
           "null",
           "number"
          ]
         },
         "fn": {
          "type": [
           "null",
           "number"
          ]
         },
         "fp": {
          "type": [
           "null",
           "number"
          ]
         },
         "tn": {
          "type": [
           "null",
           "number"
          ]
         },
         "tp": {
          "type": [
           "null",
           "number"
          ]
         },
         "recall": {
          "type": [
           "null",
           "number"
          ]
         },
         "youdenJ": {
          "type": [
           "null",
           "number"
          ]
         },
         "accuracy": {
          "type": [
           "null",
           "number"
          ]
         },
         "precision": {
          "type": [
           "null",
           "number"
          ]
         },
         "threshold": {
          "type": [
           "null",
           "number"
          ]
         },
         "specificity": {
          "type": [
           "null",
           "number"
          ]
         }
        }
       }
      },
      "bestF1": {
       "type": [
        
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/ml-metrics-threshold-sweep-c56fba5d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from ml-metrics.x402tookit.com](https://www.zero.xyz/host/ml-metrics.x402tookit.com/llms.txt)
