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 }
}