[pymvpa] getting simple regression working
kimberg at mail.med.upenn.edu
kimberg at mail.med.upenn.edu
Tue Feb 9 16:37:47 UTC 2010
Hi all. I've just started exploring PyMVPA (0.4.4) and I have a few newbie questions that I hope aren't too inappropriate for this list (but please let me know if otherwise).
I want to explore regression (i.e., not classification) methods, and just to get started, I'm trying to make sure I understand the results from a simple non-image test case. So I did the following first:
>>> from mvpa.suite import *
>>> import numpy as n
>>> iv=n.random.normal(0,1,(5,1))
>>> dv=2.0*iv
>>> mydata=Dataset(samples=iv,labels=dv)
>>> cc=GPR(regression=True,kernel=KernelLinear())
>>> cc.train(mydata)
>>> cc.predict(mydata.samples)-dv
array([[ -3.38198902e-07],
[ -1.41435398e-06],
[ 1.15496877e-06],
[ 1.68858526e-08],
[ 5.80698004e-07]])
My intuition is that this is pretty good for GPR with just five samples, and GPR does give me smaller errors (O(1e-10)) if I give it a lot more samples. Simple linear regression should obviously produce even smaller errors for this degenerate case, but I couldn't find it in the list of classifiers. Incidentally, is there an easy way to retrieve the model parameters?
Following this reasonably successful first attempt, I thought I would try to get SVR working, but the following happened:
>>> cc=SVM(svm_impl='NU_SVR',kernel_type='rbf')
>>> cc.train(mydata)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/mvpa/clfs/base.py", line 382, in train
result = self._train(dataset)
File "/usr/lib64/python2.6/site-packages/mvpa/clfs/libsvmc/svm.py", line 132, in _train
svmprob = svm.SVMProblem( dataset.labels.tolist(), src )
File "/usr/lib64/python2.6/site-packages/mvpa/clfs/libsvmc/_svm.py", line 219, in __init__
svmc.double_setitem(y_array, i, y[i])
TypeError: in method 'double_setitem', argument 3 of type 'double'
I started to look at the code, but as I'm new to PyMVPA, couldn't figure out where this went wrong. In case it makes a difference, I built PyMVPA from source, using the included libsvm. Any help would be greatly appreciated.
Thanks,
dan
More information about the Pkg-ExpPsy-PyMVPA
mailing list