python statsmodel的使用
Python Data Analysis Library 或 pandas 是基于NumPy 的一種工具,相當(dāng)于這是Python官方自己的一套庫(kù)
statsmodel是基于Pandas開發(fā)的一套庫(kù),用于一些描述統(tǒng)計(jì)、統(tǒng)計(jì)模型估計(jì)、推斷、預(yù)測(cè)
2、自回歸模型(AutoRegression model,AR)自回歸,從物理的角度來(lái)理解就是:當(dāng)前記錄與其歷史記錄的差值。eg,自回歸認(rèn)為歷史的發(fā)展是一條斜率一定的直線。
3、滑動(dòng)平均模型(moving average model, MA)移動(dòng)平均,從物理的角度來(lái)理解就是:當(dāng)前記錄是歷史記錄的均值。eg,移動(dòng)平均模型認(rèn)為歷史的發(fā)展是一條水平的線。
4、高級(jí)時(shí)間序列模型ARMAARMA就是把AR和MA結(jié)合在一起的一種算法,當(dāng)AR和MA混合在一起,可以認(rèn)為是一個(gè)y=ax+b的過(guò)程,自回歸提供了a這個(gè)系數(shù),移動(dòng)平均提供了b這個(gè)截距。
5、高級(jí)時(shí)間序列模型ARIMA【autoregression intergrated moving average差分自回歸移動(dòng)平均】ARIMA中,I指代的差分,其實(shí)是 前后時(shí)間上數(shù)值的差異,ARIMA就是使用差分的數(shù)據(jù)來(lái)進(jìn)行ARMA建模
6、ARMA測(cè)試import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport statsmodels.api as smfrom statsmodels.graphics.tsaplots import acf, pacf, plot_acf, plot_pacffrom statsmodels.tsa.arima_model import ARMAfrom statsmodels.tsa.stattools import arma_order_select_icif __name__ == '__main__': time_series = pd.Series( [151.0, 188.46, 199.38, 219.75, 241.55, 262.58, 328.22, 396.26, 442.04, 517.77, 626.52, 717.08, 824.38, 913.38, 1088.39, 1325.83, 1700.92, 2109.38, 2499.77, 2856.47, 3114.02, 3229.29, 3545.39, 3880.53, 4212.82, 4757.45, 5633.24, 6590.19, 7617.47, 9333.4, 11328.92, 12961.1, 15967.61]) # print(’BIC求解的模型階次為’, arma_order_select_ic(time_series, max_ar=10, max_ma=6, ic=’bic’)[’bic_min_order’]) print(’time_series:’, len(time_series)) my_arma = ARMA(time_series, (1, 0)) # 這里的(1, 0)從arma_order_select_ic函數(shù)返回,但是這里返回6,7運(yùn)行失敗 model = my_arma.fit() result = model.forecast(10)[0] print(’result:’, result)
以上就是python statsmodel的使用的詳細(xì)內(nèi)容,更多關(guān)于python statsmodel的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法2. 簡(jiǎn)述JAVA同步、異步、阻塞和非阻塞之間的區(qū)別3. Python TestSuite生成測(cè)試報(bào)告過(guò)程解析4. 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法5. SpringBoot項(xiàng)目?jī)?yōu)雅的全局異常處理方式(全網(wǎng)最新)6. docker /var/lib/docker/aufs/mnt 目錄清理方法7. IntelliJ IDEA設(shè)置背景圖片的方法步驟8. 如何清空python的變量9. 解決python路徑錯(cuò)誤,運(yùn)行.py文件,找不到路徑的問(wèn)題10. python操作數(shù)據(jù)庫(kù)獲取結(jié)果之fetchone和fetchall的區(qū)別說(shuō)明
