Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow:预测时间序列预测中的增长因子_Python_Tensorflow_Machine Learning_Deep Learning_Tensorflow Estimator - Fatal编程技术网

Python Tensorflow:预测时间序列预测中的增长因子

Python Tensorflow:预测时间序列预测中的增长因子,python,tensorflow,machine-learning,deep-learning,tensorflow-estimator,Python,Tensorflow,Machine Learning,Deep Learning,Tensorflow Estimator,我正在开发一个应用程序,使用罐装估计器tf.Estimator.DNNRegressor estimator = tf.estimator.DNNRegressor( feature_columns=my_feature_columns, hidden_units=hidden_units, model_dir=model_dir, optimizer=tf.train.ProximalAdagradOptimizer(

我正在开发一个应用程序,使用罐装估计器
tf.Estimator.DNNRegressor

    estimator = tf.estimator.DNNRegressor(
        feature_columns=my_feature_columns,
        hidden_units=hidden_units, 
        model_dir=model_dir, 
        optimizer=tf.train.ProximalAdagradOptimizer(learning_rate=0.01,
                                                l1_regularization_strength=0.001))
我使用的功能基本上是基于日期和时间的。例如,我的培训数据中的
csv
文件如下所示

year,month,day,weekday,isweekend,hr,weeknum,yearday,orders
2018,7,16,2,0,0,29,197,193
2018,7,16,2,0,1,29,197,131
2018,7,16,2,0,2,29,197,77
2018,7,16,2,0,3,29,197,59
.....
其中“订单”列是模型的目标

到目前为止,我得到的模型运行良好,但当我预测像黑色星期五这样的高需求日时,它被低估了。例如,在下图中,我们可以看到,对2018年黑色星期五的预测(虚线)并没有我们直觉预期的那么高,尽管它很好地预测了形状


综上所述,如果您能向我的模型中添加任何建议,我将不胜感激,这样它就可以正确预测增长因子,而不仅仅是趋势。

这是一个时间序列问题,因此您最好使用
tf.contrib.timeseries.ARRegressor
(专为时间序列构建的神经网络)或者
tf.contrib.timeseries.StructuralEnsembleRegressor
(时间序列状态空间模型-它)比一般的神经网络

这两个模型都采用了一个外生的参数,你可以用0来填充正常天数,用1来填充黑色星期五之类的事件天数。这将解决预测不足的问题,因为否则模型会将这些峰值视为异常值(即使使用通用神经网络也可以做到这一点——使用特定于时间序列的函数编写代码更容易)

更一般地说,除了tensorflow之外,我还推荐其他用于时间序列预测的工具,比如Facebook Prophet或Statsmodels包


我会进一步建议您不要使用Python,而是使用R中提供的一些预测包。

谢谢Alex。事实上,我对你的最后一句话很感兴趣。我能感觉到一些对Python的抵触情绪(只是一种意见),我想听听更多关于为什么你不推荐使用Python的问题,如果可能的话。@zeellos“我能感觉到一些对Python的抵触情绪”——就编程语言而言,实际上,我更喜欢Python而不是R。只是R中可用于时间序列分析的工具数量比Python中的工具要成熟和广泛得多。@zeellos-我在所有时间序列建模中都使用R,一些同行建议我通过Keras/Tensorflow研究RNN。我想知道您在Keras/TF中使用Python的经验与Prophet相比是什么样的?我在网上没有发现两者之间的比较,我想了解更多关于两者比较的信息。