设为首页 加入收藏

TOP

时间序列深度学习:状态 LSTM 模型预测太阳黑子(十)
2019-09-03 02:41:30 】 浏览:703
Tags:时间序列 深度 学习 状态 LSTM 模型 预测 太阳黑子
size = batch_size) %>% .[,1] # Make future index using tk_make_future_timeseries() idx <- data %>% tk_index() %>% tk_make_future_timeseries(n_future = lag_setting) # Retransform values pred_tbl <- tibble( index = idx, value = (pred_out * scale_history + center_history)^2) # Combine actual data with predictions tbl_1 <- df %>% add_column(key = "actual") tbl_3 <- pred_tbl %>% add_column(key = "predict") # Create time_bind_rows() to solve dplyr issue time_bind_rows <- function(data_1, data_2, index) { index_expr <- enquo(index) bind_rows(data_1, data_2) %>% as_tbl_time(index = !! index_expr) } ret <- list(tbl_1, tbl_3) %>% reduce(time_bind_rows, index = index) %>% arrange(key, index) %>% mutate(key = as_factor(key)) return(ret) } safe_lstm <- possibly(lstm_prediction, otherwise = NA) safe_lstm(data, epochs, ...) }

下一步,在 sun_spots 数据集上运行 predict_keras_lstm_future() 函数。

future_sun_spots_tbl <- predict_keras_lstm_future(sun_spots, epochs = 300)

最后,我们使用 plot_prediction() 可视化预测结果,需要设置 id = NULL。我们使用 filter_time() 函数将数据集缩放到 1900 年之后。

future_sun_spots_tbl %>%
    filter_time("1900" ~ "end") %>%
    plot_prediction(
        id = NULL, alpha = 0.4, size = 1.5) +
    theme(legend.position = "bottom") +
    ggtitle(
        "Sunspots: Ten Year Forecast",
        subtitle = "Forecast Horizon: 2013 - 2023")

结论

本文演示了使用 keras 包构建的状态 LSTM 模型的强大功能。令人惊讶的是,提供的唯一特征是滞后 120 阶的历史数据,深度学习方法依然识别出了数据中的趋势。回测模型的 RMSE 均值等于 34,RMSE 标准差等于 13。虽然本文未显示,但我们对比测试1了 ARIMA 模型和 prophet 模型(Facebook 开发的时间序列预测模型),LSTM 模型的表现优越:平均误差减少了 30% 以上,标准差减少了 40%。这显示了机器学习工具-应用适合性的好处。

除了使用的深度学习方法之外,文章还揭示了使用 ACF 图确定 LSTM 模型对于给定时间序列是否适用的方法。我们还揭示了时间序列模型的准确性应如何通过回测来进行基准测试,这种策略保持了时间序列的连续性,可用于时间序列数据的交叉验证。


  1. 测试结果:https://github.com/business-science/presentations/blob/master/2018_04_19_SP_Global_Time_Series_Deep_Learning/SP_Global_Presentation_final.pdf?

首页 上一页 7 8 9 10 下一页 尾页 10/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇【翻译】R 中的设计模式 下一篇基于R语言的结构方程:lavaan简明..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目