def test_anova(self): """Do some extended testing of OneWayAnova in particular -- compound estimation """ m = OneWayAnova() # default must be not compound ? mc = CompoundOneWayAnova() ds = datasets['uni2medium'] # For 2 labels it must be identical for both and equal to # simple OneWayAnova a, ac = m(ds), mc(ds) self.assertTrue(a.shape == (1, ds.nfeatures)) self.assertTrue(ac.shape == (len(ds.UT), ds.nfeatures)) assert_array_equal(ac[0], ac[1]) assert_array_equal(a, ac[1]) # check for p-value attrs if externals.exists('scipy'): assert_true('fprob' in a.fa.keys()) assert_equal(len(ac.fa), len(ac)) ds = datasets['uni4large'] ac = mc(ds) if cfg.getboolean('tests', 'labile', default='yes'): # All non-bogus features must be high for a corresponding feature self.assertTrue( (ac.samples[np.arange(4), np.array(ds.a.nonbogus_features)] >= 1).all()) # All features should have slightly but different CompoundAnova # values. I really doubt that there will be a case when this # test would fail just to being 'labile' self.assertTrue(np.max(np.std(ac, axis=1)) > 0, msg='In compound anova, we should get different' ' results for different labels. Got %s' % ac)
from mvpa2.generators.partition import NFoldPartitioner from mvpa2.generators.resampling import Balancer from mvpa2.misc.errorfx import mean_mismatch_error from mvpa2.misc.transformers import Absolute, \ DistPValue from mvpa2.measures.base import Measure, \ TransferMeasure, RepeatedMeasure, CrossValidation from mvpa2.measures.anova import OneWayAnova, CompoundOneWayAnova from mvpa2.measures.irelief import IterativeRelief, IterativeReliefOnline, \ IterativeRelief_Devel, IterativeReliefOnline_Devel _MEASURES_2_SWEEP = [ OneWayAnova(), CompoundOneWayAnova(postproc=sumofabs_sample()), IterativeRelief(), IterativeReliefOnline(), IterativeRelief_Devel(), IterativeReliefOnline_Devel() ] if externals.exists('scipy'): from mvpa2.measures.corrcoef import CorrCoef _MEASURES_2_SWEEP += [ CorrCoef(), # that one is good when small... handle later #CorrCoef(pvalue=True) ] class SensitivityAnalysersTests(unittest.TestCase):