From d4fc830c6fb5129186e8ce123f2214fea19eda15 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 10 Oct 2017 12:49:24 +0200 Subject: [PATCH] MDL-59106 report_insights: Order prediction values --- report/insights/classes/output/insights_list.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/report/insights/classes/output/insights_list.php b/report/insights/classes/output/insights_list.php index 2015b4331a2..147721ca1d9 100644 --- a/report/insights/classes/output/insights_list.php +++ b/report/insights/classes/output/insights_list.php @@ -117,6 +117,15 @@ class insights_list implements \renderable, \templatable { $insights[$predictedvalue][] = $insightrenderable->export_for_template($output); } + // Order predicted values. + if ($this->model->get_target()->is_linear()) { + // During regression what we will be interested on most of the time is in low values so let's show them first. + ksort($predictionvalues); + } else { + // During classification targets flag "not that important" samples as 0 so let's show them at the end. + krsort($predictionvalues); + } + // Ok, now we have all the data we want, put it into a format that mustache can handle. foreach ($predictionvalues as $key => $prediction) { if (isset($insights[$key])) {