Commit 69b68ad6 authored by David Monllaó's avatar David Monllaó
Browse files

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

parent d5111e6f
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment