作者:徐瑞龙 整理分享量化投资与固定收益相关的文章
博客专栏:
https://www.cnblogs.com/xuruilong100
5.3 预测未来 10 年的数据
我们可以通过调整预测函数来使用完整的数据集预测未来 10 年的数据。新函数 predict_keras_lstm_future()
用来预测未来 120 步(或 10 年)的数据。
predict_keras_lstm_future <- function(data,
epochs = 300,
...) { lstm_prediction <- function(data, epochs,
...) { # 5.1.2 Data Setup (MODIFIED) df <- data # 5.1.3 Preprocessing rec_obj <- recipe(value ~ ., df) %>%
step_sqrt(value) %>%
step_center(value) %>%
step_scale(value) %>%
prep() df_processed_tbl <- bake(rec_obj, df) center_history <- rec_obj$steps[[2]]$means["value"] scale_history <- rec_obj$steps[[3]]$sds["value"]