-
-
Save riqbal-k/68c12d8f405362c130cf89dcf1872932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the mean and standard deviation of the original dataset | |
mean_return <- mean(return_log) | |
sd_return <- sd(return_log) | |
# Rescale the predicted and original values | |
y_train_pred_rescaled <- y_train_pred_returns * sd_return + mean_return | |
y_test_pred_rescaled <- y_test_pred_returns * sd_return + mean_return | |
y_train_rescaled<-y_train * sd_return + mean_return | |
y_test_rescaled<-y_test * sd_return + mean_return | |
# Shift the predicted values to start from where the training data predictions end | |
shift <- length(y_train_pred_rescaled) | |
y_test_pred_shifted <- c(rep(NA, shift), y_test_pred_rescaled[,1]) | |
# Plot the training and predicted values | |
options(repr.plot.width=12, repr.plot.height=8) | |
plot(return_log, type = "l", col = "green",main="LSTM-APPLE-RETURNS PREDICTION", xlab = "Day", ylab = "Returns",lwd=3) | |
lines(y_train_pred_rescaled, col = "blue",lwd=3) | |
lines(y_test_pred_shifted, col = "red",lwd=3) | |
legend(x = "topleft", legend = c("Original", "Train Predictions","Test-Prediction"), col = c("green","blue" ,"red"), lwd = 2) | |
grid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment