1   
 2   
 3   
 4   
 5   
 6   
 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   
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   
34           
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           
41          test_mat = N.asarray([in_vec, dset_vec]) 
42   
43          test_dsmatrix = DSMatrix(test_mat, self.output_metric) 
44   
45           
46          return test_dsmatrix.getFullMatrix()[0, 1] 
  47