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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

statsmodels是一個Python模塊,它提供對許多不同統計模型估計的類和函數,并且可以進行統計測試和統計數據的探索。

# -*- encoding:utf-8 -*-import pandas as pd import matplotlib.pyplot as pltfrom statsmodels.tsa.holtwinters import ExponentialSmoothing# 1、對數據的預處理 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(",")) # 全部數據 all_data = [] for i in range(len(time_data)):all_data.append(float(time_data[i][1])) # 分一部分出來作為train數據 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、模型參數 ets3 = ExponentialSmoothing(train_data, trend='add', seasonal='add', seasonal_periods=24) # 3、擬合模型 r3 = ets3.fit() # 4、預測 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)

參數:

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.

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

?

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。