MDL-65175 mlbackend_php: Add missing checking for number of targets

This commit is contained in:
David Monllaó
2019-04-11 17:57:25 +02:00
parent d5111e6f6b
commit 69b68ad691
+4
View File
@@ -291,11 +291,15 @@ class processor implements \core_analytics\classifier, \core_analytics\regressor
// We need at least 2 samples belonging to each target.
$counts = array_count_values($targets);
$ntargets = count(explode(',', $metadata['targetclasses']));
foreach ($counts as $count) {
if ($count < 2) {
$notenoughdata = true;
}
}
if ($ntargets > count($counts)) {
$notenoughdata = true;
}
if (!empty($notenoughdata)) {
$resultobj = new \stdClass();
$resultobj->status = \core_analytics\model::NOT_ENOUGH_DATA;