@zukhruf/evals 0.8.3 → 0.8.5

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.
Files changed (179) hide show
  1. package/NOTICE +3 -3
  2. package/README.md +152 -79
  3. package/dist/aggregation/f-measure-form.d.ts +11 -0
  4. package/dist/aggregation/f-measure-form.d.ts.map +1 -0
  5. package/dist/aggregation/f-measure-form.js +25 -0
  6. package/dist/aggregation/f-measure-form.js.map +1 -0
  7. package/dist/aggregation/f-measure-ratio.d.ts +12 -0
  8. package/dist/aggregation/f-measure-ratio.d.ts.map +1 -0
  9. package/dist/aggregation/f-measure-ratio.js +21 -0
  10. package/dist/aggregation/f-measure-ratio.js.map +1 -0
  11. package/dist/aggregation/ratio-of-sums.d.ts +1 -0
  12. package/dist/aggregation/ratio-of-sums.d.ts.map +1 -1
  13. package/dist/aggregation/ratio-of-sums.js +7 -0
  14. package/dist/aggregation/ratio-of-sums.js.map +1 -1
  15. package/dist/classification/all-class-matches.d.ts +7 -0
  16. package/dist/classification/all-class-matches.d.ts.map +1 -0
  17. package/dist/classification/all-class-matches.js +14 -0
  18. package/dist/classification/all-class-matches.js.map +1 -0
  19. package/dist/classification/average.d.ts +11 -0
  20. package/dist/classification/average.d.ts.map +1 -0
  21. package/dist/classification/average.js +2 -0
  22. package/dist/classification/average.js.map +1 -0
  23. package/dist/classification/binary-average.d.ts +9 -0
  24. package/dist/classification/binary-average.d.ts.map +1 -0
  25. package/dist/classification/binary-average.js +20 -0
  26. package/dist/classification/binary-average.js.map +1 -0
  27. package/dist/classification/brier-score.d.ts +13 -0
  28. package/dist/classification/brier-score.d.ts.map +1 -0
  29. package/dist/classification/brier-score.js +52 -0
  30. package/dist/classification/brier-score.js.map +1 -0
  31. package/dist/classification/class-counts.d.ts +39 -0
  32. package/dist/classification/class-counts.d.ts.map +1 -0
  33. package/dist/classification/class-counts.js +159 -0
  34. package/dist/classification/class-counts.js.map +1 -0
  35. package/dist/classification/class-matches.d.ts +10 -0
  36. package/dist/classification/class-matches.d.ts.map +1 -0
  37. package/dist/classification/class-matches.js +21 -0
  38. package/dist/classification/class-matches.js.map +1 -0
  39. package/dist/classification/confusion-matrix.d.ts +9 -0
  40. package/dist/classification/confusion-matrix.d.ts.map +1 -0
  41. package/dist/classification/confusion-matrix.js +18 -0
  42. package/dist/classification/confusion-matrix.js.map +1 -0
  43. package/dist/classification/index.d.ts +21 -0
  44. package/dist/classification/index.d.ts.map +1 -0
  45. package/dist/classification/index.js +19 -0
  46. package/dist/classification/index.js.map +1 -0
  47. package/dist/classification/label-case.d.ts +11 -0
  48. package/dist/classification/label-case.d.ts.map +1 -0
  49. package/dist/classification/label-case.js +12 -0
  50. package/dist/classification/label-case.js.map +1 -0
  51. package/dist/classification/label-comparer.d.ts +8 -0
  52. package/dist/classification/label-comparer.d.ts.map +1 -0
  53. package/dist/classification/label-comparer.js +44 -0
  54. package/dist/classification/label-comparer.js.map +1 -0
  55. package/dist/classification/label-comparison.d.ts +12 -0
  56. package/dist/classification/label-comparison.d.ts.map +1 -0
  57. package/dist/classification/label-comparison.js +23 -0
  58. package/dist/classification/label-comparison.js.map +1 -0
  59. package/dist/classification/label-config-case.d.ts +6 -0
  60. package/dist/classification/label-config-case.d.ts.map +1 -0
  61. package/dist/classification/label-config-case.js +13 -0
  62. package/dist/classification/label-config-case.js.map +1 -0
  63. package/dist/classification/label-vars-case.d.ts +6 -0
  64. package/dist/classification/label-vars-case.d.ts.map +1 -0
  65. package/dist/classification/label-vars-case.js +17 -0
  66. package/dist/classification/label-vars-case.js.map +1 -0
  67. package/dist/classification/label.d.ts +4 -0
  68. package/dist/classification/label.d.ts.map +1 -0
  69. package/dist/classification/label.js +16 -0
  70. package/dist/classification/label.js.map +1 -0
  71. package/dist/classification/labels-match.d.ts +7 -0
  72. package/dist/classification/labels-match.d.ts.map +1 -0
  73. package/dist/classification/labels-match.js +13 -0
  74. package/dist/classification/labels-match.js.map +1 -0
  75. package/dist/classification/macro-average.d.ts +6 -0
  76. package/dist/classification/macro-average.d.ts.map +1 -0
  77. package/dist/classification/macro-average.js +15 -0
  78. package/dist/classification/macro-average.js.map +1 -0
  79. package/dist/classification/micro-average.d.ts +6 -0
  80. package/dist/classification/micro-average.d.ts.map +1 -0
  81. package/dist/classification/micro-average.js +16 -0
  82. package/dist/classification/micro-average.js.map +1 -0
  83. package/dist/classification/per-class.d.ts +12 -0
  84. package/dist/classification/per-class.d.ts.map +1 -0
  85. package/dist/classification/per-class.js +17 -0
  86. package/dist/classification/per-class.js.map +1 -0
  87. package/dist/classification/probability-comparer.d.ts +8 -0
  88. package/dist/classification/probability-comparer.d.ts.map +1 -0
  89. package/dist/classification/probability-comparer.js +35 -0
  90. package/dist/classification/probability-comparer.js.map +1 -0
  91. package/dist/classification/probability-comparison.d.ts +10 -0
  92. package/dist/classification/probability-comparison.d.ts.map +1 -0
  93. package/dist/classification/probability-comparison.js +11 -0
  94. package/dist/classification/probability-comparison.js.map +1 -0
  95. package/dist/classification/read-labels.d.ts +3 -0
  96. package/dist/classification/read-labels.d.ts.map +1 -0
  97. package/dist/classification/read-labels.js +11 -0
  98. package/dist/classification/read-labels.js.map +1 -0
  99. package/dist/classification/weighted-average.d.ts +6 -0
  100. package/dist/classification/weighted-average.d.ts.map +1 -0
  101. package/dist/classification/weighted-average.js +20 -0
  102. package/dist/classification/weighted-average.js.map +1 -0
  103. package/dist/index.d.ts +5 -1
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +4 -1
  106. package/dist/index.js.map +1 -1
  107. package/dist/promptfoo/index.d.ts +1 -0
  108. package/dist/promptfoo/index.d.ts.map +1 -1
  109. package/dist/promptfoo/index.js +1 -0
  110. package/dist/promptfoo/index.js.map +1 -1
  111. package/dist/promptfoo/scorer-assertion.d.ts +18 -0
  112. package/dist/promptfoo/scorer-assertion.d.ts.map +1 -0
  113. package/dist/{structured/promptfoo → promptfoo}/scorer-assertion.js +5 -11
  114. package/dist/promptfoo/scorer-assertion.js.map +1 -0
  115. package/dist/scorers/f-beta.d.ts +13 -0
  116. package/dist/scorers/f-beta.d.ts.map +1 -0
  117. package/dist/scorers/f-beta.js +22 -0
  118. package/dist/scorers/f-beta.js.map +1 -0
  119. package/dist/scorers/f1.d.ts +6 -6
  120. package/dist/scorers/f1.d.ts.map +1 -1
  121. package/dist/scorers/f1.js +5 -9
  122. package/dist/scorers/f1.js.map +1 -1
  123. package/dist/scorers/penalized.d.ts.map +1 -1
  124. package/dist/scorers/penalized.js +2 -1
  125. package/dist/scorers/penalized.js.map +1 -1
  126. package/dist/scoring/bootstrap.js +3 -5
  127. package/dist/scoring/bootstrap.js.map +1 -1
  128. package/dist/scoring/comparer.d.ts +5 -0
  129. package/dist/scoring/comparer.d.ts.map +1 -0
  130. package/dist/scoring/comparer.js +2 -0
  131. package/dist/scoring/comparer.js.map +1 -0
  132. package/dist/scoring/grouped.d.ts +9 -0
  133. package/dist/scoring/grouped.d.ts.map +1 -0
  134. package/dist/scoring/grouped.js +20 -0
  135. package/dist/scoring/grouped.js.map +1 -0
  136. package/dist/scoring/scorer-set.d.ts +13 -0
  137. package/dist/scoring/scorer-set.d.ts.map +1 -0
  138. package/dist/scoring/scorer-set.js +55 -0
  139. package/dist/scoring/scorer-set.js.map +1 -0
  140. package/dist/structured/comparison/comparators/token-overlap-at-least.d.ts +4 -1
  141. package/dist/structured/comparison/comparators/token-overlap-at-least.d.ts.map +1 -1
  142. package/dist/structured/comparison/comparators/token-overlap-at-least.js +7 -4
  143. package/dist/structured/comparison/comparators/token-overlap-at-least.js.map +1 -1
  144. package/dist/structured/comparison/json-value.d.ts +1 -0
  145. package/dist/structured/comparison/json-value.d.ts.map +1 -1
  146. package/dist/structured/comparison/json-value.js +11 -2
  147. package/dist/structured/comparison/json-value.js.map +1 -1
  148. package/dist/structured/comparison/tree-walk.d.ts +5 -5
  149. package/dist/structured/comparison/tree-walk.d.ts.map +1 -1
  150. package/dist/structured/comparison/tree-walk.js +8 -4
  151. package/dist/structured/comparison/tree-walk.js.map +1 -1
  152. package/dist/structured/cpython/python-text.d.ts +0 -1
  153. package/dist/structured/cpython/python-text.d.ts.map +1 -1
  154. package/dist/structured/cpython/python-text.js +1 -18
  155. package/dist/structured/cpython/python-text.js.map +1 -1
  156. package/dist/structured/index.d.ts +0 -2
  157. package/dist/structured/index.d.ts.map +1 -1
  158. package/dist/structured/index.js +0 -2
  159. package/dist/structured/index.js.map +1 -1
  160. package/dist/structured/scorers/token-f1.d.ts +3 -1
  161. package/dist/structured/scorers/token-f1.d.ts.map +1 -1
  162. package/dist/structured/scorers/token-f1.js +8 -5
  163. package/dist/structured/scorers/token-f1.js.map +1 -1
  164. package/dist/structured/scoring/per-field.d.ts +3 -6
  165. package/dist/structured/scoring/per-field.d.ts.map +1 -1
  166. package/dist/structured/scoring/per-field.js +8 -17
  167. package/dist/structured/scoring/per-field.js.map +1 -1
  168. package/package.json +18 -5
  169. package/dist/aggregation/f1-ratio.d.ts +0 -8
  170. package/dist/aggregation/f1-ratio.d.ts.map +0 -1
  171. package/dist/aggregation/f1-ratio.js +0 -24
  172. package/dist/aggregation/f1-ratio.js.map +0 -1
  173. package/dist/structured/promptfoo/scorer-assertion.d.ts +0 -22
  174. package/dist/structured/promptfoo/scorer-assertion.d.ts.map +0 -1
  175. package/dist/structured/promptfoo/scorer-assertion.js.map +0 -1
  176. package/dist/structured/scoring/scorer-set.d.ts +0 -15
  177. package/dist/structured/scoring/scorer-set.d.ts.map +0 -1
  178. package/dist/structured/scoring/scorer-set.js +0 -60
  179. package/dist/structured/scoring/scorer-set.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import type { CaseReader } from '../scoring/scorecard-scorer.ts';
