gluonts
0.16.0
?突發新聞:我們發布了Chronos ,這是一套預算的型模型,用於預測零時的時間序列。計時可以為訓練期間未觀察到的新時間序列產生準確的概率預測。在這裡檢查一下!
Gluonts是用於概率時間序列建模的Python軟件包,專注於基於Pytorch和MXNET的深度學習模型。
Gluonts需要Python 3.7或更新,最簡單的安裝方法是通過pip :
# install with support for torch models
pip install " gluonts[torch] "
# install with support for mxnet models
pip install " gluonts[mxnet] "有關如何安裝Gluonts,請參見文檔。
為了說明如何使用Gluonts,我們訓練Deepar模型並使用Airpassengers數據集進行預測。數據集由1949年至1960年之間的每月乘客人數的單個時間序列組成。我們在頭九年中訓練該模型,並在剩餘的三年中進行預測。
import pandas as pd
import matplotlib . pyplot as plt
from gluonts . dataset . pandas import PandasDataset
from gluonts . dataset . split import split
from gluonts . torch import DeepAREstimator
# Load data from a CSV file into a PandasDataset
df = pd . read_csv (
"https://raw.githubusercontent.com/AileenNielsen/"
"TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv" ,
index_col = 0 ,
parse_dates = True ,
)
dataset = PandasDataset ( df , target = "#Passengers" )
# Split the data for training and testing
training_data , test_gen = split ( dataset , offset = - 36 )
test_data = test_gen . generate_instances ( prediction_length = 12 , windows = 3 )
# Train the model and make predictions
model = DeepAREstimator (
prediction_length = 12 , freq = "M" , trainer_kwargs = { "max_epochs" : 5 }
). train ( training_data )
forecasts = list ( model . predict ( test_data . input ))
# Plot predictions
plt . plot ( df [ "1954" :], color = "black" )
for forecast in forecasts :
forecast . plot ()
plt . legend ([ "True values" ], loc = "upper left" , fontsize = "xx-large" )
plt . show ()注意,預測是根據概率分佈來顯示的,陰影區域代表50%和90%的預測間隔。
如果您想為該項目做出貢獻,請參閱我們的貢獻指南。
如果您在科學出版物中使用Gluonts,我們鼓勵您除了與您的工作相關的任何特定模型的參考文獻外,還向相關論文添加以下參考文獻:
@article { gluonts_jmlr ,
author = { Alexander Alexandrov and Konstantinos Benidis and Michael Bohlke-Schneider
and Valentin Flunkert and Jan Gasthaus and Tim Januschowski and Danielle C. Maddix
and Syama Rangapuram and David Salinas and Jasper Schulz and Lorenzo Stella and
Ali Caner Türkmen and Yuyang Wang } ,
title = { {GluonTS: Probabilistic and Neural Time Series Modeling in Python} } ,
journal = { Journal of Machine Learning Research } ,
year = { 2020 } ,
volume = { 21 } ,
number = { 116 } ,
pages = { 1-6 } ,
url = { http://jmlr.org/papers/v21/19-820.html }
} @article { gluonts_arxiv ,
author = { Alexandrov, A. and Benidis, K. and Bohlke-Schneider, M. and
Flunkert, V. and Gasthaus, J. and Januschowski, T. and Maddix, D. C.
and Rangapuram, S. and Salinas, D. and Schulz, J. and Stella, L. and
Türkmen, A. C. and Wang, Y. } ,
title = { {GluonTS: Probabilistic Time Series Modeling in Python} } ,
journal = { arXiv preprint arXiv:1906.05264 } ,
year = { 2019 }
}