通过pyRserve从Python调用auto.arima

时间:2017-12-21 17:31:46

标签: python rserve pyrserve

我一直在尝试使用pyRserve进行时间序列预测,并且意图使用R中的auto.arima函数。

我使用以下代码解决了名称中包含点的函数问题,例如auto.arima

import pyRserve
import pandas as pd
import numpy
conn = pyRserve.connect()

df = pd.read_excel('D:/My Path/C9.xlsx', sheet_name='C9')
aList = df['Value'].tolist()  # Cast the desired column into a python list
aList = numpy.array(aList)
conn.r.List = aList

auto_arima = getattr(conn.r, 'auto.arima')
conn.r.sapply(conn.ref.List, auto_arima)

但是,它返回了这个错误:

Traceback (most recent call last):
  File "D:/Forecast/Python/R2Python/R2P_Practice.py", line 21, in <module>
    auto_arima = getattr(conn.r, 'auto.arima')
  File "C:\Python27\lib\site-packages\pyRserve\rconn.py", line 308, in __getattr__
    'defined in Rserve' % realname)
NameError: no such variable or function "auto.arima" defined in Rserve

似乎在Rserve中未定义auto.arima。为什么不在那里?我该如何解决这个问题?

0 个答案:

没有答案