2
+ import { LabelCase } from './label-case.ts';
3
+ export declare class LabelConfigCase implements CaseReader<LabelCase> {
4
+ from(config: Readonly<Record<string, unknown>>): LabelCase;
5
+ }
6
+ //# sourceMappingURL=label-config-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-config-case.d.ts","sourceRoot":"","sources":["../../src/classification/label-config-case.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,qBAAa,eAAgB,YAAW,UAAU,CAAC,SAAS,CAAC;IAC3D,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS;CAM3D"}
@@ -0,0 +1,13 @@
1
+ import { LabelCase } from "./label-case.js";
2
+ import { readLabels } from "./read-labels.js";
3
+ // Reads a case from the config of an assertion: config.expected is a label
4
+ // or a list of labels. A case weighs 1 (Strategy).
5
+ export class LabelConfigCase {
6
+ from(config) {
7
+ return new LabelCase({
8
+ expected: readLabels(config['expected'], 'config.expected'),
9
+ weight: 1,
10
+ });
11
+ }
12
+ }
13
+ //# sourceMappingURL=label-config-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-config-case.js","sourceRoot":"","sources":["../../src/classification/label-config-case.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,2EAA2E;AAC3E,mDAAmD;AACnD,MAAM,OAAO,eAAe;IAC1B,IAAI,CAAC,MAAyC;QAC5C,OAAO,IAAI,SAAS,CAAC;YACnB,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;YAC3D,MAAM,EAAE,CAAC;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import type { CaseReader } from '../scoring/scorecard-scorer.ts';
2
+ import { LabelCase } from './label-case.ts';
3
+ export declare class LabelVarsCase implements CaseReader<LabelCase> {
4
+ from(vars: Readonly<Record<string, unknown>>): LabelCase;
5
+ }
6
+ //# sourceMappingURL=label-vars-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-vars-case.d.ts","sourceRoot":"","sources":["../../src/classification/label-vars-case.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,qBAAa,aAAc,YAAW,UAAU,CAAC,SAAS,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS;CASzD"}
@@ -0,0 +1,17 @@
1
+ import { LabelCase } from "./label-case.js";
2
+ import { readLabels } from "./read-labels.js";
3
+ // Reads a case from the vars of a test (Strategy): vars.expected is a label
4
+ // or a list of labels, and vars.weight is a number. A test without a weight
5
+ // weighs 1.
6
+ export class LabelVarsCase {
7
+ from(vars) {
8
+ const { expected, weight } = vars;
9
+ if (weight !== undefined && typeof weight !== 'number')
10
+ throw new Error(`vars.weight is a number, not ${JSON.stringify(weight)}`);
11
+ return new LabelCase({
12
+ expected: readLabels(expected, 'vars.expected'),
13
+ weight: weight ?? 1,
14
+ });
15
+ }
16
+ }
17
+ //# sourceMappingURL=label-vars-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-vars-case.js","sourceRoot":"","sources":["../../src/classification/label-vars-case.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,4EAA4E;AAC5E,4EAA4E;AAC5E,YAAY;AACZ,MAAM,OAAO,aAAa;IACxB,IAAI,CAAC,IAAuC;QAC1C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,KAAK,QAAQ;YACpD,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,IAAI,SAAS,CAAC;YACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,eAAe,CAAC;YAC/C,MAAM,EAAE,MAAM,IAAI,CAAC;SACpB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export type Label = number | string;
2
+ export declare function isLabel(value: unknown): value is Label;
3
+ export declare function compareLabels(left: Label, right: Label): number;
4
+ //# sourceMappingURL=label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/classification/label.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAGpC,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAKtD;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAQ/D"}
@@ -0,0 +1,16 @@
1
+ import { compareStrings } from '@zukhruf/python';
2
+ // Is the value a label: a finite number or a string.
3
+ export function isLabel(value) {
4
+ return (typeof value === 'string' ||
5
+ (typeof value === 'number' && Number.isFinite(value)));
6
+ }
7
+ // The order of numpy's unique() of labels: numbers by value, strings by code
8
+ // point. scikit-learn refuses a mix of numbers and strings.
9
+ export function compareLabels(left, right) {
10
+ if (typeof left === 'number' && typeof right === 'number')
11
+ return left - right;
12
+ if (typeof left === 'string' && typeof right === 'string')
13
+ return compareStrings(left, right);
14
+ throw new TypeError(`The labels ${JSON.stringify(left)} and ${JSON.stringify(right)} mix a number and a string, which scikit-learn refuses.`);
15
+ }
16
+ //# sourceMappingURL=label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/classification/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD,qDAAqD;AACrD,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,IAAW,EAAE,KAAY;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;QACvD,OAAO,IAAI,GAAG,KAAK,CAAC;IACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;QACvD,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,IAAI,SAAS,CACjB,cAAc,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,yDAAyD,CACzH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Gate } from '../scorers/gate.ts';
2
+ import type { LabelComparison } from './label-comparison.ts';
3
+ export declare class LabelsMatch extends Gate<LabelComparison> {
4
+ holds({ stated, expected }: LabelComparison): boolean;
5
+ explain(comparison: LabelComparison): string;
6
+ }
7
+ //# sourceMappingURL=labels-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels-match.d.ts","sourceRoot":"","sources":["../../src/classification/labels-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,qBAAa,WAAY,SAAQ,IAAI,CAAC,eAAe,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,OAAO;IAIrD,OAAO,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM;CAG7C"}
@@ -0,0 +1,13 @@
1
+ import { Gate } from "../scorers/gate.js";
2
+ // A gate that holds when the stated labels are the expected labels. Pooled
3
+ // over the answers, it is scikit-learn's accuracy_score (the subset accuracy
4
+ // for a set of classes).
5
+ export class LabelsMatch extends Gate {
6
+ holds({ stated, expected }) {
7
+ return stated.size === expected.size && stated.isSubsetOf(expected);
8
+ }
9
+ explain(comparison) {
10
+ return `the stated labels ${JSON.stringify([...comparison.stated])} are not the expected labels ${JSON.stringify([...comparison.expected])}`;
11
+ }
12
+ }
13
+ //# sourceMappingURL=labels-match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels-match.js","sourceRoot":"","sources":["../../src/classification/labels-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,2EAA2E;AAC3E,6EAA6E;AAC7E,yBAAyB;AACzB,MAAM,OAAO,WAAY,SAAQ,IAAqB;IACpD,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAmB;QACzC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,CAAC,UAA2B;QACjC,OAAO,qBAAqB,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;IAC/I,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import type { Counts } from '../aggregation/counts.ts';
2
+ import type { Average, Classes } from './average.ts';
3
+ export declare class MacroAverage implements Average {
4
+ of({ selected }: Classes, score: (counts: Counts) => number): number;
5
+ }
6
+ //# sourceMappingURL=macro-average.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macro-average.d.ts","sourceRoot":"","sources":["../../src/classification/macro-average.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKrD,qBAAa,YAAa,YAAW,OAAO;IAC1C,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM;CAOrE"}
@@ -0,0 +1,15 @@
1
+ import gsumpw from '@stdlib/blas-ext-base-gsumpw';
2
+ // average='macro': the mean of the scores of the selected classes, as
3
+ // numpy's nanmean gives it: a NaN score (zeroDivision NaN) adds 0 and is not
4
+ // counted, and the mean of no score is NaN.
5
+ export class MacroAverage {
6
+ of({ selected }, score) {
7
+ const scores = [...selected.values()].map(score);
8
+ const counted = scores.filter((value) => !Number.isNaN(value)).length;
9
+ if (counted === 0)
10
+ return Number.NaN;
11
+ const values = scores.map((value) => (Number.isNaN(value) ? 0 : value));
12
+ return gsumpw(values.length, values, 1) / counted;
13
+ }
14
+ }
15
+ //# sourceMappingURL=macro-average.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macro-average.js","sourceRoot":"","sources":["../../src/classification/macro-average.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,8BAA8B,CAAC;AAKlD,sEAAsE;AACtE,6EAA6E;AAC7E,4CAA4C;AAC5C,MAAM,OAAO,YAAY;IACvB,EAAE,CAAC,EAAE,QAAQ,EAAW,EAAE,KAAiC;QACzD,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Counts } from '../aggregation/counts.ts';
2
+ import type { Average, Classes } from './average.ts';
3
+ export declare class MicroAverage implements Average {
4
+ of({ selected }: Classes, score: (counts: Counts) => number): number;
5
+ }
6
+ //# sourceMappingURL=micro-average.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro-average.d.ts","sourceRoot":"","sources":["../../src/classification/micro-average.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIrD,qBAAa,YAAa,YAAW,OAAO;IAC1C,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM;CAYrE"}
@@ -0,0 +1,16 @@
1
+ import gsumpw from '@stdlib/blas-ext-base-gsumpw';
2
+ import { Counts } from "../aggregation/counts.js";
3
+ // average='micro': the counts of the selected classes are added, with numpy's
4
+ // pairwise sum, and scored once.
5
+ export class MicroAverage {
6
+ of({ selected }, score) {
7
+ const classes = [...selected.values()];
8
+ const sum = (count) => gsumpw(classes.length, classes.map(count), 1);
9
+ return score(new Counts({
10
+ hits: sum(({ hits }) => hits),
11
+ stated: sum(({ stated }) => stated),
12
+ expected: sum(({ expected }) => expected),
13
+ }));
14
+ }
15
+ }
16
+ //# sourceMappingURL=micro-average.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro-average.js","sourceRoot":"","sources":["../../src/classification/micro-average.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,8BAA8B,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,8EAA8E;AAC9E,iCAAiC;AACjC,MAAM,OAAO,YAAY;IACvB,EAAE,CAAC,EAAE,QAAQ,EAAW,EAAE,KAAiC;QACzD,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,CAAC,KAAiC,EAAE,EAAE,CAChD,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAChD,OAAO,KAAK,CACV,IAAI,MAAM,CAAC;YACT,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YAC7B,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC;SAC1C,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { Scorer } from '../scorers/scorer.ts';
2
+ import { Grouped } from '../scoring/grouped.ts';
3
+ import type { LabelComparison } from './label-comparison.ts';
4
+ import type { Label } from './label.ts';
5
+ export declare class PerClass extends Grouped<LabelComparison> {
6
+ #private;
7
+ constructor(scorer: Scorer<LabelComparison>, { labels }?: {
8
+ readonly labels?: readonly Label[];
9
+ });
10
+ protected groups(comparison: LabelComparison): Iterable<[string, LabelComparison]>;
11
+ }
12
+ //# sourceMappingURL=per-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-class.d.ts","sourceRoot":"","sources":["../../src/classification/per-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAMxC,qBAAa,QAAS,SAAQ,OAAO,CAAC,eAAe,CAAC;;gBAIlD,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,EAC/B,EAAE,MAAM,EAAE,GAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,CAAA;KAAO;IAMzD,SAAS,CAAE,MAAM,CACf,UAAU,EAAE,eAAe,GAC1B,QAAQ,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAIvC"}
@@ -0,0 +1,17 @@
1
+ import { Grouped } from "../scoring/grouped.js";
2
+ // A scorer for each class of a comparison: in a ScorerSet, it gives the ratio
3
+ // of its scorer on the comparison of each class, under the label
4
+ // `${class} ${label}`. Without labels, the classes are the labels of both
5
+ // sides of the answer; with labels, only those classes.
6
+ export class PerClass extends Grouped {
7
+ #labels;
8
+ constructor(scorer, { labels } = {}) {
9
+ super(scorer);
10
+ this.#labels = labels;
11
+ }
12
+ *groups(comparison) {
13
+ for (const label of this.#labels ?? comparison.labels())
14
+ yield [`${label}`, comparison.only(label)];
15
+ }
16
+ }
17
+ //# sourceMappingURL=per-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-class.js","sourceRoot":"","sources":["../../src/classification/per-class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIhD,8EAA8E;AAC9E,iEAAiE;AACjE,0EAA0E;AAC1E,wDAAwD;AACxD,MAAM,OAAO,QAAS,SAAQ,OAAwB;IAC3C,OAAO,CAA+B;IAE/C,YACE,MAA+B,EAC/B,EAAE,MAAM,KAA6C,EAAE;QAEvD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAES,CAAC,MAAM,CACf,UAA2B;QAE3B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE;YACrD,MAAM,CAAC,GAAG,KAAK,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { Comparer } from '../scoring/comparer.ts';
2
+ import type { LabelCase } from './label-case.ts';
3
+ import { ProbabilityComparison } from './probability-comparison.ts';
4
+ export declare class ProbabilityComparer implements Comparer<LabelCase, ProbabilityComparison> {
5
+ #private;
6
+ compare(stated: unknown, testCase: LabelCase): ProbabilityComparison;
7
+ }
8
+ //# sourceMappingURL=probability-comparer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probability-comparer.d.ts","sourceRoot":"","sources":["../../src/classification/probability-comparer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAOpE,qBAAa,mBAAoB,YAAW,QAAQ,CAClD,SAAS,EACT,qBAAqB,CACtB;;IACC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,qBAAqB;CAoCrE"}
@@ -0,0 +1,35 @@
1
+ import { ProbabilityComparison } from "./probability-comparison.js";
2
+ // Reads the stated probability of each class of an answer and gives its
3
+ // comparison with the case (Strategy). The answer is a Map of labels, a plain
4
+ // object or the JSON text of an object, whose values are probabilities in
5
+ // [0, 1]. A key of an object is a number label when each expected label of
6
+ // the case is a number. The case has one expected label.
7
+ export class ProbabilityComparer {
8
+ compare(stated, testCase) {
9
+ const [expected, ...others] = testCase.expected;
10
+ if (expected === undefined || others.length > 0)
11
+ throw new RangeError(`A probability is scored against one expected label, not ${JSON.stringify([...testCase.expected])}.`);
12
+ const numbers = typeof expected === 'number';
13
+ const entries = ProbabilityComparer.#entries(typeof stated === 'string' ? JSON.parse(stated) : stated).map(([key, probability]) => {
14
+ if (typeof probability !== 'number' ||
15
+ !(probability >= 0 && probability <= 1))
16
+ throw new RangeError(`The probability of ${JSON.stringify(key)} is a number in [0, 1], not ${JSON.stringify(probability)}.`);
17
+ return [
18
+ numbers && typeof key === 'string' ? Number(key) : key,
19
+ probability,
20
+ ];
21
+ });
22
+ return new ProbabilityComparison({
23
+ probabilities: new Map(entries),
24
+ expected,
25
+ });
26
+ }
27
+ static #entries(value) {
28
+ if (value instanceof Map)
29
+ return [...value];
30
+ if (typeof value === 'object' && value !== null && !Array.isArray(value))
31
+ return Object.entries(value);
32
+ throw new TypeError(`A stated answer is the probability of each label, as an object, not ${JSON.stringify(value)}`);
33
+ }
34
+ }
35
+ //# sourceMappingURL=probability-comparer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probability-comparer.js","sourceRoot":"","sources":["../../src/classification/probability-comparer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,wEAAwE;AACxE,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,yDAAyD;AACzD,MAAM,OAAO,mBAAmB;IAI9B,OAAO,CAAC,MAAe,EAAE,QAAmB;QAC1C,MAAM,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAC7C,MAAM,IAAI,UAAU,CAClB,2DAA2D,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CACrG,CAAC;QACJ,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC;QAC7C,MAAM,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAC1C,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CACzD,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAmB,EAAE;YAC5C,IACE,OAAO,WAAW,KAAK,QAAQ;gBAC/B,CAAC,CAAC,WAAW,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,CAAC;gBAEvC,MAAM,IAAI,UAAU,CAClB,sBAAsB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,+BAA+B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CACvG,CAAC;YACJ,OAAO;gBACL,OAAO,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;gBACtD,WAAW;aACZ,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,qBAAqB,CAAC;YAC/B,aAAa,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC;YAC/B,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAc;QAC5B,IAAI,KAAK,YAAY,GAAG;YAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACtE,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,MAAM,IAAI,SAAS,CACjB,uEAAuE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAC/F,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { Label } from './label.ts';
2
+ export declare class ProbabilityComparison {
3
+ readonly probabilities: ReadonlyMap<Label, number>;
4
+ readonly expected: Label;
5
+ constructor({ probabilities, expected, }: {
6
+ readonly probabilities: ReadonlyMap<Label, number>;
7
+ readonly expected: Label;
8
+ });
9
+ }
10
+ //# sourceMappingURL=probability-comparison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probability-comparison.d.ts","sourceRoot":"","sources":["../../src/classification/probability-comparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;gBAEb,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;KAC1B;CAIF"}
@@ -0,0 +1,11 @@
1
+ // The stated probability of each class of one answer, and the expected
2
+ // label of its case.
3
+ export class ProbabilityComparison {
4
+ probabilities;
5
+ expected;
6
+ constructor({ probabilities, expected, }) {
7
+ this.probabilities = probabilities;
8
+ this.expected = expected;
9
+ }
10
+ }
11
+ //# sourceMappingURL=probability-comparison.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probability-comparison.js","sourceRoot":"","sources":["../../src/classification/probability-comparison.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,qBAAqB;AACrB,MAAM,OAAO,qBAAqB;IACvB,aAAa,CAA6B;IAC1C,QAAQ,CAAQ;IAEzB,YAAY,EACV,aAAa,EACb,QAAQ,GAIT;QACC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { type Label } from './label.ts';
2
+ export declare function readLabels(value: unknown, name: string): Label | Label[];
3
+ //# sourceMappingURL=read-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-labels.d.ts","sourceRoot":"","sources":["../../src/classification/read-labels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAIjD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,EAAE,CAMxE"}
@@ -0,0 +1,11 @@
1
+ import { isLabel } from "./label.js";
2
+ // The expected labels of a plain object of a runner: a label or a list of
3
+ // labels.
4
+ export function readLabels(value, name) {
5
+ if (isLabel(value))
6
+ return value;
7
+ if (Array.isArray(value) && value.every(isLabel))
8
+ return value;
9
+ throw new Error(`${name} is a label (a number or a string) or a list of labels, not ${JSON.stringify(value)}`);
10
+ }
11
+ //# sourceMappingURL=read-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-labels.js","sourceRoot":"","sources":["../../src/classification/read-labels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,YAAY,CAAC;AAEjD,0EAA0E;AAC1E,UAAU;AACV,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,IAAY;IACrD,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,+DAA+D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAC9F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Counts } from '../aggregation/counts.ts';
2
+ import type { Average, Classes } from './average.ts';
3
+ export declare class WeightedAverage implements Average {
4
+ of({ selected }: Classes, score: (counts: Counts) => number): number;
5
+ }
6
+ //# sourceMappingURL=weighted-average.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weighted-average.d.ts","sourceRoot":"","sources":["../../src/classification/weighted-average.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMrD,qBAAa,eAAgB,YAAW,OAAO;IAC7C,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM;CAUrE"}
@@ -0,0 +1,20 @@
1
+ import gsumpw from '@stdlib/blas-ext-base-gsumpw';
2
+ // average='weighted': the mean of the scores of the selected classes, each
3
+ // weighted by its true count, as scikit-learn's _nanaverage gives it: a NaN
4
+ // score is dropped with its weight, the mean of no score is NaN, and when the
5
+ // weights add up to 0 it is the plain mean.
6
+ export class WeightedAverage {
7
+ of({ selected }, score) {
8
+ const kept = [...selected.values()]
9
+ .map((counts) => ({ value: score(counts), weight: counts.expected }))
10
+ .filter(({ value }) => !Number.isNaN(value));
11
+ if (kept.length === 0)
12
+ return Number.NaN;
13
+ const sum = (values) => gsumpw(values.length, values, 1);
14
+ const weights = sum(kept.map(({ weight }) => weight));
15
+ if (weights === 0)
16
+ return sum(kept.map(({ value }) => value)) / kept.length;
17
+ return sum(kept.map(({ value, weight }) => value * weight)) / weights;
18
+ }
19
+ }
20
+ //# sourceMappingURL=weighted-average.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weighted-average.js","sourceRoot":"","sources":["../../src/classification/weighted-average.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,8BAA8B,CAAC;AAKlD,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,4CAA4C;AAC5C,MAAM,OAAO,eAAe;IAC1B,EAAE,CAAC,EAAE,QAAQ,EAAW,EAAE,KAAiC;QACzD,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;aAChC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;aACpE,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC;QACzC,MAAM,GAAG,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACtD,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5E,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC;IACxE,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { Ratio } from './aggregation/ratio.ts';
2
2
  export { RatioOfSums } from './aggregation/ratio-of-sums.ts';
