[pymvpa] SL on an artificial dataset

Michael Hanke mih at debian.org
Thu Mar 29 12:15:25 UTC 2012


Hi,

On Thu, Mar 29, 2012 at 02:06:36PM +0200, Matthias Ekman wrote:
> Hi,
> 
> sometimes I still encounter some problems with the transition from
> mvpa to mvpa2. This time, I would like to run a Searchlight on an
> artificial dataset. Previously that could be done like this:
> 
> from sklearn.datasets import make_classification
> X,y = make_classification(n_samples=55, n_features=630, n_classes=2)
> ds = MaskedDataset(samples=X, labels=y, chunks=np.arange(y.size))
> cv = CrossValidatedTransferError(
>          TransferError(LinearCSVMC()),
>          OddEvenSplitter())
> sl = Searchlight(cv, radius=5)
> 
> In mvpa2 I could do the same
> 
> ds = Dataset(X)
> ds.targets = y
> ds.chunks = np.arange(55)
> 
> but the sphere_searchlight requires a 'space' parameter. Here I
> don't have real neighbor-space relations. It can be completely
> random or neighbors in the np.array. How would you define that for a
> synthetic dataset?

You should be able to create some feature attribute with arbitrary
coordinates, e.g.

ds.fa['mycoord'] = np.arange(ds.nfeatures)

Now you can use 'mycoord' as the space to let the searchlight iterate
over.

Should work.

Michael

-- 
Michael Hanke
http://mih.voxindeserto.de



More information about the Pkg-ExpPsy-PyMVPA mailing list