Warning: session_start(): open(/var/lib/php/sessions/sess_8tn7tdl8n26bd1gbi5tnb6rrpn, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// find best threshold value to separate list1 (smaller values) from list2 (bigger values), minimizing false positives + false negatives
// returns (threshold, false positives, false negatives)
static T3 findBestThreshold(Cl list1, Cl list2) {
if (empty(list1) || empty(list2)) null;
// get basic treshold & number of false positives/negatives
T3 t = findThreshold_unmoved(list1, list2);
double threshold = t.a;
int falsePositives = t.b, falseNegatives = t.c;
// get all values in a sorted list
L l = sorted(concatLists(list1, list2));
int i = binarySearch_insertionPoint(l, threshold);
ifdef findBestThreshold_debug
printVars_str("Initial threshold.", +i, l := l(l), +threshold, +falsePositives, +falseNegatives);
endifdef
while (falsePositives <= falseNegatives && i > 0) {
--i;
threshold = avg(l.get(i), l.get(i+1));
double _threshold = threshold;
int falsePositives2 = countPred(list1, d -> d > _threshold);
int falseNegatives2 = countPred(list2, d -> d <= _threshold);
ifdef findBestThreshold_debug
printVars_str("Stepped down.", +i, l := l(l), +threshold, +falsePositives2, +falseNegatives2);
endifdef
// is new result better than old result?
if (falsePositives2+falseNegatives2 < falsePositives+falseNegatives) {
falsePositives = falsePositives2;
falseNegatives = falseNegatives2;
} else break;
}
while (falseNegatives <= falsePositives && i+2 < l(l)) {
++i;
threshold = avg(l.get(i), l.get(i+1));
double _threshold = threshold;
int falsePositives2 = countPred(list1, d -> d > _threshold);
int falseNegatives2 = countPred(list2, d -> d <= _threshold);
ifdef findBestThreshold_debug
printVars_str("Stepped up.", +i, l := l(l), +threshold, +falsePositives, +falseNegatives);
endifdef
// is new result better than old result?
if (falsePositives2+falseNegatives2 < falsePositives+falseNegatives) {
falsePositives = falsePositives2;
falseNegatives = falseNegatives2;
} else break;
}
ret t3(threshold, falsePositives, falseNegatives);
}