3
3
  export { Counts } from './aggregation/counts.ts';
4
- export { F1Ratio } from './aggregation/f1-ratio.ts';
4
+ export { CountsForm, type FMeasureForm, PrecisionRecallForm, } from './aggregation/f-measure-form.ts';
5
5
  export type { Check, Scorecard } from './scoring/scorecard.ts';
6
6
  export type { CaseReader, ScorecardScorer, Weighted, } from './scoring/scorecard-scorer.ts';
7
7
  export { Totals } from './scoring/totals.ts';
@@ -10,6 +10,7 @@ export type { Scorer } from './scorers/scorer.ts';
10
10
  export type { Matches } from './scorers/matches.ts';
11
11
  export { Precision } from './scorers/precision.ts';
12
12
  export { Recall } from './scorers/recall.ts';
13
+ export { FBeta } from './scorers/f-beta.ts';
13
14
  export { F1 } from './scorers/f1.ts';
14
15
  export { Penalty } from './scorers/penalty.ts';
15
16
  export { Gate } from './scorers/gate.ts';
@@ -18,4 +19,7 @@ export { AtLeast } from './scorers/at-least.ts';
18
19
  export { ShortfallPenalty } from './scorers/shortfall-penalty.ts';
19
20
  export { SampleAveraged } from './scorers/sample-averaged.ts';
