亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python statsmodel的使用

 更新時(shí)間:2020年12月21日 15:48:36   作者:朱小勇  
這篇文章主要介紹了python statsmodel使用的相關(guān)資料,幫助大家更好的理解和使用python,感興趣的朋友可以了解下

1、Pandas

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í)間序列模型ARMA

ARMA就是把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 pd
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
from statsmodels.graphics.tsaplots import acf, pacf, plot_acf, plot_pacf
from statsmodels.tsa.arima_model import ARMA
from statsmodels.tsa.stattools import arma_order_select_ic

if __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)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論