use classification; use std::cli; fn check(ok: bool) { if !ok { stderr_line("classification check failed"); process_exit(1); } } fn main() { let c = class_confusion([1, 0, 0, 1], [0.5, 0.1, 0.8, 0.4], 0.5); check(at(c, 0) == 1.0 && at(c, 1) == 1.0 && at(c, 2) == 1.0 && at(c, 3) == 1.0); check(class_precision(2.0, 0.0) == 1.0 && class_recall(0.0, 0.0) == 0.0); check(class_f1(2.0, 2.0, 2.0) == 0.5 && class_cost(2.0, 1.0, 1.0, 10.0) == 12.0); check(len(class_confusion([], [], 0.5)) == 0); check(len(class_confusion([0], [1, 0], 0.5)) == 0); check(len(class_confusion([2], [0.5], 0.5)) == 0); check(len(class_confusion([1], [1.01], 0.5)) == 0); check(len(class_confusion([1], [0.4], -0.1)) == 0); println!("classification checks passed"); }