20
21
  export { MeanOf } from './scorers/mean-of.ts';
22
+ export type { Comparer } from './scoring/comparer.ts';
23
+ export { Grouped } from './scoring/grouped.ts';
24
+ export { ScorerSet } from './scoring/scorer-set.ts';
21
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EACV,UAAU,EACV,eAAe,EACf,QAAQ,GACT,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EACV,UAAU,EACV,eAAe,EACf,QAAQ,GACT,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  export { Ratio } from "./aggregation/ratio.js";
2
2
  export { RatioOfSums } from "./aggregation/ratio-of-sums.js";
3
3
  export { Counts } from "./aggregation/counts.js";
4
- export { F1Ratio } from "./aggregation/f1-ratio.js";
4
+ export { CountsForm, PrecisionRecallForm, } from "./aggregation/f-measure-form.js";
5
5
  export { Totals } from "./scoring/totals.js";
6
6
  export { Bootstrap } from "./scoring/bootstrap.js";
7
7
  export { Precision } from "./scorers/precision.js";
8
8
  export { Recall } from "./scorers/recall.js";
9
+ export { FBeta } from "./scorers/f-beta.js";
9
10
  export { F1 } from "./scorers/f1.js";
10
11
  export { Penalty } from "./scorers/penalty.js";
11
12
  export { Gate } from "./scorers/gate.js";
