[pymvpa] custom cross-validation procedure: train on individual blocks, test on averaged blocks?
Yaroslav Halchenko
debian at onerussian.com
Thu Mar 8 14:55:07 UTC 2012
now that it is morning I see it clearer ;)
so... it has nothing to do you with disbalanced set in your case -- it is
due to assigned by me unique 'custom' sample attribute per each sample in
training so they do not get meanned...
what I have ovelooked though that by the time measure obtains the
dataset for training or testing it is already split, so we can fulfill
your need in more straightforward way which would not confuse the
partitioner:
class MeanTesting(Mapper):
def _forward_dataset(self, ds):
# Here we get already split training or testing dataset
# so it should have a single partition
assert(len(ds.sa['partitions'].unique) == 1)
if np.all(ds.sa.partitions == 1):
# so we got training split
# thus nothing really todo
return ds
else:
# and for testing mean the beast per each target
return mean_group_sample(['targets'])(ds)
cv2 = CrossValidation(ChainMapper(
[MeanTesting(),
CLASSIFIER], space='targets'),
NFoldPartitioner(1),
descr='custom-CV2')
is this one clearer? results must be identical
> print dataset.summary() yields:
> Counts of targets in each chunk:
> chunks\targets HI HO
> --- ---
> 0.0 3 2
--
=------------------------------------------------------------------=
Keep in touch www.onerussian.com
Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic
More information about the Pkg-ExpPsy-PyMVPA
mailing list