@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
46 lines • 1.9 kB
TypeScript
/**
* Experiment Analytics Aggregation Helpers
*
* Pure functions for computing statistics from raw score data.
* Used by compareExperiments to build ScorerStats and detect regressions.
*/
import type { ScoreRowData } from '../../../evals/types.js';
import type { ScorerStats } from './types.js';
/**
* Compute the arithmetic mean of an array of numbers.
*
* @param values - Array of numbers to average
* @returns Mean value, or 0 if array is empty
*/
export declare function computeMean(values: number[]): number;
/**
* Compute aggregate statistics for a set of scores.
*
* Metrics:
* - errorRate: proportion of items with null scores (errors)
* - passRate: proportion of scored items meeting threshold
* - avgScore: mean of non-null scores
*
* @param scores - Score records from storage
* @param passThreshold - Absolute threshold for pass (score >= threshold)
* @returns ScorerStats with all computed metrics
*/
export declare function computeScorerStats(scores: ScoreRowData[], passThreshold?: number): ScorerStats;
/**
* Determine if a score delta represents a regression.
*
* @param delta - Score difference (experiment B - experiment A)
* @param threshold - Absolute threshold for regression detection
* @param direction - Score direction ('higher-is-better' or 'lower-is-better')
* @returns True if delta represents a regression
*
* @example
* // Higher is better (default): negative delta is bad
* isRegression(-0.1, 0.05, 'higher-is-better') // true (dropped more than 0.05)
* isRegression(-0.01, 0.05, 'higher-is-better') // false (within tolerance)
*
* // Lower is better: positive delta is bad
* isRegression(0.1, 0.05, 'lower-is-better') // true (increased more than 0.05)
*/
export declare function isRegression(delta: number, threshold: number, direction?: 'higher-is-better' | 'lower-is-better'): boolean;
//# sourceMappingURL=aggregate.d.ts.map