python statsmodel的使用
Python Data Analysis Library 或 pandas 是基于NumPy 的一種工具,相當(dāng)于這是Python官方自己的一套庫(kù)
statsmodel是基于Pandas開(kāi)發(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. python 讀txt文件,按‘,’分割每行數(shù)據(jù)操作2. Python 忽略文件名編碼的方法3. JavaEE SpringMyBatis是什么? 它和Hibernate的區(qū)別及如何配置MyBatis4. 解決vue頁(yè)面刷新,數(shù)據(jù)丟失的問(wèn)題5. android studio實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器(無(wú)bug)6. Java Media Framework 基礎(chǔ)教程7. 在Mac中配置Python虛擬環(huán)境過(guò)程解析8. python如何實(shí)現(xiàn)word批量轉(zhuǎn)HTML9. 利用單元測(cè)試對(duì)PHP代碼進(jìn)行檢查10. python excel和yaml文件的讀取封裝
