def test_iris(self): data = Orange.data.Table("iris") proc = PCADenoising(components=2) d1 = proc(data) newdata = data.transform(d1.domain) differences = newdata.X - data.X self.assertTrue(np.all(np.abs(differences) < 0.6)) # pin some values to detect changes in the PCA implementation # (for example normalization) np.testing.assert_almost_equal( newdata.X[:2], [[5.08718247, 3.51315614, 1.40204280, 0.21105556], [4.75015528, 3.15366444, 1.46254138, 0.23693223]])
def test_no_samples(self): data = Orange.data.Table("iris") proc = PCADenoising() d1 = proc(data[:0]) newdata = data.transform(d1.domain) np.testing.assert_equal(newdata.X, np.nan)
PREPROCESSORS_INDEPENDENT_SAMPLES += list( add_edge_case_data_parameter(EMSC, "reference", SMALL_COLLAGEN[0:1])) # EMSC with different kinds of bad spectra PREPROCESSORS_INDEPENDENT_SAMPLES += list( add_edge_case_data_parameter(EMSC, "badspectra", SMALL_COLLAGEN[0:2], reference=SMALL_COLLAGEN[-1:])) PREPROCESSORS_INDEPENDENT_SAMPLES += \ list(add_edge_case_data_parameter(NormalizeReference, "reference", SMALL_COLLAGEN[:1])) # Preprocessors that use groups of input samples to infer # internal parameters. PREPROCESSORS_GROUPS_OF_SAMPLES = [ PCADenoising(components=2), ] PREPROCESSORS_INDEPENDENT_SAMPLES += list( add_edge_case_data_parameter(ME_EMSC, "reference", SMALLER_COLLAGEN[0:1], max_iter=4)) PREPROCESSORS = PREPROCESSORS_INDEPENDENT_SAMPLES + PREPROCESSORS_GROUPS_OF_SAMPLES class TestTransmittance(unittest.TestCase): def test_domain_conversion(self): """Test whether a domain can be used for conversion.""" data = SMALL_COLLAGEN