MDL-57791 mlbackend_php: Minimum 2 samples per target value

This commit is contained in:
David Monllao
2017-07-24 08:37:02 +02:00
parent ee345551d6
commit 98b2f06fe7
3 changed files with 19 additions and 3 deletions
+16 -1
View File
@@ -258,6 +258,21 @@ class processor implements \core_analytics\predictor {
}
fclose($fh);
// We need at least 2 samples belonging to each target.
$counts = array_count_values($targets);
foreach ($counts as $count) {
if ($count < 2) {
$notenoughdata = true;
}
}
if (!empty($notenoughdata)) {
$resultobj = new \stdClass();
$resultobj->status = \core_analytics\model::EVALUATE_NOT_ENOUGH_DATA;
$resultobj->score = 0;
$resultobj->info = array(get_string('errornotenoughdata', 'mlbackend_php'));
return $resultobj;
}
$phis = array();
// Evaluate the model multiple times to confirm the results are not significantly random due to a short amount of data.
@@ -318,7 +333,7 @@ class processor implements \core_analytics\predictor {
$a = new \stdClass();
$a->deviation = $modeldev;
$a->accepteddeviation = $maxdeviation;
$resultobj->info[] = get_string('errornotenoughdata', 'mlbackend_php', $a);
$resultobj->info[] = get_string('errornotenoughdatadev', 'mlbackend_php', $a);
}
if ($resultobj->score < \core_analytics\model::MIN_SCORE) {