@@ -14,4 +15,6 @@ export { AtLeast } from "./scorers/at-least.js";
14
15
  export { ShortfallPenalty } from "./scorers/shortfall-penalty.js";
15
16
  export { SampleAveraged } from "./scorers/sample-averaged.js";
16
17
  export { MeanOf } from "./scorers/mean-of.js";
18
+ export { Grouped } from "./scoring/grouped.js";
19
+ export { ScorerSet } from "./scoring/scorer-set.js";
17
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAOpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAA0B,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACL,UAAU,EAEV,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAA0B,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { AssertionModule, type FileAssertion, type ModuleAssertion, type VarsContext, } from './assertion-module.ts';
2
2
  export { type AssertionContext, type GradingResult, PromptfooAssertion, } from './promptfoo-assertion.ts';
3
+ export { ScorerAssertion } from './scorer-assertion.ts';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promptfoo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/promptfoo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { AssertionModule, } from "./assertion-module.js";
2
2
  export { PromptfooAssertion, } from "./promptfoo-assertion.js";
3
+ export { ScorerAssertion } from "./scorer-assertion.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/promptfoo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/promptfoo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Scorer } from '../scorers/scorer.ts';
2
+ import type { Comparer } from '../scoring/comparer.ts';
3
+ import type { CaseReader, Weighted } from '../scoring/scorecard-scorer.ts';
4
+ import type { VarsContext } from './assertion-module.ts';
5
+ export declare class ScorerAssertion<Case extends Weighted, Input> {
6
+ readonly metric: string | undefined;
7
+ readonly weight: number;
8
+ readonly threshold: number;
9
+ readonly value: (output: string, context: VarsContext) => number;
10
+ constructor(scorer: Scorer<Input>, { weight, threshold, metric, comparer, cases, }: {
11
+ readonly weight: number;
12
+ readonly threshold: number;
13
+ readonly metric?: string;
14
+ readonly comparer: Comparer<Case, Input>;
15
+ readonly cases: CaseReader<Case>;
16
+ });
17
+ }
18
+ //# sourceMappingURL=scorer-assertion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorer-assertion.d.ts","sourceRoot":"","sources":["../../src/promptfoo/scorer-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAiBzD,qBAAa,eAAe,CAAC,IAAI,SAAS,QAAQ,EAAE,KAAK;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC;gBAG/D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,EACE,MAAM,EACN,SAAS,EACT,MAAM,EACN,QAAQ,EACR,KAAK,GACN,EAAE;QACD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;KAClC;CAQJ"}
@@ -1,7 +1,3 @@
1
- import { ComparisonSpec } from "../comparison/comparison-spec.js";
2
- import { statedData } from "../comparison/json-value.js";
3
- import { TreeWalk } from "../comparison/tree-walk.js";
4
- import { TextVarsCase } from "../scoring/text-vars-case.js";
5
1
  // One scorer with the rule of its promptfoo assertion (ADR 0007, ADR 0013):
