Function accuracy

Get Function Metrics

Retrieve performance metrics for functions based on labeled transformation data.

This endpoint calculates accuracy metrics by comparing function outputs against ground truth data (user corrections). Metrics help you understand function performance and identify areas for improvement.

Available Metrics

For each function, the response includes:

  • Accuracy: Overall correctness rate
  • Precision: True positives / (True positives + False positives)
  • Recall: True positives / (True positives + False negatives)
  • F1 Score: Harmonic mean of precision and recall
  • Confusion Matrix: TP, FP, TN, FN counts

Requirements

Metrics are only available for functions with:

  • Historical transformations that have been labeled/corrected
  • Sufficient sample size for meaningful calculations

Filtering

Filter by specific functions using functionIDs or functionNames, or by function type using the types parameter.

GET
/v2/functions/metrics
x-api-key<token>

Authenticate using API Key in request header

In: header

Query Parameters

limit?integer
Default50
Range1 <= value <= 100
functionIDs?array<>
Items1 <= items
functionNames?array<>
Items1 <= items
types?array<>
Items1 <= items
sortOrder?string

Specifies sorting behavior. The two options are asc and desc to sort ascending and descending respectively, with default sort being ascending. Paging works in both directions.

Default"asc"
Value in"asc" | "desc"
startingAfter?string

A cursor to use in pagination. startingAfter is a function ID that defines your place in the list.

endingBefore?string

A cursor to use in pagination. endingBefore is a function ID that defines your place in the list.

Response Body

application/json

curl -X GET "https://api.bem.ai/v2/functions/metrics"
{
  "functions": [
    {
      "functionName": "invoice-transformer",
      "totalLabeledResults": 54,
      "totalResults": 120,
      "metrics": {
        "accuracy": 0.7407,
        "precision": 0.9524,
        "recall": 0.7692,
        "f1Score": 0.8511,
        "tp": 40,
        "fp": 2,
        "tn": 0,
        "fn": 12
      }
    }
  ],
  "totalCount": 1
}