Ich versuche, eine einfache lineare Regression (mit rpy2 aus Python) zu tun und stieß auf eine seltsam formulierte Fehler bei Ausführung des Skripts unter:'ValueError: Nichts kann für den Typ <class' numpy.core.records.recarray '> im Moment' Fehler
from numpy import array, rec
from numpy.random import normal as nprandom
from rpy2.robjects import numpy2ri, r
foo = array(range(10))
bar = foo + nprandom(0,1,10)
d = rec.fromarrays([foo, bar], names=('foo','bar'))
fit = r.lm('bar ~ foo', data=d)
print fit.rx2('coefficients')
hier ist die Ausgabe der Konsole:
>>> from numpy import array, rec
>>> from numpy.random import normal as nprandom
>>> from rpy2.robjects import numpy2ri, r
>>>
>>> foo = array(range(10))
>>> bar = foo + nprandom(0,1,10)
>>>
>>> d = rec.fromarrays([foo, bar], names=('foo','bar'))
>>> fit = r.lm('bar ~ foo', data=d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/functions.py", line 82, in __call__
return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/functions.py", line 33, in __call__
new_kwargs[k] = conversion.py2ri(v)
File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/__init__.py", line 134, in default_py2ri
raise(ValueError("Nothing can be done for the type %s at the moment." %(type(o))))
ValueError: Nothing can be done for the type <class 'numpy.core.records.recarray'> at the moment.
>>> print fit.rx2('coefficients')
ich bin mit Python 2.6.5 und haben numpy Version 1.6.1
jemand weiß, was verursacht th ist ein Fehler?