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