日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

【机器学习】时间序列预测:三次指数平滑(Holt-Winters)

發(fā)布時(shí)間:2024/1/18 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【机器学习】时间序列预测:三次指数平滑(Holt-Winters) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

statsmodels是一個(gè)Python模塊,它提供對(duì)許多不同統(tǒng)計(jì)模型估計(jì)的類和函數(shù),并且可以進(jìn)行統(tǒng)計(jì)測(cè)試和統(tǒng)計(jì)數(shù)據(jù)的探索。

# -*- encoding:utf-8 -*-import pandas as pd import matplotlib.pyplot as pltfrom statsmodels.tsa.holtwinters import ExponentialSmoothing# 1、對(duì)數(shù)據(jù)的預(yù)處理 input_data = open("ftproot.txt", mode='r').read().split("\n") time_data = [] for i in range(len(input_data)):time_data.append(input_data[i].split(",")) # 全部數(shù)據(jù) all_data = [] for i in range(len(time_data)):all_data.append(float(time_data[i][1])) # 分一部分出來作為train數(shù)據(jù) train_data = [] test_data = [] train_data.extend([all_data[i] for i in range(0, 1334)]) test_data.extend([all_data[i] for i in range(1334, len(all_data))])# 2、模型參數(shù) ets3 = ExponentialSmoothing(train_data, trend='add', seasonal='add', seasonal_periods=24) # 3、擬合模型 r3 = ets3.fit() # 4、預(yù)測(cè) pred3 = r3.predict(start=len(train_data), end=len(all_data)-1) # 5、畫圖,可以忽略 pd.DataFrame({'origin': test_data,'pred': pred3 }).plot(legend=True) plt.show() print(pred3)

參數(shù):

Holt Winter's Exponential SmoothingParameters----------endog : array-likeTime seriestrend : {"add", "mul", "additive", "multiplicative", None}, optionalType of trend component.damped : bool, optionalShould the trend component be damped.seasonal : {"add", "mul", "additive", "multiplicative", None}, optionalType of seasonal component.seasonal_periods : int, optionalThe number of seasons to consider for the holt winters.Returns-------results : ExponentialSmoothing class Notes-----This is a full implementation of the holt winters exponential smoothing asper [1]. This includes all the unstable methods as well as the stable methods.The implementation of the library covers the functionality of the R library as much as possible whilst still being pythonic.

第一個(gè)endog,時(shí)間序列數(shù)據(jù),array-like的形式。
第二個(gè)trend是趨勢(shì),有三種可選項(xiàng),就是加法趨勢(shì)、乘法趨勢(shì)還有None。
第三個(gè)damped是衰減,Boolean決定是否對(duì)趨勢(shì)進(jìn)行衰減。
第四個(gè)seasonal是季節(jié)性(周期),也是三種選項(xiàng),加法、乘法還有None。
第五個(gè)seasonal_periods,季節(jié)性周期,int型,holt-winter要考慮的季節(jié)的數(shù)量。簡(jiǎn)單來說,多少點(diǎn)是一個(gè)周期?你可以設(shè)定為一天,一星期,一個(gè)月,一年等等

?

總結(jié)

以上是生活随笔為你收集整理的【机器学习】时间序列预测:三次指数平滑(Holt-Winters)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。