6
2
  // how much it counts in the score of the test (weight: the score is the sum
7
3
  // of value × weight over the sum of the weights), when it passes (threshold:
@@ -14,21 +10,19 @@ import { TextVarsCase } from "../scoring/text-vars-case.js";
14
10
  // and gives the value of the ratio of the scorer: promptfoo takes the mean of
15
11
  // the values of one metric, so a SampleAveraged scorer gives its samples
16
12
  // average. The case comes from the vars of the test, as its case reader reads
17
- // them (a TextVarsCase that reads each schema with the draft of its $schema,
18
- // unless the caller gives one): an assertion that defaultTest shares gets
19
- // only the vars of each test, and JSON text keeps 7.0 a float. The spec tells
20
- // the walk how to compare the answer with the case.
13
+ // them: an assertion that defaultTest shares gets only the vars of each test.
14
+ // The comparer compares the answer with the case and gives the input of the
15
+ // scorer.
21
16
  export class ScorerAssertion {
22
17
  metric;
23
18
  weight;
24
19
  threshold;
25
20
  value;
26
- constructor(scorer, { weight, threshold, metric, spec = new ComparisonSpec(), cases = new TextVarsCase(), }) {
21
+ constructor(scorer, { weight, threshold, metric, comparer, cases, }) {
27
22
  this.metric = metric;
28
23
  this.weight = weight;
29
24
  this.threshold = threshold;
30
- const walk = new TreeWalk(spec);
31
- this.value = (output, { vars }) => scorer.score(walk.compare(statedData(output), cases.from(vars))).value;
25
+ this.value = (output, { vars }) => scorer.score(comparer.compare(output, cases.from(vars))).value;
32
26
  }
33
27
  }
34
28
  //# sourceMappingURL=scorer-assertion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorer-assertion.js","sourceRoot":"","sources":["../../src/promptfoo/scorer-assertion.ts"],"names":[],"mappings":"AAKA,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,UAAU;AACV,MAAM,OAAO,eAAe;IACjB,MAAM,CAAqB;IAC3B,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,KAAK,CAAmD;IAEjE,YACE,MAAqB,EACrB,EACE,MAAM,EACN,SAAS,EACT,MAAM,EACN,QAAQ,EACR,KAAK,GAON;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAChC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { type FMeasureForm } from '../aggregation/f-measure-form.ts';
2
+ import type { Ratio } from '../aggregation/ratio.ts';
3
+ import type { Matches } from './matches.ts';
4
+ import type { Scorer } from './scorer.ts';
5
+ export declare class FBeta<Input> implements Scorer<Input> {
6
+ #private;
7
+ constructor(matches: Matches<Input>, { beta, form, }: {
8
+ readonly beta: number;
9
+ readonly form?: FMeasureForm;
10
+ });
11
+ score(input: Input): Ratio;
12
+ }
13
+ //# sourceMappingURL=f-beta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"f-beta.d.ts","sourceRoot":"","sources":["../../src/scorers/f-beta.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,qBAAa,KAAK,CAAC,KAAK,CAAE,YAAW,MAAM,CAAC,KAAK,CAAC;;gBAM9C,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EACvB,EACE,IAAI,EACJ,IAAuB,GACxB,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAA;KAAE;IAO5D,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAM3B"}
@@ -0,0 +1,22 @@
1
+ import { CountsForm, } from "../aggregation/f-measure-form.js";
2
+ import { FMeasureRatio } from "../aggregation/f-measure-ratio.js";
3
+ // The F-beta of the hits, as scikit-learn's fbeta_score: β weighs recall β
4
+ // times as much as precision. The form is the arithmetic of the value, and
5
+ // CountsForm is the form of scikit-learn.
6
+ export class FBeta {
7
+ #matches;
8
+ #beta;
9
+ #form;
10
+ constructor(matches, { beta, form = new CountsForm(), }) {
11
+ this.#matches = matches;
12
+ this.#beta = beta;
13
+ this.#form = form;
14
+ }
15
+ score(input) {
16
+ return new FMeasureRatio(this.#matches.counts(input), {
17
+ beta: this.#beta,
18
+ form: this.#form,
19
+ });
20
+ }
21
+ }
22
+ //# sourceMappingURL=f-beta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"f-beta.js","sourceRoot":"","sources":["../../src/scorers/f-beta.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAEX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,2EAA2E;AAC3E,2EAA2E;AAC3E,0CAA0C;AAC1C,MAAM,OAAO,KAAK;IACP,QAAQ,CAAiB;IACzB,KAAK,CAAS;IACd,KAAK,CAAe;IAE7B,YACE,OAAuB,EACvB,EACE,IAAI,EACJ,IAAI,GAAG,IAAI,UAAU,EAAE,GACiC;QAE1D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,KAAY;QAChB,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACpD,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,IAAI,EAAE,IAAI,CAAC,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}