evalsense 0.3.0 → 0.3.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 +89 -66
- package/dist/{chunk-DFC6FRTG.cjs → chunk-BFGA2NUB.cjs} +67 -8
- package/dist/chunk-BFGA2NUB.cjs.map +1 -0
- package/dist/{chunk-JPVZL45G.js → chunk-IYLSY7NX.js} +67 -8
- package/dist/chunk-IYLSY7NX.js.map +1 -0
- package/dist/cli.cjs +11 -11
- package/dist/cli.js +1 -1
- package/dist/index.cjs +101 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +23 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DFC6FRTG.cjs.map +0 -1
- package/dist/chunk-JPVZL45G.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBFGA2NUB_cjs = require('./chunk-BFGA2NUB.cjs');
|
|
4
4
|
require('./chunk-JEQ2X3Z6.cjs');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
|
|
8
8
|
// src/core/describe.ts
|
|
9
9
|
function describe(name, fn) {
|
|
10
|
-
const parentSuite =
|
|
10
|
+
const parentSuite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
11
11
|
const suite = {
|
|
12
12
|
name,
|
|
13
13
|
tests: [],
|
|
@@ -16,37 +16,37 @@ function describe(name, fn) {
|
|
|
16
16
|
beforeEach: [],
|
|
17
17
|
afterEach: []
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
chunkBFGA2NUB_cjs.setCurrentSuite(suite);
|
|
20
20
|
try {
|
|
21
21
|
fn();
|
|
22
22
|
} finally {
|
|
23
|
-
|
|
23
|
+
chunkBFGA2NUB_cjs.setCurrentSuite(parentSuite);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
chunkBFGA2NUB_cjs.addSuite(suite);
|
|
26
26
|
}
|
|
27
27
|
function beforeAll(fn) {
|
|
28
|
-
const suite =
|
|
28
|
+
const suite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
29
29
|
if (!suite) {
|
|
30
30
|
throw new Error("beforeAll() must be called inside a describe() block");
|
|
31
31
|
}
|
|
32
32
|
suite.beforeAll?.push(fn);
|
|
33
33
|
}
|
|
34
34
|
function afterAll(fn) {
|
|
35
|
-
const suite =
|
|
35
|
+
const suite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
36
36
|
if (!suite) {
|
|
37
37
|
throw new Error("afterAll() must be called inside a describe() block");
|
|
38
38
|
}
|
|
39
39
|
suite.afterAll?.push(fn);
|
|
40
40
|
}
|
|
41
41
|
function beforeEach(fn) {
|
|
42
|
-
const suite =
|
|
42
|
+
const suite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
43
43
|
if (!suite) {
|
|
44
44
|
throw new Error("beforeEach() must be called inside a describe() block");
|
|
45
45
|
}
|
|
46
46
|
suite.beforeEach?.push(fn);
|
|
47
47
|
}
|
|
48
48
|
function afterEach(fn) {
|
|
49
|
-
const suite =
|
|
49
|
+
const suite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
50
50
|
if (!suite) {
|
|
51
51
|
throw new Error("afterEach() must be called inside a describe() block");
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ function afterEach(fn) {
|
|
|
55
55
|
|
|
56
56
|
// src/core/eval-test.ts
|
|
57
57
|
function evalTest(name, fn) {
|
|
58
|
-
const currentSuite =
|
|
58
|
+
const currentSuite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
59
59
|
if (!currentSuite) {
|
|
60
60
|
throw new Error("evalTest() must be called inside a describe() block");
|
|
61
61
|
}
|
|
@@ -63,12 +63,12 @@ function evalTest(name, fn) {
|
|
|
63
63
|
name,
|
|
64
64
|
fn
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
chunkBFGA2NUB_cjs.addTestToCurrentSuite(test2);
|
|
67
67
|
}
|
|
68
68
|
var test = evalTest;
|
|
69
69
|
var it = evalTest;
|
|
70
70
|
function evalTestSkip(name, _fn) {
|
|
71
|
-
const currentSuite =
|
|
71
|
+
const currentSuite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
72
72
|
if (!currentSuite) {
|
|
73
73
|
throw new Error("evalTest.skip() must be called inside a describe() block");
|
|
74
74
|
}
|
|
@@ -77,10 +77,10 @@ function evalTestSkip(name, _fn) {
|
|
|
77
77
|
fn: async () => {
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
chunkBFGA2NUB_cjs.addTestToCurrentSuite(test2);
|
|
81
81
|
}
|
|
82
82
|
function evalTestOnly(name, fn) {
|
|
83
|
-
const currentSuite =
|
|
83
|
+
const currentSuite = chunkBFGA2NUB_cjs.getCurrentSuite();
|
|
84
84
|
if (!currentSuite) {
|
|
85
85
|
throw new Error("evalTest.only() must be called inside a describe() block");
|
|
86
86
|
}
|
|
@@ -88,7 +88,7 @@ function evalTestOnly(name, fn) {
|
|
|
88
88
|
name: `[ONLY] ${name}`,
|
|
89
89
|
fn
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
chunkBFGA2NUB_cjs.addTestToCurrentSuite(test2);
|
|
92
92
|
}
|
|
93
93
|
evalTest.skip = evalTestSkip;
|
|
94
94
|
evalTest.only = evalTestOnly;
|
|
@@ -103,17 +103,17 @@ function loadDataset(path$1) {
|
|
|
103
103
|
} else if (ext === ".json") {
|
|
104
104
|
records = parseJSON(content);
|
|
105
105
|
} else {
|
|
106
|
-
throw new
|
|
106
|
+
throw new chunkBFGA2NUB_cjs.DatasetError(
|
|
107
107
|
`Unsupported file format: ${ext}. Use .json, .ndjson, or .jsonl`,
|
|
108
108
|
path$1
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
} catch (error) {
|
|
112
|
-
if (error instanceof
|
|
112
|
+
if (error instanceof chunkBFGA2NUB_cjs.DatasetError) {
|
|
113
113
|
throw error;
|
|
114
114
|
}
|
|
115
115
|
const message = error instanceof Error ? error.message : String(error);
|
|
116
|
-
throw new
|
|
116
|
+
throw new chunkBFGA2NUB_cjs.DatasetError(`Failed to load dataset from ${path$1}: ${message}`, path$1);
|
|
117
117
|
}
|
|
118
118
|
return {
|
|
119
119
|
records,
|
|
@@ -127,7 +127,7 @@ function loadDataset(path$1) {
|
|
|
127
127
|
function parseJSON(content) {
|
|
128
128
|
const parsed = JSON.parse(content);
|
|
129
129
|
if (!Array.isArray(parsed)) {
|
|
130
|
-
throw new
|
|
130
|
+
throw new chunkBFGA2NUB_cjs.DatasetError("JSON dataset must be an array of records");
|
|
131
131
|
}
|
|
132
132
|
return parsed;
|
|
133
133
|
}
|
|
@@ -140,7 +140,7 @@ function parseNDJSON(content) {
|
|
|
140
140
|
try {
|
|
141
141
|
records.push(JSON.parse(line));
|
|
142
142
|
} catch {
|
|
143
|
-
throw new
|
|
143
|
+
throw new chunkBFGA2NUB_cjs.DatasetError(`Invalid JSON at line ${i + 1} in NDJSON file`);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
return records;
|
|
@@ -165,7 +165,7 @@ async function runModel(dataset, modelFn) {
|
|
|
165
165
|
const id = getRecordId(record);
|
|
166
166
|
const prediction = await modelFn(record);
|
|
167
167
|
if (prediction.id !== id) {
|
|
168
|
-
throw new
|
|
168
|
+
throw new chunkBFGA2NUB_cjs.DatasetError(
|
|
169
169
|
`Prediction ID mismatch: expected "${id}", got "${prediction.id}". Model function must return the same ID as the input record.`
|
|
170
170
|
);
|
|
171
171
|
}
|
|
@@ -185,7 +185,7 @@ async function runModel(dataset, modelFn) {
|
|
|
185
185
|
function getRecordId(record) {
|
|
186
186
|
const id = record.id ?? record._id;
|
|
187
187
|
if (id === void 0 || id === null) {
|
|
188
|
-
throw new
|
|
188
|
+
throw new chunkBFGA2NUB_cjs.DatasetError('Dataset records must have an "id" or "_id" field for alignment');
|
|
189
189
|
}
|
|
190
190
|
return String(id);
|
|
191
191
|
}
|
|
@@ -207,7 +207,7 @@ async function runModelParallel(dataset, modelFn, concurrency = 10) {
|
|
|
207
207
|
for (const { prediction, record } of results) {
|
|
208
208
|
const id = getRecordId(record);
|
|
209
209
|
if (prediction.id !== id) {
|
|
210
|
-
throw new
|
|
210
|
+
throw new chunkBFGA2NUB_cjs.DatasetError(`Prediction ID mismatch: expected "${id}", got "${prediction.id}".`);
|
|
211
211
|
}
|
|
212
212
|
predictions.push(prediction);
|
|
213
213
|
aligned.push({
|
|
@@ -225,16 +225,28 @@ async function runModelParallel(dataset, modelFn, concurrency = 10) {
|
|
|
225
225
|
|
|
226
226
|
// src/dataset/alignment.ts
|
|
227
227
|
function alignByKey(predictions, expected, options = {}) {
|
|
228
|
-
const { strict = false, idField
|
|
228
|
+
const { strict = false, idField, predictionIdField, expectedIdField } = options;
|
|
229
|
+
const predIdField = predictionIdField ?? idField ?? "id";
|
|
230
|
+
const expIdField = expectedIdField ?? idField ?? "id";
|
|
229
231
|
const expectedMap = /* @__PURE__ */ new Map();
|
|
230
232
|
for (const record of expected) {
|
|
231
|
-
const id = String(record[
|
|
233
|
+
const id = String(record[expIdField] ?? record._id);
|
|
234
|
+
if (!id || id === "undefined") {
|
|
235
|
+
throw new chunkBFGA2NUB_cjs.IntegrityError(
|
|
236
|
+
`Expected record missing ${expIdField} field: ${JSON.stringify(record)}`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
232
239
|
expectedMap.set(id, record);
|
|
233
240
|
}
|
|
234
241
|
const aligned = [];
|
|
235
242
|
const missingIds = [];
|
|
236
243
|
for (const prediction of predictions) {
|
|
237
|
-
const id = prediction
|
|
244
|
+
const id = String(prediction[predIdField]);
|
|
245
|
+
if (!id || id === "undefined") {
|
|
246
|
+
throw new chunkBFGA2NUB_cjs.IntegrityError(
|
|
247
|
+
`Prediction missing ${predIdField} field: ${JSON.stringify(prediction)}`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
238
250
|
const expectedRecord = expectedMap.get(id);
|
|
239
251
|
if (!expectedRecord) {
|
|
240
252
|
missingIds.push(id);
|
|
@@ -255,7 +267,7 @@ function alignByKey(predictions, expected, options = {}) {
|
|
|
255
267
|
}
|
|
256
268
|
}
|
|
257
269
|
if (strict && missingIds.length > 0) {
|
|
258
|
-
throw new
|
|
270
|
+
throw new chunkBFGA2NUB_cjs.IntegrityError(
|
|
259
271
|
`${missingIds.length} prediction(s) have no matching expected record`,
|
|
260
272
|
missingIds
|
|
261
273
|
);
|
|
@@ -334,7 +346,7 @@ function checkIntegrity(dataset, options = {}) {
|
|
|
334
346
|
if (missingFields.length > 0) {
|
|
335
347
|
issues.push(`${missingFields.length} record(s) missing required fields`);
|
|
336
348
|
}
|
|
337
|
-
throw new
|
|
349
|
+
throw new chunkBFGA2NUB_cjs.IntegrityError(`Dataset integrity check failed: ${issues.join("; ")}`);
|
|
338
350
|
}
|
|
339
351
|
return result;
|
|
340
352
|
}
|
|
@@ -352,7 +364,7 @@ function validatePredictions(predictions, expectedIds) {
|
|
|
352
364
|
|
|
353
365
|
// src/statistics/classification.ts
|
|
354
366
|
function computeClassificationMetrics(actual, expected) {
|
|
355
|
-
const confusionMatrix =
|
|
367
|
+
const confusionMatrix = chunkBFGA2NUB_cjs.buildConfusionMatrix(actual, expected);
|
|
356
368
|
return computeMetricsFromMatrix(confusionMatrix);
|
|
357
369
|
}
|
|
358
370
|
function computeMetricsFromMatrix(cm) {
|
|
@@ -360,10 +372,10 @@ function computeMetricsFromMatrix(cm) {
|
|
|
360
372
|
let totalSupport = 0;
|
|
361
373
|
let correctPredictions = 0;
|
|
362
374
|
for (const label of cm.labels) {
|
|
363
|
-
const tp =
|
|
364
|
-
const fp =
|
|
365
|
-
const fn =
|
|
366
|
-
const support =
|
|
375
|
+
const tp = chunkBFGA2NUB_cjs.getTruePositives(cm, label);
|
|
376
|
+
const fp = chunkBFGA2NUB_cjs.getFalsePositives(cm, label);
|
|
377
|
+
const fn = chunkBFGA2NUB_cjs.getFalseNegatives(cm, label);
|
|
378
|
+
const support = chunkBFGA2NUB_cjs.getSupport(cm, label);
|
|
367
379
|
const precision = tp + fp > 0 ? tp / (tp + fp) : 0;
|
|
368
380
|
const recall = tp + fn > 0 ? tp / (tp + fn) : 0;
|
|
369
381
|
const f1 = precision + recall > 0 ? 2 * precision * recall / (precision + recall) : 0;
|
|
@@ -392,15 +404,15 @@ function computeMetricsFromMatrix(cm) {
|
|
|
392
404
|
};
|
|
393
405
|
}
|
|
394
406
|
function computePrecision(actual, expected, targetClass) {
|
|
395
|
-
const cm =
|
|
396
|
-
const tp =
|
|
397
|
-
const fp =
|
|
407
|
+
const cm = chunkBFGA2NUB_cjs.buildConfusionMatrix(actual, expected);
|
|
408
|
+
const tp = chunkBFGA2NUB_cjs.getTruePositives(cm, targetClass);
|
|
409
|
+
const fp = chunkBFGA2NUB_cjs.getFalsePositives(cm, targetClass);
|
|
398
410
|
return tp + fp > 0 ? tp / (tp + fp) : 0;
|
|
399
411
|
}
|
|
400
412
|
function computeRecall(actual, expected, targetClass) {
|
|
401
|
-
const cm =
|
|
402
|
-
const tp =
|
|
403
|
-
const fn =
|
|
413
|
+
const cm = chunkBFGA2NUB_cjs.buildConfusionMatrix(actual, expected);
|
|
414
|
+
const tp = chunkBFGA2NUB_cjs.getTruePositives(cm, targetClass);
|
|
415
|
+
const fn = chunkBFGA2NUB_cjs.getFalseNegatives(cm, targetClass);
|
|
404
416
|
return tp + fn > 0 ? tp / (tp + fn) : 0;
|
|
405
417
|
}
|
|
406
418
|
function computeF1(actual, expected, targetClass) {
|
|
@@ -555,10 +567,7 @@ var BinarizeSelector = class {
|
|
|
555
567
|
field: this.fieldName
|
|
556
568
|
};
|
|
557
569
|
this.assertions.push(result);
|
|
558
|
-
|
|
559
|
-
if (!passed) {
|
|
560
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, threshold, metrics.accuracy, this.fieldName);
|
|
561
|
-
}
|
|
570
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
562
571
|
return this;
|
|
563
572
|
}
|
|
564
573
|
/**
|
|
@@ -579,7 +588,7 @@ var BinarizeSelector = class {
|
|
|
579
588
|
actualThreshold = threshold;
|
|
580
589
|
const classMetrics = metrics.perClass[targetClass];
|
|
581
590
|
if (!classMetrics) {
|
|
582
|
-
throw new
|
|
591
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
583
592
|
`Class "${targetClass}" not found in binarized predictions`,
|
|
584
593
|
targetClass,
|
|
585
594
|
Object.keys(metrics.perClass),
|
|
@@ -599,10 +608,7 @@ var BinarizeSelector = class {
|
|
|
599
608
|
class: targetClass
|
|
600
609
|
};
|
|
601
610
|
this.assertions.push(result);
|
|
602
|
-
|
|
603
|
-
if (!passed) {
|
|
604
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualPrecision, this.fieldName);
|
|
605
|
-
}
|
|
611
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
606
612
|
return this;
|
|
607
613
|
}
|
|
608
614
|
/**
|
|
@@ -623,7 +629,7 @@ var BinarizeSelector = class {
|
|
|
623
629
|
actualThreshold = threshold;
|
|
624
630
|
const classMetrics = metrics.perClass[targetClass];
|
|
625
631
|
if (!classMetrics) {
|
|
626
|
-
throw new
|
|
632
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
627
633
|
`Class "${targetClass}" not found in binarized predictions`,
|
|
628
634
|
targetClass,
|
|
629
635
|
Object.keys(metrics.perClass),
|
|
@@ -643,10 +649,7 @@ var BinarizeSelector = class {
|
|
|
643
649
|
class: targetClass
|
|
644
650
|
};
|
|
645
651
|
this.assertions.push(result);
|
|
646
|
-
|
|
647
|
-
if (!passed) {
|
|
648
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualRecall, this.fieldName);
|
|
649
|
-
}
|
|
652
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
650
653
|
return this;
|
|
651
654
|
}
|
|
652
655
|
/**
|
|
@@ -665,7 +668,7 @@ var BinarizeSelector = class {
|
|
|
665
668
|
actualThreshold = threshold;
|
|
666
669
|
const classMetrics = metrics.perClass[targetClass];
|
|
667
670
|
if (!classMetrics) {
|
|
668
|
-
throw new
|
|
671
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
669
672
|
`Class "${targetClass}" not found in binarized predictions`,
|
|
670
673
|
targetClass,
|
|
671
674
|
Object.keys(metrics.perClass),
|
|
@@ -685,10 +688,7 @@ var BinarizeSelector = class {
|
|
|
685
688
|
class: targetClass
|
|
686
689
|
};
|
|
687
690
|
this.assertions.push(result);
|
|
688
|
-
|
|
689
|
-
if (!passed) {
|
|
690
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualF1, this.fieldName);
|
|
691
|
-
}
|
|
691
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
692
692
|
return this;
|
|
693
693
|
}
|
|
694
694
|
/**
|
|
@@ -702,7 +702,7 @@ var BinarizeSelector = class {
|
|
|
702
702
|
binarized: true,
|
|
703
703
|
binarizeThreshold: this.threshold
|
|
704
704
|
};
|
|
705
|
-
|
|
705
|
+
chunkBFGA2NUB_cjs.recordFieldMetrics(fieldResult);
|
|
706
706
|
const result = {
|
|
707
707
|
type: "confusionMatrix",
|
|
708
708
|
passed: true,
|
|
@@ -710,7 +710,7 @@ var BinarizeSelector = class {
|
|
|
710
710
|
field: this.fieldName
|
|
711
711
|
};
|
|
712
712
|
this.assertions.push(result);
|
|
713
|
-
|
|
713
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
714
714
|
return this;
|
|
715
715
|
}
|
|
716
716
|
/**
|
|
@@ -754,7 +754,7 @@ var FieldSelector = class {
|
|
|
754
754
|
validateGroundTruth() {
|
|
755
755
|
const hasExpected = this.expectedValues.some((v) => v !== void 0 && v !== null);
|
|
756
756
|
if (!hasExpected) {
|
|
757
|
-
throw new
|
|
757
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
758
758
|
`Classification metric requires ground truth, but field "${this.fieldName}" has no expected values. Use expectStats(predictions, groundTruth) to provide expected values.`,
|
|
759
759
|
void 0,
|
|
760
760
|
void 0,
|
|
@@ -778,10 +778,7 @@ var FieldSelector = class {
|
|
|
778
778
|
field: this.fieldName
|
|
779
779
|
};
|
|
780
780
|
this.assertions.push(result);
|
|
781
|
-
|
|
782
|
-
if (!passed) {
|
|
783
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, threshold, metrics.accuracy, this.fieldName);
|
|
784
|
-
}
|
|
781
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
785
782
|
return this;
|
|
786
783
|
}
|
|
787
784
|
/**
|
|
@@ -803,7 +800,7 @@ var FieldSelector = class {
|
|
|
803
800
|
actualThreshold = threshold;
|
|
804
801
|
const classMetrics = metrics.perClass[targetClass];
|
|
805
802
|
if (!classMetrics) {
|
|
806
|
-
throw new
|
|
803
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
807
804
|
`Class "${targetClass}" not found in predictions`,
|
|
808
805
|
targetClass,
|
|
809
806
|
Object.keys(metrics.perClass),
|
|
@@ -823,10 +820,7 @@ var FieldSelector = class {
|
|
|
823
820
|
class: targetClass
|
|
824
821
|
};
|
|
825
822
|
this.assertions.push(result);
|
|
826
|
-
|
|
827
|
-
if (!passed) {
|
|
828
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualPrecision, this.fieldName);
|
|
829
|
-
}
|
|
823
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
830
824
|
return this;
|
|
831
825
|
}
|
|
832
826
|
/**
|
|
@@ -848,7 +842,7 @@ var FieldSelector = class {
|
|
|
848
842
|
actualThreshold = threshold;
|
|
849
843
|
const classMetrics = metrics.perClass[targetClass];
|
|
850
844
|
if (!classMetrics) {
|
|
851
|
-
throw new
|
|
845
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
852
846
|
`Class "${targetClass}" not found in predictions`,
|
|
853
847
|
targetClass,
|
|
854
848
|
Object.keys(metrics.perClass),
|
|
@@ -868,10 +862,7 @@ var FieldSelector = class {
|
|
|
868
862
|
class: targetClass
|
|
869
863
|
};
|
|
870
864
|
this.assertions.push(result);
|
|
871
|
-
|
|
872
|
-
if (!passed) {
|
|
873
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualRecall, this.fieldName);
|
|
874
|
-
}
|
|
865
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
875
866
|
return this;
|
|
876
867
|
}
|
|
877
868
|
/**
|
|
@@ -893,7 +884,7 @@ var FieldSelector = class {
|
|
|
893
884
|
actualThreshold = threshold;
|
|
894
885
|
const classMetrics = metrics.perClass[targetClass];
|
|
895
886
|
if (!classMetrics) {
|
|
896
|
-
throw new
|
|
887
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
897
888
|
`Class "${targetClass}" not found in predictions`,
|
|
898
889
|
targetClass,
|
|
899
890
|
Object.keys(metrics.perClass),
|
|
@@ -913,10 +904,7 @@ var FieldSelector = class {
|
|
|
913
904
|
class: targetClass
|
|
914
905
|
};
|
|
915
906
|
this.assertions.push(result);
|
|
916
|
-
|
|
917
|
-
if (!passed) {
|
|
918
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, actualThreshold, actualF1, this.fieldName);
|
|
919
|
-
}
|
|
907
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
920
908
|
return this;
|
|
921
909
|
}
|
|
922
910
|
/**
|
|
@@ -929,7 +917,7 @@ var FieldSelector = class {
|
|
|
929
917
|
metrics,
|
|
930
918
|
binarized: false
|
|
931
919
|
};
|
|
932
|
-
|
|
920
|
+
chunkBFGA2NUB_cjs.recordFieldMetrics(fieldResult);
|
|
933
921
|
const result = {
|
|
934
922
|
type: "confusionMatrix",
|
|
935
923
|
passed: true,
|
|
@@ -937,7 +925,7 @@ var FieldSelector = class {
|
|
|
937
925
|
field: this.fieldName
|
|
938
926
|
};
|
|
939
927
|
this.assertions.push(result);
|
|
940
|
-
|
|
928
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
941
929
|
return this;
|
|
942
930
|
}
|
|
943
931
|
/**
|
|
@@ -957,7 +945,7 @@ var FieldSelector = class {
|
|
|
957
945
|
toHavePercentageBelow(valueThreshold, percentageThreshold) {
|
|
958
946
|
const numericActual = filterNumericValues(this.actualValues);
|
|
959
947
|
if (numericActual.length === 0) {
|
|
960
|
-
throw new
|
|
948
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
961
949
|
`Field '${this.fieldName}' contains no numeric values (found 0 numeric out of ${this.actualValues.length} total values)`,
|
|
962
950
|
percentageThreshold,
|
|
963
951
|
void 0,
|
|
@@ -975,15 +963,7 @@ var FieldSelector = class {
|
|
|
975
963
|
field: this.fieldName
|
|
976
964
|
};
|
|
977
965
|
this.assertions.push(result);
|
|
978
|
-
|
|
979
|
-
if (!passed) {
|
|
980
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(
|
|
981
|
-
result.message,
|
|
982
|
-
percentageThreshold,
|
|
983
|
-
actualPercentage,
|
|
984
|
-
this.fieldName
|
|
985
|
-
);
|
|
986
|
-
}
|
|
966
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
987
967
|
return this;
|
|
988
968
|
}
|
|
989
969
|
/**
|
|
@@ -1003,7 +983,7 @@ var FieldSelector = class {
|
|
|
1003
983
|
toHavePercentageAbove(valueThreshold, percentageThreshold) {
|
|
1004
984
|
const numericActual = filterNumericValues(this.actualValues);
|
|
1005
985
|
if (numericActual.length === 0) {
|
|
1006
|
-
throw new
|
|
986
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
1007
987
|
`Field '${this.fieldName}' contains no numeric values (found 0 numeric out of ${this.actualValues.length} total values)`,
|
|
1008
988
|
percentageThreshold,
|
|
1009
989
|
void 0,
|
|
@@ -1021,15 +1001,7 @@ var FieldSelector = class {
|
|
|
1021
1001
|
field: this.fieldName
|
|
1022
1002
|
};
|
|
1023
1003
|
this.assertions.push(result);
|
|
1024
|
-
|
|
1025
|
-
if (!passed) {
|
|
1026
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(
|
|
1027
|
-
result.message,
|
|
1028
|
-
percentageThreshold,
|
|
1029
|
-
actualPercentage,
|
|
1030
|
-
this.fieldName
|
|
1031
|
-
);
|
|
1032
|
-
}
|
|
1004
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
1033
1005
|
return this;
|
|
1034
1006
|
}
|
|
1035
1007
|
// ============================================================================
|
|
@@ -1044,7 +1016,7 @@ var FieldSelector = class {
|
|
|
1044
1016
|
const numericActual = filterNumericValues(this.actualValues);
|
|
1045
1017
|
const numericExpected = filterNumericValues(this.expectedValues);
|
|
1046
1018
|
if (numericActual.length === 0) {
|
|
1047
|
-
throw new
|
|
1019
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
1048
1020
|
`Regression metric requires numeric values, but field "${this.fieldName}" has no numeric actual values.`,
|
|
1049
1021
|
void 0,
|
|
1050
1022
|
void 0,
|
|
@@ -1052,7 +1024,7 @@ var FieldSelector = class {
|
|
|
1052
1024
|
);
|
|
1053
1025
|
}
|
|
1054
1026
|
if (numericExpected.length === 0) {
|
|
1055
|
-
throw new
|
|
1027
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
1056
1028
|
`Regression metric requires numeric values, but field "${this.fieldName}" has no numeric expected values.`,
|
|
1057
1029
|
void 0,
|
|
1058
1030
|
void 0,
|
|
@@ -1060,7 +1032,7 @@ var FieldSelector = class {
|
|
|
1060
1032
|
);
|
|
1061
1033
|
}
|
|
1062
1034
|
if (numericActual.length !== numericExpected.length) {
|
|
1063
|
-
throw new
|
|
1035
|
+
throw new chunkBFGA2NUB_cjs.AssertionError(
|
|
1064
1036
|
`Regression metric requires equal-length arrays, but got ${numericActual.length} actual and ${numericExpected.length} expected values.`,
|
|
1065
1037
|
numericExpected.length,
|
|
1066
1038
|
numericActual.length,
|
|
@@ -1094,10 +1066,7 @@ var FieldSelector = class {
|
|
|
1094
1066
|
field: this.fieldName
|
|
1095
1067
|
};
|
|
1096
1068
|
this.assertions.push(result);
|
|
1097
|
-
|
|
1098
|
-
if (!passed) {
|
|
1099
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, threshold, metrics.mae, this.fieldName);
|
|
1100
|
-
}
|
|
1069
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
1101
1070
|
return this;
|
|
1102
1071
|
}
|
|
1103
1072
|
/**
|
|
@@ -1125,10 +1094,7 @@ var FieldSelector = class {
|
|
|
1125
1094
|
field: this.fieldName
|
|
1126
1095
|
};
|
|
1127
1096
|
this.assertions.push(result);
|
|
1128
|
-
|
|
1129
|
-
if (!passed) {
|
|
1130
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, threshold, metrics.rmse, this.fieldName);
|
|
1131
|
-
}
|
|
1097
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
1132
1098
|
return this;
|
|
1133
1099
|
}
|
|
1134
1100
|
/**
|
|
@@ -1158,10 +1124,7 @@ var FieldSelector = class {
|
|
|
1158
1124
|
field: this.fieldName
|
|
1159
1125
|
};
|
|
1160
1126
|
this.assertions.push(result);
|
|
1161
|
-
|
|
1162
|
-
if (!passed) {
|
|
1163
|
-
throw new chunkDFC6FRTG_cjs.AssertionError(result.message, threshold, metrics.r2, this.fieldName);
|
|
1164
|
-
}
|
|
1127
|
+
chunkBFGA2NUB_cjs.recordAssertion(result);
|
|
1165
1128
|
return this;
|
|
1166
1129
|
}
|
|
1167
1130
|
/**
|
|
@@ -1206,7 +1169,12 @@ function expectStats(inputOrActual, expected, options) {
|
|
|
1206
1169
|
if (!Array.isArray(inputOrActual)) {
|
|
1207
1170
|
throw new Error("When using two-argument expectStats(), first argument must be Prediction[]");
|
|
1208
1171
|
}
|
|
1209
|
-
const alignOptions = options ? {
|
|
1172
|
+
const alignOptions = options ? {
|
|
1173
|
+
idField: options.idField,
|
|
1174
|
+
predictionIdField: options.predictionIdField,
|
|
1175
|
+
expectedIdField: options.expectedIdField,
|
|
1176
|
+
strict: options.strict
|
|
1177
|
+
} : void 0;
|
|
1210
1178
|
const aligned2 = alignByKey(inputOrActual, expected, alignOptions);
|
|
1211
1179
|
return new ExpectStats(aligned2);
|
|
1212
1180
|
}
|
|
@@ -1240,63 +1208,63 @@ var ExpectStats = class {
|
|
|
1240
1208
|
|
|
1241
1209
|
Object.defineProperty(exports, "AssertionError", {
|
|
1242
1210
|
enumerable: true,
|
|
1243
|
-
get: function () { return
|
|
1211
|
+
get: function () { return chunkBFGA2NUB_cjs.AssertionError; }
|
|
1244
1212
|
});
|
|
1245
1213
|
Object.defineProperty(exports, "ConfigurationError", {
|
|
1246
1214
|
enumerable: true,
|
|
1247
|
-
get: function () { return
|
|
1215
|
+
get: function () { return chunkBFGA2NUB_cjs.ConfigurationError; }
|
|
1248
1216
|
});
|
|
1249
1217
|
Object.defineProperty(exports, "ConsoleReporter", {
|
|
1250
1218
|
enumerable: true,
|
|
1251
|
-
get: function () { return
|
|
1219
|
+
get: function () { return chunkBFGA2NUB_cjs.ConsoleReporter; }
|
|
1252
1220
|
});
|
|
1253
1221
|
Object.defineProperty(exports, "DatasetError", {
|
|
1254
1222
|
enumerable: true,
|
|
1255
|
-
get: function () { return
|
|
1223
|
+
get: function () { return chunkBFGA2NUB_cjs.DatasetError; }
|
|
1256
1224
|
});
|
|
1257
1225
|
Object.defineProperty(exports, "EvalSenseError", {
|
|
1258
1226
|
enumerable: true,
|
|
1259
|
-
get: function () { return
|
|
1227
|
+
get: function () { return chunkBFGA2NUB_cjs.EvalSenseError; }
|
|
1260
1228
|
});
|
|
1261
1229
|
Object.defineProperty(exports, "ExitCodes", {
|
|
1262
1230
|
enumerable: true,
|
|
1263
|
-
get: function () { return
|
|
1231
|
+
get: function () { return chunkBFGA2NUB_cjs.ExitCodes; }
|
|
1264
1232
|
});
|
|
1265
1233
|
Object.defineProperty(exports, "IntegrityError", {
|
|
1266
1234
|
enumerable: true,
|
|
1267
|
-
get: function () { return
|
|
1235
|
+
get: function () { return chunkBFGA2NUB_cjs.IntegrityError; }
|
|
1268
1236
|
});
|
|
1269
1237
|
Object.defineProperty(exports, "JsonReporter", {
|
|
1270
1238
|
enumerable: true,
|
|
1271
|
-
get: function () { return
|
|
1239
|
+
get: function () { return chunkBFGA2NUB_cjs.JsonReporter; }
|
|
1272
1240
|
});
|
|
1273
1241
|
Object.defineProperty(exports, "TestExecutionError", {
|
|
1274
1242
|
enumerable: true,
|
|
1275
|
-
get: function () { return
|
|
1243
|
+
get: function () { return chunkBFGA2NUB_cjs.TestExecutionError; }
|
|
1276
1244
|
});
|
|
1277
1245
|
Object.defineProperty(exports, "buildConfusionMatrix", {
|
|
1278
1246
|
enumerable: true,
|
|
1279
|
-
get: function () { return
|
|
1247
|
+
get: function () { return chunkBFGA2NUB_cjs.buildConfusionMatrix; }
|
|
1280
1248
|
});
|
|
1281
1249
|
Object.defineProperty(exports, "discoverEvalFiles", {
|
|
1282
1250
|
enumerable: true,
|
|
1283
|
-
get: function () { return
|
|
1251
|
+
get: function () { return chunkBFGA2NUB_cjs.discoverEvalFiles; }
|
|
1284
1252
|
});
|
|
1285
1253
|
Object.defineProperty(exports, "executeEvalFiles", {
|
|
1286
1254
|
enumerable: true,
|
|
1287
|
-
get: function () { return
|
|
1255
|
+
get: function () { return chunkBFGA2NUB_cjs.executeEvalFiles; }
|
|
1288
1256
|
});
|
|
1289
1257
|
Object.defineProperty(exports, "formatConfusionMatrix", {
|
|
1290
1258
|
enumerable: true,
|
|
1291
|
-
get: function () { return
|
|
1259
|
+
get: function () { return chunkBFGA2NUB_cjs.formatConfusionMatrix; }
|
|
1292
1260
|
});
|
|
1293
1261
|
Object.defineProperty(exports, "getExitCode", {
|
|
1294
1262
|
enumerable: true,
|
|
1295
|
-
get: function () { return
|
|
1263
|
+
get: function () { return chunkBFGA2NUB_cjs.getExitCode; }
|
|
1296
1264
|
});
|
|
1297
1265
|
Object.defineProperty(exports, "parseReport", {
|
|
1298
1266
|
enumerable: true,
|
|
1299
|
-
get: function () { return
|
|
1267
|
+
get: function () { return chunkBFGA2NUB_cjs.parseReport; }
|
|
1300
1268
|
});
|
|
1301
1269
|
exports.afterAll = afterAll;
|
|
1302
1270
|
exports.afterEach = afterEach;
|