@memberjunction/testing-engine 6.2.0-edge.1 → 6.2.0-edge.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/decision-eval/corpus.d.ts +94 -0
- package/dist/decision-eval/corpus.d.ts.map +1 -0
- package/dist/decision-eval/corpus.js +144 -0
- package/dist/decision-eval/corpus.js.map +1 -0
- package/dist/decision-eval/discovery-baseline.d.ts +62 -0
- package/dist/decision-eval/discovery-baseline.d.ts.map +1 -0
- package/dist/decision-eval/discovery-baseline.js +90 -0
- package/dist/decision-eval/discovery-baseline.js.map +1 -0
- package/dist/decision-eval/discovery-corpus.d.ts +75 -0
- package/dist/decision-eval/discovery-corpus.d.ts.map +1 -0
- package/dist/decision-eval/discovery-corpus.js +110 -0
- package/dist/decision-eval/discovery-corpus.js.map +1 -0
- package/dist/decision-eval/discovery-mapping.d.ts +18 -0
- package/dist/decision-eval/discovery-mapping.d.ts.map +1 -0
- package/dist/decision-eval/discovery-mapping.js +21 -0
- package/dist/decision-eval/discovery-mapping.js.map +1 -0
- package/dist/decision-eval/discovery-metrics.d.ts +339 -0
- package/dist/decision-eval/discovery-metrics.d.ts.map +1 -0
- package/dist/decision-eval/discovery-metrics.js +401 -0
- package/dist/decision-eval/discovery-metrics.js.map +1 -0
- package/dist/decision-eval/discovery-scorecard.d.ts +96 -0
- package/dist/decision-eval/discovery-scorecard.d.ts.map +1 -0
- package/dist/decision-eval/discovery-scorecard.js +351 -0
- package/dist/decision-eval/discovery-scorecard.js.map +1 -0
- package/dist/decision-eval/discovery-suite.d.ts +201 -0
- package/dist/decision-eval/discovery-suite.d.ts.map +1 -0
- package/dist/decision-eval/discovery-suite.js +180 -0
- package/dist/decision-eval/discovery-suite.js.map +1 -0
- package/dist/decision-eval/discovery-types.d.ts +896 -0
- package/dist/decision-eval/discovery-types.d.ts.map +1 -0
- package/dist/decision-eval/discovery-types.js +211 -0
- package/dist/decision-eval/discovery-types.js.map +1 -0
- package/dist/decision-eval/index.d.ts +18 -0
- package/dist/decision-eval/index.d.ts.map +1 -0
- package/dist/decision-eval/index.js +18 -0
- package/dist/decision-eval/index.js.map +1 -0
- package/dist/decision-eval/metrics.d.ts +330 -0
- package/dist/decision-eval/metrics.d.ts.map +1 -0
- package/dist/decision-eval/metrics.js +574 -0
- package/dist/decision-eval/metrics.js.map +1 -0
- package/dist/decision-eval/output-paths.d.ts +119 -0
- package/dist/decision-eval/output-paths.d.ts.map +1 -0
- package/dist/decision-eval/output-paths.js +258 -0
- package/dist/decision-eval/output-paths.js.map +1 -0
- package/dist/decision-eval/point-mapping.d.ts +50 -0
- package/dist/decision-eval/point-mapping.d.ts.map +1 -0
- package/dist/decision-eval/point-mapping.js +83 -0
- package/dist/decision-eval/point-mapping.js.map +1 -0
- package/dist/decision-eval/scorecard.d.ts +190 -0
- package/dist/decision-eval/scorecard.d.ts.map +1 -0
- package/dist/decision-eval/scorecard.js +384 -0
- package/dist/decision-eval/scorecard.js.map +1 -0
- package/dist/decision-eval/suite.d.ts +244 -0
- package/dist/decision-eval/suite.d.ts.map +1 -0
- package/dist/decision-eval/suite.js +238 -0
- package/dist/decision-eval/suite.js.map +1 -0
- package/dist/decision-eval/types.d.ts +993 -0
- package/dist/decision-eval/types.d.ts.map +1 -0
- package/dist/decision-eval/types.js +227 -0
- package/dist/decision-eval/types.js.map +1 -0
- package/dist/drivers/AgentEvalDriver.d.ts +30 -1
- package/dist/drivers/AgentEvalDriver.d.ts.map +1 -1
- package/dist/drivers/AgentEvalDriver.js +145 -16
- package/dist/drivers/AgentEvalDriver.js.map +1 -1
- package/dist/drivers/DecisionEvalDriver.d.ts +297 -0
- package/dist/drivers/DecisionEvalDriver.d.ts.map +1 -0
- package/dist/drivers/DecisionEvalDriver.js +716 -0
- package/dist/drivers/DecisionEvalDriver.js.map +1 -0
- package/dist/drivers/PinnedDecisionRunner.d.ts +24 -0
- package/dist/drivers/PinnedDecisionRunner.d.ts.map +1 -0
- package/dist/drivers/PinnedDecisionRunner.js +24 -0
- package/dist/drivers/PinnedDecisionRunner.js.map +1 -0
- package/dist/drivers/PromptEvalDriver.d.ts.map +1 -1
- package/dist/drivers/PromptEvalDriver.js +8 -1
- package/dist/drivers/PromptEvalDriver.js.map +1 -1
- package/dist/drivers/RubricCalibrationTestDriver.d.ts +34 -0
- package/dist/drivers/RubricCalibrationTestDriver.d.ts.map +1 -0
- package/dist/drivers/RubricCalibrationTestDriver.js +193 -0
- package/dist/drivers/RubricCalibrationTestDriver.js.map +1 -0
- package/dist/drivers/calibration.d.ts +85 -0
- package/dist/drivers/calibration.d.ts.map +1 -0
- package/dist/drivers/calibration.js +191 -0
- package/dist/drivers/calibration.js.map +1 -0
- package/dist/drivers/index.d.ts +2 -0
- package/dist/drivers/index.d.ts.map +1 -1
- package/dist/drivers/index.js +2 -0
- package/dist/drivers/index.js.map +1 -1
- package/dist/engine/TestEngine.d.ts.map +1 -1
- package/dist/engine/TestEngine.js +14 -4
- package/dist/engine/TestEngine.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/oracles/DecisionJudgeOracle.d.ts +97 -0
- package/dist/oracles/DecisionJudgeOracle.d.ts.map +1 -0
- package/dist/oracles/DecisionJudgeOracle.js +230 -0
- package/dist/oracles/DecisionJudgeOracle.js.map +1 -0
- package/dist/oracles/DecisionLabelMatchOracle.d.ts +38 -0
- package/dist/oracles/DecisionLabelMatchOracle.d.ts.map +1 -0
- package/dist/oracles/DecisionLabelMatchOracle.js +96 -0
- package/dist/oracles/DecisionLabelMatchOracle.js.map +1 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.d.ts +39 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.d.ts.map +1 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.js +88 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.js.map +1 -0
- package/dist/oracles/LLMJudgeOracle.d.ts +2 -47
- package/dist/oracles/LLMJudgeOracle.d.ts.map +1 -1
- package/dist/oracles/LLMJudgeOracle.js +80 -149
- package/dist/oracles/LLMJudgeOracle.js.map +1 -1
- package/dist/oracles/RubricOracle.d.ts +51 -0
- package/dist/oracles/RubricOracle.d.ts.map +1 -0
- package/dist/oracles/RubricOracle.js +66 -0
- package/dist/oracles/RubricOracle.js.map +1 -0
- package/dist/oracles/index.d.ts +5 -0
- package/dist/oracles/index.d.ts.map +1 -1
- package/dist/oracles/index.js +5 -0
- package/dist/oracles/index.js.map +1 -1
- package/dist/oracles/inline-rubric.d.ts +25 -0
- package/dist/oracles/inline-rubric.d.ts.map +1 -0
- package/dist/oracles/inline-rubric.js +82 -0
- package/dist/oracles/inline-rubric.js.map +1 -0
- package/dist/oracles/judge-trace.d.ts +76 -0
- package/dist/oracles/judge-trace.d.ts.map +1 -0
- package/dist/oracles/judge-trace.js +125 -0
- package/dist/oracles/judge-trace.js.map +1 -0
- package/dist/oracles/promote-criteria.d.ts +57 -0
- package/dist/oracles/promote-criteria.d.ts.map +1 -0
- package/dist/oracles/promote-criteria.js +104 -0
- package/dist/oracles/promote-criteria.js.map +1 -0
- package/dist/oracles/rubric-resolution.d.ts +69 -0
- package/dist/oracles/rubric-resolution.d.ts.map +1 -0
- package/dist/oracles/rubric-resolution.js +110 -0
- package/dist/oracles/rubric-resolution.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/result-formatter.d.ts +5 -0
- package/dist/utils/result-formatter.d.ts.map +1 -1
- package/dist/utils/result-formatter.js +8 -2
- package/dist/utils/result-formatter.js.map +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-types.d.ts","sourceRoot":"","sources":["../../src/decision-eval/discovery-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEjD,CAAC;AAEH,0DAA0D;AAC1D,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;IASzC,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;EAGnD,CAAC;AAEH,sDAAsD;AACtD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,sFAAsF;AACtF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAItC,CAAC;AAEH,yBAAyB;AACzB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,6GAA6G;AAC7G,eAAO,MAAM,8BAA8B;;IAEvC,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGvD,CAAC;AAEH,qBAAqB;AACrB,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The Decision Eval shapes for the `agent-discovery` decision (plan Task 3.1): Sage's
|
|
3
|
+
* pick of the agent that should handle a request, asked as one typed decision, and the
|
|
4
|
+
* `semantic-search` baseline that measures what `Find Candidate Agents` ranked first.
|
|
5
|
+
*
|
|
6
|
+
* - **The corpus** is `corpus.jsonl` (one request per line) and `labels.jsonl` (one label per
|
|
7
|
+
* line, several sources per request). A label is `agent` (with the agent that should handle the
|
|
8
|
+
* request) or `none` (with why no specialist should: small talk, a question the conversation
|
|
9
|
+
* manager answers directly, or a multi-agent workflow).
|
|
10
|
+
* - **A test** carries one request as its `InputDefinition` and its label as `ExpectedOutcomes`.
|
|
11
|
+
* Its `Configuration` pins the cell's model, or names the baseline, which makes no decision call.
|
|
12
|
+
*
|
|
13
|
+
* As in `types.ts`, every JSON shape is a Zod schema with its type inferred from it; the corpus
|
|
14
|
+
* keys are the corpus's own (snake_case) and the test keys are the ones the suite generator writes.
|
|
15
|
+
*
|
|
16
|
+
* @module @memberjunction/testing-engine
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { DecisionEvalAnswerSummarySchema, DecisionEvalModelRecordSchema, DecisionEvalOracleSpecSchema, DecisionEvalSamplingSchema } from './types.js';
|
|
20
|
+
/** The labels a discovery request can carry: an agent should handle it, or none should. */
|
|
21
|
+
export const DISCOVERY_EVAL_LABELS = ['agent', 'none'];
|
|
22
|
+
/**
|
|
23
|
+
* Why no specialist agent should handle a request:
|
|
24
|
+
* - `chat`: small talk;
|
|
25
|
+
* - `direct`: a general question the conversation manager answers itself;
|
|
26
|
+
* - `workflow`: a request that needs several agents, which the conversation manager plans.
|
|
27
|
+
*/
|
|
28
|
+
export const DISCOVERY_NONE_KINDS = ['chat', 'direct', 'workflow'];
|
|
29
|
+
/** The baselines a cell can run instead of the decision. */
|
|
30
|
+
export const DISCOVERY_EVAL_BASELINES = ['semantic-search'];
|
|
31
|
+
/** What a run measured: the decision, or a baseline. */
|
|
32
|
+
export const DISCOVERY_EVAL_ARMS = ['decision', ...DISCOVERY_EVAL_BASELINES];
|
|
33
|
+
/** The suite name when neither the matrix nor the command line gives one. */
|
|
34
|
+
export const DEFAULT_DISCOVERY_EVAL_SUITE_NAME = 'Decision Eval — Agent Discovery';
|
|
35
|
+
/** One request, as a corpus line records it. */
|
|
36
|
+
export const DiscoveryCorpusRequestSchema = z.object({
|
|
37
|
+
id: z.string().uuid(),
|
|
38
|
+
request: z.string().min(1),
|
|
39
|
+
created_at: z.string().min(1)
|
|
40
|
+
});
|
|
41
|
+
/** An `agent` label's own fields: the agent that should handle the request. */
|
|
42
|
+
const AgentLabelFields = { label: z.literal('agent'), agentId: z.string().uuid() };
|
|
43
|
+
/** A `none` label's own fields: why no specialist should. */
|
|
44
|
+
const NoneLabelFields = { label: z.literal('none'), kind: z.enum(DISCOVERY_NONE_KINDS) };
|
|
45
|
+
/** One label for a request, from one source. A request may have several, from different sources. */
|
|
46
|
+
export const DiscoveryCorpusLabelSchema = z.discriminatedUnion('label', [
|
|
47
|
+
z.object({ id: z.string().uuid(), ...AgentLabelFields, source: z.string().min(1) }),
|
|
48
|
+
z.object({ id: z.string().uuid(), ...NoneLabelFields, source: z.string().min(1) })
|
|
49
|
+
]);
|
|
50
|
+
/** A label without its request ID and source: what the request should reach. */
|
|
51
|
+
export const DiscoveryLabelSchema = z.discriminatedUnion('label', [
|
|
52
|
+
z.object(AgentLabelFields),
|
|
53
|
+
z.object(NoneLabelFields)
|
|
54
|
+
]);
|
|
55
|
+
/** A discovery test's `Configuration`: the cell's model pinning, or its baseline. `null` reads as unset. */
|
|
56
|
+
export const DiscoveryEvalConfigSchema = z.object({
|
|
57
|
+
decision: z.literal('agent-discovery'),
|
|
58
|
+
/** Runs this baseline instead of the decision: no decision call is made. */
|
|
59
|
+
baseline: z.enum(DISCOVERY_EVAL_BASELINES).nullish(),
|
|
60
|
+
/** The decision prompt. Defaults to `Default Decision`, the prompt production's discovery asks. */
|
|
61
|
+
promptName: z.string().min(1).nullish(),
|
|
62
|
+
/** Pins the `MJ: AI Models` row that must answer. */
|
|
63
|
+
modelId: z.string().uuid().nullish(),
|
|
64
|
+
/** Pins the vendor. */
|
|
65
|
+
vendorId: z.string().uuid().nullish(),
|
|
66
|
+
/** Whether the runner may fail over. Defaults to false when the cell pins a model or vendor. */
|
|
67
|
+
failover: z.boolean().nullish(),
|
|
68
|
+
/** Requested sampling temperature. Recorded, not applied: see the driver. */
|
|
69
|
+
temperature: z.number().nullish(),
|
|
70
|
+
/** Requested sampling seed. Recorded, not applied: see the driver. */
|
|
71
|
+
seed: z.number().int().nullish(),
|
|
72
|
+
/** The oracles to run. */
|
|
73
|
+
oracles: z.array(DecisionEvalOracleSpecSchema).min(1)
|
|
74
|
+
});
|
|
75
|
+
/** A discovery test's `InputDefinition`: the request, as the user typed it. */
|
|
76
|
+
export const DiscoveryEvalInputSchema = z.object({
|
|
77
|
+
request: z.string().min(1)
|
|
78
|
+
});
|
|
79
|
+
/** A discovery test's `ExpectedOutcomes`: the request's label, and where the label came from. */
|
|
80
|
+
export const DiscoveryEvalExpectedSchema = z.discriminatedUnion('label', [
|
|
81
|
+
z.object({ ...AgentLabelFields, labelSource: z.string().min(1) }),
|
|
82
|
+
z.object({ ...NoneLabelFields, labelSource: z.string().min(1) })
|
|
83
|
+
]);
|
|
84
|
+
/** How the decision arm's options were reached from the catalog. */
|
|
85
|
+
export const DiscoveryOptionsRecordSchema = z.object({
|
|
86
|
+
/** How many options the Choice offered. */
|
|
87
|
+
Count: z.number().int(),
|
|
88
|
+
/** The most options the Choice may offer. */
|
|
89
|
+
Limit: z.number().int(),
|
|
90
|
+
/** The permitted, directly discoverable agents, minus the conversation manager. */
|
|
91
|
+
CatalogSize: z.number().int(),
|
|
92
|
+
/** Catalog agents left out for having no description. */
|
|
93
|
+
WithoutDescription: z.number().int(),
|
|
94
|
+
/** The decision model's declared option cap, or null. */
|
|
95
|
+
DeclaredCap: z.number().nullable(),
|
|
96
|
+
/** The option count before the semantic search narrowed it, or null when it did not. */
|
|
97
|
+
NarrowedFrom: z.number().int().nullable()
|
|
98
|
+
});
|
|
99
|
+
/** One agent the semantic search ranked, scored as `Find Candidate Agents` scores it. */
|
|
100
|
+
export const DiscoveryBaselineCandidateSchema = z.object({
|
|
101
|
+
AgentId: z.string(),
|
|
102
|
+
AgentName: z.string().nullable(),
|
|
103
|
+
/** 1-based position in the search's results. */
|
|
104
|
+
Rank: z.number().int(),
|
|
105
|
+
/** The score the action reports: the larger of the semantic and lexical components, else the blended score. */
|
|
106
|
+
Score: z.number(),
|
|
107
|
+
Semantic: z.number().nullable(),
|
|
108
|
+
Lexical: z.number().nullable(),
|
|
109
|
+
/** Whether the action keeps it: semantic at or above the floor, or any lexical hit. */
|
|
110
|
+
PassesFloor: z.boolean()
|
|
111
|
+
});
|
|
112
|
+
/** What the `semantic-search` baseline found. */
|
|
113
|
+
export const DiscoveryBaselineRecordSchema = z.object({
|
|
114
|
+
/** The action's similarity floor. */
|
|
115
|
+
Floor: z.number(),
|
|
116
|
+
/** How many results the search was asked for. */
|
|
117
|
+
TopK: z.number().int(),
|
|
118
|
+
/** How many it returned. */
|
|
119
|
+
Results: z.number().int(),
|
|
120
|
+
/** The best-ranked candidate, floor or not, or null when the search returned none. */
|
|
121
|
+
TopRanked: DiscoveryBaselineCandidateSchema.nullable(),
|
|
122
|
+
/** The best-ranked candidate that passes the floor: the first row the action returns, or null when it returns none. */
|
|
123
|
+
TopMatch: DiscoveryBaselineCandidateSchema.nullable()
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* What a discovery run records as its `ActualOutput`. Both arms fill the shared fields:
|
|
127
|
+
* - `ChosenAgentId`: the Choice's agent (decision), or the action's first row (baseline);
|
|
128
|
+
* - `WouldInject`: whether production would suggest the agent: production's own verdict,
|
|
129
|
+
* `DecisionDiscoveryFromResult`, which calibrates the answers for the answering model and judges
|
|
130
|
+
* them at production's threshold, and only when the discovery finished within production's
|
|
131
|
+
* timeout (decision); or whether the action returns any row (baseline). `Confidence` and
|
|
132
|
+
* `AnyApplies` stay the model's raw answers, which calibration is fitted on.
|
|
133
|
+
*/
|
|
134
|
+
export const DiscoveryEvalActualOutputSchema = z.object({
|
|
135
|
+
Decision: z.literal('agent-discovery'),
|
|
136
|
+
Arm: z.enum(DISCOVERY_EVAL_ARMS),
|
|
137
|
+
/** The decision prompt, or null for the baseline. */
|
|
138
|
+
PromptName: z.string().nullable(),
|
|
139
|
+
/** The decision arm's options, or null. */
|
|
140
|
+
Options: DiscoveryOptionsRecordSchema.nullable(),
|
|
141
|
+
/** For an `agent` label: whether the labelled agent was among the options (decision) or the catalog (baseline). Null otherwise. */
|
|
142
|
+
LabelledAgentOffered: z.boolean().nullable(),
|
|
143
|
+
/** Every answer, summarized. The Choice keeps its full distribution, by agent ID. */
|
|
144
|
+
Answers: z.record(DecisionEvalAnswerSummarySchema),
|
|
145
|
+
ChosenAgentId: z.string().nullable(),
|
|
146
|
+
ChosenAgentName: z.string().nullable(),
|
|
147
|
+
/** The Choice's confidence, or null. */
|
|
148
|
+
Confidence: z.number().nullable(),
|
|
149
|
+
/** The Likelihood that a specialist agent should handle the request, or null. */
|
|
150
|
+
AnyApplies: z.number().nullable(),
|
|
151
|
+
/** Whether production would suggest the chosen agent, or null without a usable answer. */
|
|
152
|
+
WouldInject: z.boolean().nullable(),
|
|
153
|
+
/** The calibrated threshold `WouldInject` was judged at (decision arm), or null. */
|
|
154
|
+
MinConfidence: z.number().nullable(),
|
|
155
|
+
/** Why nothing would be injected, or null. */
|
|
156
|
+
VerdictReason: z.string().nullable(),
|
|
157
|
+
/** The baseline's ranking, or null for the decision arm. */
|
|
158
|
+
Baseline: DiscoveryBaselineRecordSchema.nullable(),
|
|
159
|
+
/** The model record (decision arm), or null. */
|
|
160
|
+
Model: DecisionEvalModelRecordSchema.nullable(),
|
|
161
|
+
Sampling: DecisionEvalSamplingSchema,
|
|
162
|
+
/** Wall-clock time of the decision call alone, or of the search for the baseline, in milliseconds. */
|
|
163
|
+
LatencyMs: z.number().nullable(),
|
|
164
|
+
/**
|
|
165
|
+
* Decision arm: wall-clock time from building the options, the semantic search included, through
|
|
166
|
+
* the decision call, in milliseconds. That is the span production's discovery timeout bounds.
|
|
167
|
+
* Null for the baseline. Absent from runs recorded before it was measured.
|
|
168
|
+
*/
|
|
169
|
+
DiscoveryLatencyMs: z.number().nullish(),
|
|
170
|
+
/**
|
|
171
|
+
* Whether the discovery (`DiscoveryLatencyMs`) finished within production's timeout, or null
|
|
172
|
+
* without an answer. Production gives up at the timeout and injects nothing, so a late answer is
|
|
173
|
+
* never `WouldInject`. In runs recorded before `DiscoveryLatencyMs`, it timed the call alone.
|
|
174
|
+
*/
|
|
175
|
+
WithinProductionTimeout: z.boolean().nullable(),
|
|
176
|
+
PromptRunId: z.string().nullable(),
|
|
177
|
+
CostUSD: z.number().nullable(),
|
|
178
|
+
/** Why the run produced no answer, or null. */
|
|
179
|
+
Error: z.string().nullable()
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* The `discovery-label-match` oracle's `details`. `correct` is null when the run has no usable
|
|
183
|
+
* answer to judge.
|
|
184
|
+
*/
|
|
185
|
+
export const DiscoveryLabelMatchDetailsSchema = z.object({
|
|
186
|
+
arm: z.enum(DISCOVERY_EVAL_ARMS),
|
|
187
|
+
label: z.enum(DISCOVERY_EVAL_LABELS),
|
|
188
|
+
kind: z.enum(DISCOVERY_NONE_KINDS).nullable(),
|
|
189
|
+
expectedAgentId: z.string().nullable(),
|
|
190
|
+
chosenAgentId: z.string().nullable(),
|
|
191
|
+
confidence: z.number().nullable(),
|
|
192
|
+
anyApplies: z.number().nullable(),
|
|
193
|
+
wouldInject: z.boolean().nullable(),
|
|
194
|
+
/** The baseline's first row's score, or null. */
|
|
195
|
+
topScore: z.number().nullable(),
|
|
196
|
+
correct: z.boolean().nullable()
|
|
197
|
+
});
|
|
198
|
+
/** One agent in the catalog snapshot the corpus generator writes as `agents.json`. */
|
|
199
|
+
export const DiscoveryCatalogAgentSchema = z.object({
|
|
200
|
+
ID: z.string().uuid(),
|
|
201
|
+
Name: z.string(),
|
|
202
|
+
Description: z.string()
|
|
203
|
+
});
|
|
204
|
+
/** `agents.json`: the discoverable agents a corpus was generated from, so a run can detect catalog drift. */
|
|
205
|
+
export const DiscoveryCatalogSnapshotSchema = z.object({
|
|
206
|
+
created_at: z.string().min(1),
|
|
207
|
+
/** The conversation manager the catalog excludes. */
|
|
208
|
+
conversation_manager_id: z.string().uuid(),
|
|
209
|
+
agents: z.array(DiscoveryCatalogAgentSchema)
|
|
210
|
+
});
|
|
211
|
+
//# sourceMappingURL=discovery-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-types.js","sourceRoot":"","sources":["../../src/decision-eval/discovery-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC7B,MAAM,SAAS,CAAC;AAEjB,2FAA2F;AAC3F,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC;AAKhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAK5E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAKrE,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,GAAG,wBAAwB,CAAU,CAAC;AAKtF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iCAAiC,GAAG,iCAAiC,CAAC;AAEnF,gDAAgD;AAChD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC;AAKH,+EAA+E;AAC/E,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAA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CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC;AAKH,6GAA6G;AAC7G,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,qDAAqD;IACrD,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC;CAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision Eval: measuring typed decisions against labels (plan Phase 2).
|
|
3
|
+
*/
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './corpus.js';
|
|
6
|
+
export * from './point-mapping.js';
|
|
7
|
+
export * from './metrics.js';
|
|
8
|
+
export * from './output-paths.js';
|
|
9
|
+
export * from './suite.js';
|
|
10
|
+
export * from './scorecard.js';
|
|
11
|
+
export * from './discovery-types.js';
|
|
12
|
+
export * from './discovery-corpus.js';
|
|
13
|
+
export * from './discovery-mapping.js';
|
|
14
|
+
export * from './discovery-baseline.js';
|
|
15
|
+
export * from './discovery-suite.js';
|
|
16
|
+
export * from './discovery-metrics.js';
|
|
17
|
+
export * from './discovery-scorecard.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decision-eval/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision Eval: measuring typed decisions against labels (plan Phase 2).
|
|
3
|
+
*/
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './corpus.js';
|
|
6
|
+
export * from './point-mapping.js';
|
|
7
|
+
export * from './metrics.js';
|
|
8
|
+
export * from './output-paths.js';
|
|
9
|
+
export * from './suite.js';
|
|
10
|
+
export * from './scorecard.js';
|
|
11
|
+
export * from './discovery-types.js';
|
|
12
|
+
export * from './discovery-corpus.js';
|
|
13
|
+
export * from './discovery-mapping.js';
|
|
14
|
+
export * from './discovery-baseline.js';
|
|
15
|
+
export * from './discovery-suite.js';
|
|
16
|
+
export * from './discovery-metrics.js';
|
|
17
|
+
export * from './discovery-scorecard.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decision-eval/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Decision Eval metrics: agreement with labels, repeatability and calibration, per
|
|
3
|
+
* matrix cell. Pure and deterministic: every random draw comes from a seeded generator, and
|
|
4
|
+
* {@link ComputeCellMetrics} puts the cases in case-ID order before any draw, so the same runs give
|
|
5
|
+
* the same scorecard in whatever order they are read.
|
|
6
|
+
*
|
|
7
|
+
* Definitions (all on the cell's observations):
|
|
8
|
+
* - A **case** is one corpus point. Its repeats are the cell's runs of it.
|
|
9
|
+
* - A run is **usable** when it produced a probability and was not answered by a model other than
|
|
10
|
+
* the pinned one in a cell that disallowed failover. Other runs are counted, never scored.
|
|
11
|
+
* - **Accuracy-type metrics** (accuracy, balanced accuracy, AUC, Brier, ECE, switch recall,
|
|
12
|
+
* operating points) use one probability per case: the mean of its usable repeats. They cover
|
|
13
|
+
* cases labelled `continue` (positive) or `switch` (negative); `ambiguous` cases are reported
|
|
14
|
+
* apart, as the rate kept with the previous agent.
|
|
15
|
+
* - **Repeatability** uses the individual repeats: per case, the population standard deviation of
|
|
16
|
+
* the probability, and the verdict agreement (the share of repeats whose verdict at the threshold
|
|
17
|
+
* matches the case's majority verdict). Cases with fewer than two usable repeats are left out.
|
|
18
|
+
* - **Signal value** is accuracy × mean verdict agreement (plan §2: agreement with labels ×
|
|
19
|
+
* repeatability).
|
|
20
|
+
* - **Calibration** is Platt scaling on logit(p), fitted out of fold, with the parameters also
|
|
21
|
+
* fitted on all the data.
|
|
22
|
+
*
|
|
23
|
+
* @module @memberjunction/testing-engine
|
|
24
|
+
*/
|
|
25
|
+
import type { DecisionEvalLabel } from './types.js';
|
|
26
|
+
/** The threshold the metrics use unless told otherwise. */
|
|
27
|
+
export declare const DECISION_EVAL_DEFAULT_THRESHOLD = 0.5;
|
|
28
|
+
/** The bootstrap's resample count unless told otherwise. */
|
|
29
|
+
export declare const DECISION_EVAL_BOOTSTRAP_RESAMPLES = 1000;
|
|
30
|
+
/** The seed for every random draw unless told otherwise. */
|
|
31
|
+
export declare const DECISION_EVAL_SEED = 20260929;
|
|
32
|
+
/** The calibration fold count unless told otherwise. */
|
|
33
|
+
export declare const DECISION_EVAL_CALIBRATION_FOLDS = 5;
|
|
34
|
+
/** The number of equal-width reliability bins. */
|
|
35
|
+
export declare const DECISION_EVAL_ECE_BINS = 10;
|
|
36
|
+
/**
|
|
37
|
+
* How far a probability is clamped from 0 and 1 before its logit is taken: production's
|
|
38
|
+
* `PLATT_LOGIT_CLAMP` (`@memberjunction/ai`), so parameters fitted here are applied there on the
|
|
39
|
+
* same scale.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DECISION_EVAL_LOGIT_CLAMP = 0.000001;
|
|
42
|
+
/** The operating-point thresholds: 0.30 to 0.90 in steps of 0.05. */
|
|
43
|
+
export declare const DECISION_EVAL_OPERATING_THRESHOLDS: readonly number[];
|
|
44
|
+
/** One run of one case in one cell. */
|
|
45
|
+
export interface DecisionEvalObservation {
|
|
46
|
+
/** The corpus point's ID. */
|
|
47
|
+
CaseId: string;
|
|
48
|
+
/** The point's label. */
|
|
49
|
+
Label: DecisionEvalLabel;
|
|
50
|
+
/** The positive-class probability (the `continues` Likelihood), or null when the run produced none. */
|
|
51
|
+
Probability: number | null;
|
|
52
|
+
/** Latency of the decision call in milliseconds, when recorded. */
|
|
53
|
+
LatencyMs: number | null;
|
|
54
|
+
/** The run's cost in USD, when known. */
|
|
55
|
+
CostUSD: number | null;
|
|
56
|
+
/** True when a pinned run was answered by another model or vendor. */
|
|
57
|
+
FailedOver: boolean;
|
|
58
|
+
/** Whether the cell allowed failover. A failed-over run in a cell that didn't is not scored. */
|
|
59
|
+
FailoverAllowed: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** One probability with its true class. */
|
|
62
|
+
export interface LabelledProbability {
|
|
63
|
+
/** The positive-class probability. */
|
|
64
|
+
Probability: number;
|
|
65
|
+
/** True for the positive class (`continue`). */
|
|
66
|
+
Positive: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** A 95% interval. */
|
|
69
|
+
export interface ConfidenceInterval {
|
|
70
|
+
Lower: number;
|
|
71
|
+
Upper: number;
|
|
72
|
+
}
|
|
73
|
+
/** One reliability bin: its probability range, how many cases fell in it, and how they came out. */
|
|
74
|
+
export interface ReliabilityBin {
|
|
75
|
+
Lower: number;
|
|
76
|
+
Upper: number;
|
|
77
|
+
Count: number;
|
|
78
|
+
/** Mean predicted probability in the bin, or null when it is empty. */
|
|
79
|
+
MeanPredicted: number | null;
|
|
80
|
+
/** Share of the bin's cases that are positive, or null when it is empty. */
|
|
81
|
+
ObservedRate: number | null;
|
|
82
|
+
}
|
|
83
|
+
/** Expected calibration error and the reliability table behind it. */
|
|
84
|
+
export interface CalibrationSummary {
|
|
85
|
+
/** Σ (bin count / n) × |mean predicted − observed rate|, or null with no cases. */
|
|
86
|
+
ECE: number | null;
|
|
87
|
+
Bins: ReliabilityBin[];
|
|
88
|
+
}
|
|
89
|
+
/** Precision and recall of each class at one threshold. Null where the ratio has no denominator. */
|
|
90
|
+
export interface OperatingPoint {
|
|
91
|
+
Threshold: number;
|
|
92
|
+
ContinuePrecision: number | null;
|
|
93
|
+
ContinueRecall: number | null;
|
|
94
|
+
SwitchPrecision: number | null;
|
|
95
|
+
SwitchRecall: number | null;
|
|
96
|
+
}
|
|
97
|
+
/** The accuracy-type metrics of one set of per-case probabilities. */
|
|
98
|
+
export interface ProbabilityMetrics {
|
|
99
|
+
/** Cases scored. */
|
|
100
|
+
N: number;
|
|
101
|
+
Accuracy: number | null;
|
|
102
|
+
AccuracyCI: ConfidenceInterval | null;
|
|
103
|
+
BalancedAccuracy: number | null;
|
|
104
|
+
BalancedAccuracyCI: ConfidenceInterval | null;
|
|
105
|
+
RocAuc: number | null;
|
|
106
|
+
Brier: number | null;
|
|
107
|
+
Calibration: CalibrationSummary;
|
|
108
|
+
SwitchRecall: number | null;
|
|
109
|
+
OperatingPoints: OperatingPoint[];
|
|
110
|
+
}
|
|
111
|
+
/** Platt parameters: calibrated p = 1 / (1 + exp(−(A · logit(p) + B))). */
|
|
112
|
+
export interface PlattParameters {
|
|
113
|
+
A: number;
|
|
114
|
+
B: number;
|
|
115
|
+
Iterations: number;
|
|
116
|
+
Converged: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** One case's repeatability. */
|
|
119
|
+
export interface CaseRepeatability {
|
|
120
|
+
CaseId: string;
|
|
121
|
+
Repeats: number;
|
|
122
|
+
StdDev: number;
|
|
123
|
+
VerdictAgreement: number;
|
|
124
|
+
}
|
|
125
|
+
/** A cell's repeatability. */
|
|
126
|
+
export interface RepeatabilitySummary {
|
|
127
|
+
/** Cases with at least two usable repeats. */
|
|
128
|
+
Cases: number;
|
|
129
|
+
MeanStdDev: number | null;
|
|
130
|
+
MeanVerdictAgreement: number | null;
|
|
131
|
+
/** The least repeatable cases (lowest agreement, then highest spread), by ID only. */
|
|
132
|
+
Worst: CaseRepeatability[];
|
|
133
|
+
}
|
|
134
|
+
/** Counts of a cell's runs. */
|
|
135
|
+
export interface RunCounts {
|
|
136
|
+
Runs: number;
|
|
137
|
+
UsableRuns: number;
|
|
138
|
+
/** Runs that produced no probability. */
|
|
139
|
+
NoProbabilityRuns: number;
|
|
140
|
+
/** Runs answered by a model other than the pinned one, allowed or not. */
|
|
141
|
+
FailoverRuns: number;
|
|
142
|
+
/** Failed-over runs in a cell that disallowed failover: not scored. */
|
|
143
|
+
ExcludedFailoverRuns: number;
|
|
144
|
+
}
|
|
145
|
+
/** How `ambiguous` cases came out. */
|
|
146
|
+
export interface AmbiguousSummary {
|
|
147
|
+
Cases: number;
|
|
148
|
+
/** Cases whose mean probability is at or above the threshold: kept with the previous agent. */
|
|
149
|
+
KeptWithPreviousAgent: number;
|
|
150
|
+
Rate: number | null;
|
|
151
|
+
}
|
|
152
|
+
/** Latency percentiles over the runs that produced a probability. */
|
|
153
|
+
export interface LatencySummary {
|
|
154
|
+
Runs: number;
|
|
155
|
+
P50: number | null;
|
|
156
|
+
P95: number | null;
|
|
157
|
+
}
|
|
158
|
+
/** Cost per thousand runs, from the runs whose cost is known. */
|
|
159
|
+
export interface CostSummary {
|
|
160
|
+
RunsWithCost: number;
|
|
161
|
+
CostPer1kUSD: number | null;
|
|
162
|
+
}
|
|
163
|
+
/** Everything the scorecard reports for one cell. */
|
|
164
|
+
export interface DecisionEvalCellMetrics {
|
|
165
|
+
Threshold: number;
|
|
166
|
+
Counts: RunCounts;
|
|
167
|
+
Raw: ProbabilityMetrics;
|
|
168
|
+
/** The same metrics on out-of-fold Platt-calibrated probabilities, or null with fewer than two cases. */
|
|
169
|
+
Calibrated: ProbabilityMetrics | null;
|
|
170
|
+
/** Platt parameters fitted on all the cases: what a consumer would ship. */
|
|
171
|
+
Platt: PlattParameters | null;
|
|
172
|
+
Repeatability: RepeatabilitySummary;
|
|
173
|
+
/** Accuracy × mean verdict agreement. */
|
|
174
|
+
SignalValue: number | null;
|
|
175
|
+
Latency: LatencySummary;
|
|
176
|
+
Cost: CostSummary;
|
|
177
|
+
Ambiguous: AmbiguousSummary;
|
|
178
|
+
}
|
|
179
|
+
/** Options for {@link ComputeCellMetrics}. Every one has a default. */
|
|
180
|
+
export interface DecisionEvalMetricOptions {
|
|
181
|
+
Threshold?: number;
|
|
182
|
+
BootstrapResamples?: number;
|
|
183
|
+
Seed?: number;
|
|
184
|
+
CalibrationFolds?: number;
|
|
185
|
+
WorstCaseCount?: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A seeded pseudo-random generator (mulberry32) returning numbers in [0, 1).
|
|
189
|
+
*
|
|
190
|
+
* @param seed Any 32-bit integer.
|
|
191
|
+
*/
|
|
192
|
+
export declare function CreateSeededRandom(seed: number): () => number;
|
|
193
|
+
/** The mean, or null for no values. */
|
|
194
|
+
export declare function Mean(values: readonly number[]): number | null;
|
|
195
|
+
/** The population standard deviation (divides by n), or null for no values. */
|
|
196
|
+
export declare function PopulationStdDev(values: readonly number[]): number | null;
|
|
197
|
+
/**
|
|
198
|
+
* The q-quantile with linear interpolation between order statistics (R type 7, NumPy's default),
|
|
199
|
+
* or null for no values.
|
|
200
|
+
*
|
|
201
|
+
* @param values The values, in any order.
|
|
202
|
+
* @param q The quantile, in [0, 1].
|
|
203
|
+
*/
|
|
204
|
+
export declare function Quantile(values: readonly number[], q: number): number | null;
|
|
205
|
+
/** The share of cases whose verdict at the threshold matches the class, or null with none. */
|
|
206
|
+
export declare function Accuracy(points: readonly LabelledProbability[], threshold: number): number | null;
|
|
207
|
+
/**
|
|
208
|
+
* The recall of one class: among its cases, the share the threshold assigns to it. Null when the
|
|
209
|
+
* class has no cases.
|
|
210
|
+
*
|
|
211
|
+
* @param points The cases.
|
|
212
|
+
* @param threshold At or above it predicts the positive class.
|
|
213
|
+
* @param positive Which class: true for `continue`, false for `switch`.
|
|
214
|
+
*/
|
|
215
|
+
export declare function ClassRecall(points: readonly LabelledProbability[], threshold: number, positive: boolean): number | null;
|
|
216
|
+
/** The mean of the two classes' recalls, over the classes present. Null with no cases. */
|
|
217
|
+
export declare function BalancedAccuracy(points: readonly LabelledProbability[], threshold: number): number | null;
|
|
218
|
+
/**
|
|
219
|
+
* ROC AUC: the probability that a random positive case scores above a random negative one, with
|
|
220
|
+
* ties counting half (the Mann-Whitney U statistic over average ranks). Null unless both classes
|
|
221
|
+
* are present.
|
|
222
|
+
*/
|
|
223
|
+
export declare function RocAuc(points: readonly LabelledProbability[]): number | null;
|
|
224
|
+
/** Mean squared difference between the probability and the class (1 or 0). Null with no cases. */
|
|
225
|
+
export declare function BrierScore(points: readonly LabelledProbability[]): number | null;
|
|
226
|
+
/**
|
|
227
|
+
* Expected calibration error over equal-width bins, and the reliability table. Bin i holds
|
|
228
|
+
* probabilities in [i/b, (i+1)/b); the last bin also holds 1.
|
|
229
|
+
*
|
|
230
|
+
* @param points The cases.
|
|
231
|
+
* @param binCount The number of bins.
|
|
232
|
+
*/
|
|
233
|
+
export declare function CalibrationBins(points: readonly LabelledProbability[], binCount?: number): CalibrationSummary;
|
|
234
|
+
/**
|
|
235
|
+
* A percentile bootstrap interval for a statistic of the cases: `resamples` draws of n cases with
|
|
236
|
+
* replacement, from a generator seeded with `seed`, and the 2.5th and 97.5th percentiles of the
|
|
237
|
+
* statistic. Draws where the statistic is undefined are skipped. Null when none is defined.
|
|
238
|
+
*
|
|
239
|
+
* The draws pick cases by position, so the interval depends on the input's order as well as the
|
|
240
|
+
* seed: pass the cases in a stable order ({@link ComputeCellMetrics} sorts them by case ID).
|
|
241
|
+
*
|
|
242
|
+
* @param points The cases.
|
|
243
|
+
* @param statistic The statistic to bound.
|
|
244
|
+
* @param resamples How many resamples.
|
|
245
|
+
* @param seed The generator's seed.
|
|
246
|
+
*/
|
|
247
|
+
export declare function BootstrapInterval(points: readonly LabelledProbability[], statistic: (sample: readonly LabelledProbability[]) => number | null, resamples: number, seed: number): ConfidenceInterval | null;
|
|
248
|
+
/**
|
|
249
|
+
* Precision and recall of each class at each threshold. `continue` is predicted at or above the
|
|
250
|
+
* threshold, `switch` below it.
|
|
251
|
+
*
|
|
252
|
+
* @param points The cases.
|
|
253
|
+
* @param thresholds The thresholds.
|
|
254
|
+
*/
|
|
255
|
+
export declare function OperatingPoints(points: readonly LabelledProbability[], thresholds?: readonly number[]): OperatingPoint[];
|
|
256
|
+
/**
|
|
257
|
+
* The logit of a probability clamped to [ε, 1 − ε].
|
|
258
|
+
*
|
|
259
|
+
* @param probability The probability.
|
|
260
|
+
*/
|
|
261
|
+
export declare function ClampedLogit(probability: number): number;
|
|
262
|
+
/**
|
|
263
|
+
* Fits Platt scaling: a logistic regression of the class on logit(p), by Newton's method with a
|
|
264
|
+
* backtracking line search, at most 100 iterations. The targets are Platt's smoothed ones,
|
|
265
|
+
* (N₊ + 1) / (N₊ + 2) for a positive case and 1 / (N₋ + 2) for a negative one, so a separable set
|
|
266
|
+
* still has a finite fit. It has converged when the gradient is below 1e-9.
|
|
267
|
+
*
|
|
268
|
+
* @param points The cases to fit on.
|
|
269
|
+
*/
|
|
270
|
+
export declare function FitPlatt(points: readonly LabelledProbability[]): PlattParameters;
|
|
271
|
+
/**
|
|
272
|
+
* A probability through fitted Platt parameters, by production's own `ApplyPlattCalibration`
|
|
273
|
+
* (`@memberjunction/ai`), so the eval scores exactly the transform a consumer applies.
|
|
274
|
+
*
|
|
275
|
+
* @param probability The raw probability.
|
|
276
|
+
* @param parameters The fit.
|
|
277
|
+
*/
|
|
278
|
+
export declare function ApplyPlatt(probability: number, parameters: Pick<PlattParameters, 'A' | 'B'>): number;
|
|
279
|
+
/**
|
|
280
|
+
* Out-of-fold Platt calibration: the cases are shuffled within each class with a seeded generator
|
|
281
|
+
* and dealt into folds in turn (so each fold holds both classes where it can); each fold is
|
|
282
|
+
* calibrated by a fit on the others, so no case's calibrated value depends on its own label.
|
|
283
|
+
* Returns the calibrated probabilities in the input's order, or null with fewer than two cases.
|
|
284
|
+
* With fewer cases than folds, each case is its own fold (leave one out).
|
|
285
|
+
*
|
|
286
|
+
* The shuffle is by position, so the folds depend on the input's order as well as the seed: pass
|
|
287
|
+
* the cases in a stable order ({@link ComputeCellMetrics} sorts them by case ID).
|
|
288
|
+
*
|
|
289
|
+
* @param points The cases.
|
|
290
|
+
* @param folds The fold count.
|
|
291
|
+
* @param seed The generator's seed.
|
|
292
|
+
*/
|
|
293
|
+
export declare function OutOfFoldPlatt(points: readonly LabelledProbability[], folds: number, seed: number): number[] | null;
|
|
294
|
+
/**
|
|
295
|
+
* One case's repeatability: the population standard deviation of its repeats' probabilities, and
|
|
296
|
+
* the share of repeats whose verdict at the threshold matches the majority verdict.
|
|
297
|
+
*
|
|
298
|
+
* @param caseId The case.
|
|
299
|
+
* @param probabilities Its repeats' probabilities.
|
|
300
|
+
* @param threshold At or above it the verdict is positive.
|
|
301
|
+
*/
|
|
302
|
+
export declare function MeasureCaseRepeatability(caseId: string, probabilities: readonly number[], threshold: number): CaseRepeatability;
|
|
303
|
+
/**
|
|
304
|
+
* A cell's repeatability over the cases with at least two repeats, and its least repeatable cases:
|
|
305
|
+
* lowest verdict agreement first, then highest spread, then ID.
|
|
306
|
+
*
|
|
307
|
+
* @param repeatsByCase Each case's repeats' probabilities.
|
|
308
|
+
* @param threshold At or above it the verdict is positive.
|
|
309
|
+
* @param worstCount How many of the least repeatable cases to list.
|
|
310
|
+
*/
|
|
311
|
+
export declare function SummarizeRepeatability(repeatsByCase: ReadonlyMap<string, readonly number[]>, threshold: number, worstCount?: number): RepeatabilitySummary;
|
|
312
|
+
/**
|
|
313
|
+
* The accuracy-type metrics of a set of per-case probabilities.
|
|
314
|
+
*
|
|
315
|
+
* @param points The cases.
|
|
316
|
+
* @param threshold At or above it predicts `continue`.
|
|
317
|
+
* @param resamples The bootstrap's resample count.
|
|
318
|
+
* @param seed The bootstrap's seed.
|
|
319
|
+
*/
|
|
320
|
+
export declare function ComputeProbabilityMetrics(points: readonly LabelledProbability[], threshold: number, resamples: number, seed: number): ProbabilityMetrics;
|
|
321
|
+
/**
|
|
322
|
+
* Every metric for one cell, from its runs. The runs may come in any order: the cases are put in
|
|
323
|
+
* case-ID order, and each case's repeats in ascending order, before anything is summed or drawn,
|
|
324
|
+
* so the folds, the bootstrap draws and every figure are the same for any order of the same runs.
|
|
325
|
+
*
|
|
326
|
+
* @param observations The cell's runs.
|
|
327
|
+
* @param options Threshold, bootstrap, seed, folds and worst-case count; each has a default.
|
|
328
|
+
*/
|
|
329
|
+
export declare function ComputeCellMetrics(observations: readonly DecisionEvalObservation[], options?: DecisionEvalMetricOptions): DecisionEvalCellMetrics;
|
|
330
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/decision-eval/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,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