Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Canonical TypeScript types, Zod schemas, and cross-cutting utilities for the classifier-evals suite. This package is the single source of truth for all classification evaluation shapes used throughout the @reaatech/classifier-evals-* ecosystem.
OpenTelemetry metrics — counters, histograms, and gauges for runs, samples, judge calls, costs, and gate results
PII redaction — credit card, email, phone, SSN, and IP address detection with prompt-injection sanitization
Hash utilities — SHA-256 hashing for anonymizing data and creating deterministic identifiers
Zero runtime dependencies beyond zod and pino — lightweight and tree-shakeable
Dual ESM/CJS output — works with import and require
Quick Start
typescript
import { ClassificationResultSchema, type ClassificationResult, type EvalRun, type ConfusionMatrix,} from "@reaatech/classifier-evals";// Validate a classification result at the boundaryconst rawResult = JSON.parse(incomingJson);const result = ClassificationResultSchema.parse(rawResult);// Use structured loggingimport { createLogger, setEvalRunId } from "@reaatech/classifier-evals";setEvalRunId("eval-abc123");const logger = createLogger({ name: "my-evaluator" });logger.info({ dataset: "test-set.csv" }, "Evaluation started");
Exports
Classification Types
The foundational types for all evaluation operations.
import { hashString, shortHash, hashSet } from "@reaatech/classifier-evals";// Full SHA-256 hashhashString("sensitive-user-id");// → "a5c41c1d7aa6f33650de2b5a0c3fd1b1ddc651638719b70888ae52afe46e6996"// Short hash for displayshortHash("sensitive-user-id");// → "a5c41c1d"// Hash a set of valueshashSet(["user-1", "user-2"]);// → ["hash1...", "hash2..."] (sorted, unique)
Utility: eval-run.ts
typescript
import { loadEvalRunFromFile } from "@reaatech/classifier-evals";// Load a persisted eval runconst evalRun = loadEvalRunFromFile("./results/latest.json");console.log(evalRun.metrics.accuracy);