-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Comments
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 |
Gotcha! 👌 |
...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. |
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
In the attached screenshot, the table is sorted by column 3, RMSE, alphabetically ascending:
12630
1389
20510
2194779950371
37742
For sorting to be useful, these values should be sorted:
1389
12630
20510
37742
2194779950371
Additional info (worksheets, data, screenshots, ...)
The text was updated successfully, but these errors were encountered: