-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[FIX] Evaluation Results input validation #1954
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
Merged
janezd
merged 9 commits into
biolab:master
from
ales-erjavec:fixes/evaluate-input-validation
Feb 3, 2017
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1acc52b
owpredictions: Omit rows with missing targets (Eval. Results output)
ales-erjavec 7938648
Results: Use `is not None` to check for data presence
ales-erjavec b71ae87
owconfusionmatrix: Fix an ValueError on empty results
ales-erjavec 135d7a8
owconfusionmatrix: Check the input for NaN values
ales-erjavec 314ae87
owconfusionmatrix: Remove call to super's migrate_settings
ales-erjavec 5a55b42
owrocanalysis: Handle deficient number of test results
ales-erjavec 88fbee8
owrocanalysis: Check the input for NaN values
ales-erjavec 009a6f4
owliftcurve: Handle empty results
ales-erjavec c7cc742
owcalibrationplot: Validate input results
ales-erjavec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import copy | ||
|
|
||
| import numpy as np | ||
|
|
||
| import Orange.data | ||
| import Orange.evaluation | ||
| import Orange.classification | ||
|
|
||
| from Orange.widgets.tests.base import WidgetTest | ||
| from Orange.widgets.evaluate.owcalibrationplot import OWCalibrationPlot | ||
|
|
||
|
|
||
| class TestOWCalibrationPlot(WidgetTest): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.lenses = data = Orange.data.Table("lenses") | ||
| cls.res = Orange.evaluation.TestOnTestData( | ||
| train_data=data[::2], test_data=data[1::2], | ||
| learners=[Orange.classification.MajorityLearner(), | ||
| Orange.classification.KNNLearner()], | ||
| store_data=True, | ||
| ) | ||
|
|
||
| def setUp(self): | ||
| super().setUp() | ||
| self.widget = self.create_widget(OWCalibrationPlot) # type: OWCalibrationPlot | ||
|
|
||
| def test_basic(self): | ||
| self.send_signal("Evaluation Results", self.res) | ||
| self.widget.controls.display_rug.click() | ||
|
|
||
| def test_empty(self): | ||
| res = copy.copy(self.res) | ||
| res.row_indices = res.row_indices[:0] | ||
| res.actual = res.actual[:0] | ||
| res.predicted = res.predicted[:, 0] | ||
| res.probabilities = res.probabilities[:, :0, :] | ||
| self.send_signal("Evaluation Results", res) | ||
|
|
||
| def test_nan_input(self): | ||
| res = copy.copy(self.res) | ||
| res.actual = res.actual.copy() | ||
| res.probabilities = res.probabilities.copy() | ||
|
|
||
| res.actual[0] = np.nan | ||
| res.probabilities[:, [0, 3], :] = np.nan | ||
| self.send_signal("Evaluation Results", res) | ||
| self.assertTrue(self.widget.Error.invalid_results.is_shown()) | ||
| self.send_signal("Evaluation Results", None) | ||
| self.assertFalse(self.widget.Error.invalid_results.is_shown()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import copy | ||
|
|
||
| import numpy as np | ||
|
|
||
| import Orange.data | ||
| import Orange.evaluation | ||
| import Orange.classification | ||
|
|
||
| from Orange.widgets.tests.base import WidgetTest | ||
| from Orange.widgets.tests.utils import simulate | ||
| from Orange.widgets.evaluate.owliftcurve import OWLiftCurve | ||
|
|
||
|
|
||
| class TestOWLiftCurve(WidgetTest): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.lenses = data = Orange.data.Table("lenses") | ||
| cls.res = Orange.evaluation.TestOnTestData( | ||
| train_data=data[::2], test_data=data[1::2], | ||
| learners=[Orange.classification.MajorityLearner(), | ||
| Orange.classification.KNNLearner()], | ||
| store_data=True, | ||
| ) | ||
|
|
||
| def setUp(self): | ||
| super().setUp() | ||
| self.widget = self.create_widget( | ||
| OWLiftCurve, | ||
| stored_settings={ | ||
| "display_convex_hull": True | ||
| } | ||
| ) # type: OWLiftCurve | ||
|
|
||
| def test_basic(self): | ||
| self.send_signal("Evaluation Results", self.res) | ||
| simulate.combobox_run_through_all(self.widget.target_cb) | ||
|
|
||
| def test_empty_input(self): | ||
| res = copy.copy(self.res) | ||
| res.actual = res.actual[:0] | ||
| res.row_indices = res.row_indices[:0] | ||
| res.predicted = res.predicted[:, :0] | ||
| res.probabilities = res.probabilities[:, :0, :] | ||
| self.send_signal("Evaluation Results", res) | ||
|
|
||
| def test_nan_input(self): | ||
| res = copy.copy(self.res) | ||
| res.actual[0] = np.nan | ||
| self.send_signal("Evaluation Results", res) | ||
| self.assertTrue(self.widget.Error.invalid_results.is_shown()) | ||
| self.send_signal("Evaluation Results", None) | ||
| self.assertFalse(self.widget.Error.invalid_results.is_shown()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change anything here, but just if you didn't know: if you prefer, you can use
self.Error.invalid_values(shown=nan_values), which shows or hides the messages.