[pymvpa] Multi-class SVM Sensitivities

Mark Lescroart lescroar at usc.edu
Sun Nov 15 23:10:03 UTC 2009


Hello,

I have a question regarding extracting sensitivity values for a multi- 
class SVM classifier.

For whatever reason, I do not seem to be able to get 1 sensitivity  
value per feature (i.e., per voxel) - I get only three values,  
presumably one per condition.

The code I am using deviates from some very basic examples in two ways  
that I can see: (1) I'm using a multi-class classifier, and (2) I'm  
importing the data from Matlab .mat files rather than NIfTI files. I'm  
using the .mat files because I use Brain Voyager for my data pre- 
processing, and I have had less trouble exporting the files with the  
BVQXtools Matlab toolbox than I have had exporting the files to NIfTI  
format.

The code I am using is below.

What am I doing wrong? Am I missing something conceptually?

Thanks for your time (and your excellent toolbox),

Mark

~~~~~~~~~~

from scipy.io import loadmat
from mvpa.suite import *

DatFile = 'WholeBrainMatFile.mat' # 4-D .mat file of 2x2x2 voxels -  
440x80x60x69 matrix
MaskFile = 'ROI_Mask.mat' # Contains a mask for 649 voxels in the  
Lateral Occipital area
AttrFile = 'ConditionLabels.txt'

D = loadmat(DatFile)
Data = D['Data']
M = loadmat(MaskFile)
MaskMat = M['Mask']
attr = SampleAttributes(AttrFile)

# create masked data set
PyDat =  
MaskedDataset 
(samples=Data,labels=attr.labels,chunks=attr.chunks,mask=MaskMat)
zscore(PyDat,perchunk=True,targetdtype='float32')
# PyDat is: <Dataset / float32 440 x 649 uniq: 8 chunks 3 labels>

clf = LinearCSVMC()

# Side question: what is the difference between option 1 and option 2?

# Option 1:
Sensitivity_FromCLF = clf.getSensitivityAnalyzer()(PyDat)
# This results in a 3x1 array of values

# Option 2:
terr = TransferError(clf)
splitter = NFoldSplitter(cvtype=1)
cvterr = CrossValidatedTransferError(
	terr,
	splitter,
	enable_states='confusion',
	 
harvest_attribs 
=['transerror.clf.getSensitivityAnalyzer(force_training=False)()']
	)
Err = cvterr(PyDat)
Sensitivity_FromCVTransError = cvterr.harvested.values()[0]
# This results in a list of 8 3x1 arrays

# Neither option results in 649x1 arrays, which it seems to me that  
they should (i.e., there should be one sensitivity value per feature)



~~~~~~~~~~~~~~~~~~~~~~~~~~

Mark Lescroart
(say it LESS-qua)

University of Southern California
Neuroscience Graduate Program
Image Understanding Lab
Email: mark.lescroart at usc.edu
Cell: (213) 447-0752




More information about the Pkg-ExpPsy-PyMVPA mailing list