Package mvpa :: Package measures :: Module ds
[hide private]
[frames] | no frames]

Source Code for Module mvpa.measures.ds

 1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  # vi: set ft=python sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Dissimilarity measure. 
10   
11  """ 
12   
13  __docformat__ = 'restructuredtext' 
14   
15  import numpy as N 
16  from mvpa.measures.base import DatasetMeasure 
17  from mvpa.misc.stats import DSMatrix 
18   
19 -class DSMDatasetMeasure(DatasetMeasure):
20 """DSMDatasetMeasure creates a DatasetMeasure object 21 where metric can be one of 'euclidean', 'spearman', 'pearson' 22 or 'confusion'""" 23
24 - def __init__(self, dsmatrix, dset_metric, output_metric='spearman'):
25 DatasetMeasure.__init__(self) 26 27 self.dsmatrix = dsmatrix 28 self.dset_metric = dset_metric 29 self.output_metric = output_metric 30 self.dset_dsm = []
31 32
33 - def __call__(self, dataset):
34 # create the dissimilarity matrix for the data in the input dataset 35 self.dset_dsm = DSMatrix(dataset.samples, self.dset_metric) 36 37 in_vec = self.dsmatrix.getVectorForm() 38 dset_vec = self.dset_dsm.getVectorForm() 39 40 # concatenate the two vectors, send to dissimlarity function 41 test_mat = N.asarray([in_vec, dset_vec]) 42 43 test_dsmatrix = DSMatrix(test_mat, self.output_metric) 44 45 # return correct dissimilarity value 46 return test_dsmatrix.getFullMatrix()[0, 1]
47