Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1030082 - ai_verifyDetector

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3255L/20K).

sS ai_verifyDetector(IPred<S> detector, S posLines, S negLines) {
  LS posExamples = tlft(posLines);
  LS negExamples = tlft(negLines);
  LPair<S, Bool> examples = trueFalseBPairs(posExamples, negExamples);
  new LS good;
  new LS bad;
  new Scorer scorer;
  
  long time = sysNow();
  for (Pair<S, Bool> example : examples) {
    bool result = detector.get(example.a);
    bool ok = result == example.b;
    scorer.add(ok);
    S line = (ok ? "OK" : example.b ? "False negative" : "False positive") + ": " + example.a;
    (ok ? good : bad).add(line);
  }
  time = sysNow()-time;

  ret "Score for detector: " + scorer + "\n"
    + n2(good, "correct answer") + ", " + n2(bad, "bad answer") + ". Runtime: " + n2(time) + " ms\n\n"
    + or2(trim(lines(concatLists(bad, ll(""), good))), "No errors");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

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: 40 / 67
Version history: 4 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1030082 & http://1030082.tinybrain.de