MDL-65175 mlbackend_php: Add missing checking for number of targets
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user