{"uid":"cap_n4lJ4tPaaLbX0ubcSSbVS","slug":"machine-learning-metrics-roc-curve-and-auc-4de827ff","name":"Machine Learning Metrics: ROC Curve and AUC","description":"ROC curve points and AUC from binary labels and scores via the Mann-Whitney rank-sum identity, with ties counted half.","url":"https://ml-metrics.x402tookit.com/roc-auc?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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), same length as labels"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"auc":{"type":["null","number"]},"asOf":{"type":["null","string"]},"gini":{"type":["null","number"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"negatives":{"type":["null","number"]},"positives":{"type":["null","number"]},"rocPoints":{"type":["array","null"],"items":{"type":"object","properties":{"fpr":{"type":["null","number"]},"tpr":{"type":["null","number"]},"threshold":{"type":["null","number"]}}}},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"aucTrapezoid":{"type":["null","number"]},"rocPointsTruncated":{"type":["boolean","null"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_USQ3FNF7fLx04-10i9rxG","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes ROC curve points and AUC from binary labels and model scores using the Mann-Whitney rank-sum identity, with tie-handling.","exampleAgentPrompt":"Can you compute the ROC curve and AUC for my binary classifier? The true labels are 0,1,1,0,1,0,0,1 and the model scores are 0.1,0.9,0.8,0.2,0.75,0.3,0.4,0.85.","exampleUseCases":[{"title":"Evaluating fraud detection model","prompt":"I just trained a fraud detection model and I want to know how well it ranks fraudulent vs legitimate transactions — here are the true labels: 0,0,1,0,1,1,0,1 and the predicted scores: 0.05,0.2,0.85,0.1,0.9,0.78,0.15,0.88. Can you give me the ROC curve points and AUC?"},{"title":"Comparing two classifier outputs","prompt":"I have two sets of predictions for the same test set with labels 1,0,1,1,0,0,1,0,1,0 — can you compute the ROC AUC for scores 0.9,0.1,0.8,0.7,0.3,0.2,0.85,0.15,0.75,0.25 so I can benchmark against my baseline?"},{"title":"Checking clinical risk score performance","prompt":"We built a clinical risk score to predict hospital readmission and I need to see the full ROC curve and AUC — the true readmission labels are 1,0,0,1,1,0,1,0 and the risk scores are 0.82,0.1,0.23,0.77,0.91,0.18,0.68,0.35."}],"resultDescription":"Returns an array of ROC curve points each with false positive rate (FPR), true positive rate (TPR), and threshold; the AUC value via Mann-Whitney rank-sum; a trapezoid AUC; Gini coefficient; counts of positives and negatives; a summary string; a verdict; and optionally a degraded flag and disclaimer if the result is approximate or the curve was truncated.","failureModes":["Labels and scores arrays have different lengths — returns an error","Non-binary labels (values other than 0/1) cause a validation failure","Empty or malformed input arrays fail to parse","All labels are the same class (all 0 or all 1) — AUC is undefined, may return null","Very large inputs (over 10000 values) are rejected","URL encoding issues with comma-separated values in query params"],"whenToPreferThis":"Choose this endpoint when you need AUC and the full ROC curve for a binary classifier, especially when tie-handling via the Mann-Whitney rank-sum identity matters for correctness. Prefer it over precision-recall endpoints when the task is ranking/discrimination evaluation rather than threshold-specific performance. Use it when you need both the curve coordinates (for plotting) and the scalar AUC in one call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-02T12:31:13.552Z","isFirstParty":false,"canonicalSlug":"machine-learning-metrics-roc-curve-and-auc-4de827ff"}