从金字塔导入 auto_arima 时出错

Error importing auto_arima from pyramid

尝试使用金字塔的自动 arima 功能,但没有成功。

导入整个class:

import pyramid



stepwise_fit = auto_arima(df.Weighted_Price, start_p=0, start_q=0, max_p=10, max_q=10, m=1,
                      start_P=0, seasonal=True, trace=True,
                      error_action='ignore',  # don't want to know if an order does not work
                      suppress_warnings=True,  # don't want convergence warnings
                      stepwise=True)  # set to stepwise

我收到错误消息:

NameError: name 'auto_arima' is not defined

好吧,那么让我们从金字塔中导入那个特定的包。

from pyramid.arima import auto_arima

--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa

--------------------------------------------------------------------------- ImportError Traceback (most recent call last) in () 1 #trying to import pyramid ----> 2 from pyramid.arima import auto_arima

/usr/local/lib/python2.7/site-packages/pyramid/arima/init.py in () 3 # Author: Taylor Smith 4 ----> 5 from .approx import * 6 from .arima import * 7 from .auto import *

/usr/local/lib/python2.7/site-packages/pyramid/arima/approx.py in () 16 # and since the platform might name the .so file something funky (like 17 # _arima.cpython-35m-darwin.so), import this absolutely and not relatively. ---> 18 from pyramid.arima._arima import C_Approx 19 20 all = [

ImportError: numpy.core.multiarray failed to import

在导入 numpy 之后,甚至只是再次 运行 块之后,我在 运行 from pyramid.arima import auto_arima

时收到此错误消息

--------------------------------------------------------------------------- ImportError Traceback (most recent call last) in () 1 #trying to import pyramid ----> 2 from pyramid import arima

/usr/local/lib/python2.7/site-packages/pyramid/arima/init.py in () 3 # Author: Taylor Smith 4 ----> 5 from .approx import * 6 from .arima import * 7 from .auto import *

/usr/local/lib/python2.7/site-packages/pyramid/arima/approx.py in () 16 # and since the platform might name the .so file something funky (like 17 # _arima.cpython-35m-darwin.so), import this absolutely and not relatively. ---> 18 from pyramid.arima._arima import C_Approx 19 20 all = [

ImportError: cannot import name C_Approx

  1. 尝试卸载 numpy 并安装最新版本。
  2. 尝试从 Anaconda 安装 pyramid-arima。

使用:

pip install pyramid-arima

您安装了不是您要找的网络框架金字塔。

环境: Windows 10 IDE: Pycharm Python: 3.6

在Anaconda中,创建一个新环境然后运行:

pip install pyramid-arima

现在在您的 python 代码中,您可以使用:

from pyramid.arima import auto_arima

尝试使用 pip 安装 pmdarima

pip install pmdarima

然后在您的 python 脚本中使用:

from pmdarima.arima import auto_arima

这对我有用:(Anaconda 提示)

$ conda create -n pmdissue23 --yes --quiet python=3.5 numpy scipy scikit-learn statsmodels
activate pmdissue23
(pmdissue23) $ pip install pmdarima

在 anaconda 导航器中,

from pmdarima import auto_arima