Statistical & Classification Metrics

Code-based metrics that score predicted labels or values against expected ones for classification and regression

These are code-based (CustomCodeEval) metrics: each one runs a fixed formula over the output and expected values you supply and returns a normalized 0-1 score, no LLM judge involved.

Metrics

MetricWhat it measuresRequired inputsOutput
accuracyFraction of predicted labels that exactly match expected labelsoutput, expectedscore (0-1)
balanced_accuracyAverage per-class recall, corrects for class imbalance that skews plain accuracyoutput, expectedscore (0-1)
f1_scoreToken-level overlap between output and expected text, harmonic mean of precision and recalloutput, expectedscore (0-1)
f_beta_scorePrecision/recall on a chosen positive label, weighted by beta (below 1 favors precision, above 1 favors recall)output, expected, positive_labelscore (0-1)
precision_scoreFraction of predicted-positive labels that are actually positive (TP / (TP + FP))output, expected, positive_labelscore (0-1)
cohen_kappaInter-rater agreement between predicted and expected labels, adjusted for chance agreementoutput, expectedscore (0-1), higher = better
matthews_correlationBalanced classification quality across all four confusion matrix categoriesoutput, expectedscore (0-1), higher = better
fleiss_kappaMulti-rater agreement from a rating count matrix (rows = subjects, columns = categories)output (rating matrix)score (0-1), higher = better
log_lossCross-entropy between predicted probabilities and true 0/1 labels, lower loss scores higheroutput, expectedscore (0-1), higher = better
rmseRoot mean squared error between predicted and actual numeric values, lower error scores higheroutput, expectedscore (0-1), higher = better
r2_scoreProportion of variance in the actual values explained by the predicted valuesoutput, expectedscore (0-1), higher = better
pearson_correlationStrength of the linear relationship between two numeric arraysoutput, expectedscore (0-1), higher = better
spearman_correlationStrength of the monotonic relationship between two numeric arrays, based on rank differencesoutput, expectedscore (0-1), higher = better

Run a metric from code

Call evaluate() with the template id and the metric’s required inputs. Swap the template id to run any metric in this table.

Note

Before running: install the SDK and set FI_API_KEY / FI_SECRET_KEY. The model argument in the snippets is the evaluator model Future AGI uses to run the eval; turing_flash is a fast default.

from fi.evals import evaluate

result = evaluate(
    "f1_score",
    output="The capital of France is Paris",
    expected="Paris is the capital of France",
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "f1_score",
  {
    output: "The capital of France is Paris",
    expected: "Paris is the capital of France",
  },
  { modelName: "turing_flash" }
);

console.log(result);

When to use

These metrics fit tasks where you already have a ground-truth label or value to compare against, not open-ended generation.

  • Classification evals: accuracy, balanced_accuracy, precision_score, f1_score, f_beta_score, cohen_kappa, and matthews_correlation for predicted vs. expected labels
  • Regression evals: rmse, r2_score, and log_loss for predicted vs. actual numeric values or probabilities
  • Inter-rater or inter-model agreement: cohen_kappa for two raters, fleiss_kappa for three or more
  • Correlation checks: pearson_correlation for linear relationships, spearman_correlation for monotonic (rank-based) relationships between two numeric series
Was this page helpful?

Questions & Discussion