[pymvpa] TypeError: unhashable type: 'numpy.ndarray'

Dmitry Smirnov dmi.smirnov07 at gmail.com
Tue Aug 20 12:09:46 UTC 2013


Hi!

I'm trying to run some simple classification to get used to PyMVPA.
Specifically, I'm trying to classify 4 types of stimuli presented using
mask of 4501 voxels.

Here is the error and code. I'm new to python, so not much of experience in
figuring out error messages. Thanks in advance for all the suggestions!

ERROR:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/learner.py", line
239, in __call__
    return super(Learner, self).__call__(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/node.py", line 84, in
__call__
    result = self._call(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/measures/base.py", line
472, in _call
    return super(CrossValidation, self)._call(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/measures/base.py", line
301, in _call
    result = node(sds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/learner.py", line
239, in __call__
    return super(Learner, self).__call__(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/node.py", line 84, in
__call__
    result = self._call(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/measures/base.py", line
583, in _call
    res = measure(dstest)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/learner.py", line
239, in __call__
    return super(Learner, self).__call__(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/node.py", line 84, in
__call__
    result = self._call(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/clfs/base.py", line 438,
in _call
    pred = self.predict(ds)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/clfs/base.py", line 48, in
wrap_samples
    return fx(obj, data, *args, **kwargs)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/clfs/base.py", line 409,
in predict
    result = self._predict(dataset)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/base/types.py", line 35,
in extract_samples
    return fx(obj, data.samples)
  File "/scratch/braindata/DSmirnov/PyMVPA/mvpa2/clfs/knn.py", line 191, in
_predict
    votes[labels[nn]] += 1
TypeError: unhashable type: 'numpy.ndarray'

CODE:

from mvpa2.suite import *

from scipy import *


# samples: 1730x4501 matrix, rows=timepoints, columns=voxels
# regressor: 1730x1 vector, rows=labels of stimuli
# chunks: 1730x1 vector, rows=labels of independent runs (5 of them)

ds = dataset_wizard(samples, targets = regressor, chunks = selector)

clf = kNN(k=1, dfx=one_minus_correlation, voting='majority')

cvte = CrossValidation(clf, NFoldPartitioner())

cv_results = cvte(ds)





BR, Dima

-- 

Dmitry Smirnov (MSc.)
PhD Candidate, Brain & Mind Laboratory <http://becs.aalto.fi/bml/>
BECS, Aalto University School of Science
00076 AALTO, FINLAND
mobile: +358 50 3015072
email: dmitry.smirnov at aalto.fi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20130820/36c2081a/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list