栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Statsmodels中ARMIA报错求助: ‘NoneType‘ object has no attribute ‘params‘

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Statsmodels中ARMIA报错求助: ‘NoneType‘ object has no attribute ‘params‘

我尝试着使用statsmodels中的ARMIA模块计算最佳滞后阶数和差分数时出现了问题
这是我的train_date数据:
trade_date
2021-01-04    27.78
2021-01-05    27.91
2021-01-06    28.75
2021-01-07    28.79
2021-01-08    29.34
2021-01-11    29.78
2021-01-12    29.70
2021-01-13    29.90
2021-01-14    29.99
2021-01-15    29.95
2021-01-18    31.26
2021-01-19    31.28
2021-01-20    30.50
2021-01-21    30.10
2021-01-22    29.26
2021-01-25    29.36
2021-01-26    29.70
2021-01-27    29.40
2021-01-28    28.43
2021-01-29    27.79
2021-02-01    28.07
2021-02-02    28.34
2021-02-03    27.92
2021-02-04    27.89
2021-02-05    28.88
2021-02-08    29.13
2021-02-09    28.75
2021-02-10    28.83
2021-02-18    30.01
2021-02-19    29.84
2021-02-22    29.73
2021-02-23    30.01
2021-02-24    29.99
2021-02-25    32.99
2021-02-26    33.10
2021-03-01    33.35
2021-03-02    33.29
2021-03-03    33.50
2021-03-04    32.69
2021-03-05    31.54
2021-03-08    31.20
2021-03-09    31.02
2021-03-10    30.69
2021-03-11    31.15
2021-03-12    31.49
2021-03-15    31.44
2021-03-16    32.90
2021-03-17    32.71
2021-03-18    32.70
代码如下:
import tushare as ts
import pandas as pd
import numpy as np
df=pd.read_csv('000002.SZ.csv')
df.index = pd.to_datetime(df["trade_date"],format='%Y%m%d')
from statsmodels.tsa.api import ARIMA
train_data=df['close'][:-10]
test_data=df['close'][-10:]
print(train_data)
min_aic=np.inf
best_order=None
best_arima=None
counter=5
biger=2
for i in range(counter):
    for k in range(biger):
        for j in range(counter):
            try:
                tmp_arima=ARIMA(train_data,order=(i,k,j)).fit(method='mle',trend='nc')
                tmp_aic=tmp_arima.aic
                if tmp_aic < min_aic:
                    min_aic = tmp_aic
                    best_order = (i,k,j)
                    best_arima = tmp_arima
            except:continue
print("order",best_order)
print("para",best_arima.params)

当我一运行时就会出现

 'NoneType' object has no attribute 'params'

但是始终不知道问题出现在哪,希望有大神可以解答一下

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/934667.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号