Libraryless. Click here for Pure Java version (3255L/20K).
1 | sS ai_verifyDetector(IPred<S> detector, S posLines, S negLines) { |
2 | LS posExamples = tlft(posLines); |
3 | LS negExamples = tlft(negLines); |
4 | LPair<S, Bool> examples = trueFalseBPairs(posExamples, negExamples); |
5 | new LS good; |
6 | new LS bad; |
7 | new Scorer scorer; |
8 | |
9 | long time = sysNow(); |
10 | for (Pair<S, Bool> example : examples) { |
11 | bool result = detector.get(example.a); |
12 | bool ok = result == example.b; |
13 | scorer.add(ok); |
14 | S line = (ok ? "OK" : example.b ? "False negative" : "False positive") + ": " + example.a; |
15 | (ok ? good : bad).add(line); |
16 | } |
17 | time = sysNow()-time; |
18 | |
19 | ret "Score for detector: " + scorer + "\n" |
20 | + n2(good, "correct answer") + ", " + n2(bad, "bad answer") + ". Runtime: " + n2(time) + " ms\n\n" |
21 | + or2(trim(lines(concatLists(bad, ll(""), good))), "No errors"); |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030082 |
Snippet name: | ai_verifyDetector |
Eternal ID of this version: | #1030082/5 |
Text MD5: | 9a0916e83121ee7c94e6b17f0b59aac0 |
Transpilation MD5: | 81e12ad56762db36654cd593d4c82611 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-06 09:20:45 |
Source code size: | 821 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 199 / 290 |
Version history: | 4 change(s) |
Referenced in: | [show references] |