简体   繁体   English

Colab 中没有名为“statsmodels.tsa.arima”的模块,但在 Pycharm 中没有

[英]No module named 'statsmodels.tsa.arima' in Colab but not in Pycharm

# ARIMA example
from statsmodels.tsa.arima.model import ARIMA
data = [200,30,30,35,30,20,26,35,30,33,40,29,29,30,30,30,30,20,26,35,30,33,40,29,29,30,30,30]
# fit model
model = ARIMA(data, order=(10, 1, 10))
model_fit = model.fit()
# make prediction
yhat = model_fit.predict(len(data), len(data), typ='levels')
print(yhat)

The from statsmodels.tsa.arima.model import ARIMA is wokring perfectly in pycharm but while running the same code in colab it throws from statsmodels.tsa.arima.model import ARIMA在 pycharm 中完美运行,但在 colab 中运行相同的代码时会抛出在此处输入图像描述 There are very few supports there on inte.net for this library, so I would appreciate any sort of help or any workaround please. inte.net 上对该库的支持很少,所以我将不胜感激任何类型的帮助或任何解决方法。

You import statsmodels like this:您像这样导入 statsmodels:

import statsmodels.api as sm

And then you can use SARIMA like this:然后你可以像这样使用 SARIMA:

model=sm.tsa.arima.ARIMA(data,order=(10, 1, 10))

The arima_model import is deprecated. arima_model 导入已弃用。 You can read more about using ARIMA here. 您可以在此处阅读有关使用 ARIMA 的更多信息。

You need a newer version.你需要一个更新的版本。 Try to run the following in your Colab:尝试在您的 Colab 中运行以下命令:

.pip install statsmodels==0.12.1

It will allow the import that you want.它将允许您想要的导入。

Try,尝试,

from statsmodels.tsa.arima_model import ARIMA

if you don't have statsmodel installed then also do, pip install statsmodels如果你没有安装 statsmodel 也可以安装,pip install statsmodels

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM