Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Test and Score Evaluation results sort alphabetically #3947

Closed
Pigankle opened this issue Jul 29, 2019 · 3 comments · Fixed by #3951
Closed

Bug: Test and Score Evaluation results sort alphabetically #3947

Pigankle opened this issue Jul 29, 2019 · 3 comments · Fixed by #3951
Assignees
Labels
bug A bug confirmed by the core team

Comments

@Pigankle
Copy link

Pigankle commented Jul 29, 2019

Orange version

3.22

Expected behavior

In the Test&Score module window, there are five columns by default: Model, MSE, RMSE, MAE & R2. All but the first column contains numeric values. It is possible to click on any of the column headers to sort the table by that column. Expected behavior: sorting by the numeric columns will use numeric sort behavior.

Actual behavior

Clicking on a numeric column header sorts with alphabetic/lexicographic behavior, so a possible "sorted" list might look like:
16992
178
355
4536

Steps to reproduce the behavior
  1. Associate multiple model modules with a Test and Score module
  2. Once the Test and Score module results window
  3. Click on a column header to sort by a numeric column.

In the attached screenshot, the table is sorted by column 3, RMSE, alphabetically ascending:
12630
1389
20510
2194779950371
37742
screenshot_200

For sorting to be useful, these values should be sorted:

1389
12630
20510
37742
2194779950371

Additional info (worksheets, data, screenshots, ...)
@janezd
Copy link
Contributor

janezd commented Jul 30, 2019

Thanks! Funny that nobody noticed this before. Fixed in #3951.

@ajdapretnar, other widgets (such as GEO Data Sets) can be fixed in a similar way, but not by reusing the code from #3951. Test & Score is specific because we want to have strings and Nones (both representing errors) always at the bottom of the table. Most other widgets should expect just numbers and empty cells, which can be treated as -np.inf.

@ajdapretnar
Copy link
Contributor

@ajdapretnar, other widgets (such as GEO Data Sets) can be fixed in a similar way, but not by reusing the code from #3595

Gotcha! 👌

@ales-erjavec
Copy link
Contributor

ales-erjavec commented Jul 31, 2019

Or maybe just undo b419679 and go on from there.

...
diff --git a/Orange/widgets/evaluate/owtestlearners.py b/Orange/widgets/evaluate/owtestlearners.py
index 139f2cb9c..9a2d77de9 100644
--- a/Orange/widgets/evaluate/owtestlearners.py
+++ b/Orange/widgets/evaluate/owtestlearners.py
@@ -533,7 +533,7 @@ class OWTestLearners(OWWidget):
                 for stat, scorer in zip(stats, self.scorers):
                     item = QStandardItem()
                     if stat.success:
-                        item.setText("{:.3f}".format(stat.value[0]))
+                        item.setData(float(stat.value[0]), Qt.DisplayRole)
                     else:
                         item.setToolTip(str(stat.exception))
                         if scorer.name in self.score_table.shown_scores:
diff --git a/Orange/widgets/evaluate/utils.py b/Orange/widgets/evaluate/utils.py
index ebe060327..6caa6811b 100644
--- a/Orange/widgets/evaluate/utils.py
+++ b/Orange/widgets/evaluate/utils.py
@@ -109,6 +109,12 @@ class ScoreTable(OWComponent, QObject):
             size = super().sizeHint(*args)
             return QSize(size.width(), size.height() + 6)
 
+        def displayText(self, value, locale):
+            if isinstance(value, float):
+                return "{:.3f}".format(value)
+            else:
+                return super().displayText(value, locale)
+
     def __init__(self, master):
         QObject.__init__(self)
         OWComponent.__init__(self, master)

EDIT: posted in the wrong thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug confirmed by the core team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants