def test_empty_results(self): """Test on empty results.""" res = Results(data=self.iris[:0], store_data=True) res.row_indices = np.array([], dtype=int) res.actual = np.array([]) res.predicted = np.array([[]]) res.probabilities = np.zeros((1, 0, 3)) self.send_signal(self.widget.Inputs.evaluation_results, res) self.widget.select_correct() self.widget.select_wrong()
def test_nan_results(self): """Test on results with nan values in actual/predicted""" res = Results(data=self.iris, nmethods=2, store_data=True) res.row_indices = np.array([0, 50, 100], dtype=int) res.actual = np.array([0., np.nan, 2.]) res.predicted = np.array([[np.nan, 1, 2], [np.nan, np.nan, np.nan]]) res.probabilities = np.zeros((1, 3, 3)) self.send_signal(self.widget.Inputs.evaluation_results, res) self.assertTrue(self.widget.Error.invalid_values.is_shown()) self.send_signal(self.widget.Inputs.evaluation_results, None) self.assertFalse(self.widget.Error.invalid_values.is_shown())
def get_fold(self, fold): results = Results() results.data = self.data if self.folds is None: raise ValueError("This 'Results' instance does not have folds.") if self.models is not None: results.models = self.models[fold] results.row_indices = self.row_indices results.actual = self.actual results.predicted = self.predicted[:, fold, :] results.domain = self.domain return results