-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLSTM_temp.Rmd
More file actions
88 lines (72 loc) · 1.77 KB
/
LSTM_temp.Rmd
File metadata and controls
88 lines (72 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: "MCM_2022"
author: "MCM2022"
date: "2/17/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(dplyr)
library(ggplot2)
library(ggthemes)
library(lubridate)
theme_set(theme_bw())
set.seed(123)
```
```{r}
# Set colors
DB <- rgb(29/255, 59/255, 83/255)
B <- rgb(69/255, 147/255, 182/255)
O <- rgb(225/255, 116/255, 56/255)
```
```{r}
# Load the data & clean the data
bitcoin_data <- read.csv("data/BCHAIN-MKPRU.csv") %>%
mutate(Date = as.Date(Date, "%m/%d/%y")) %>%
na.omit()
gold_data <- read.csv("data/LBMA-GOLD.csv") %>%
mutate(Date = as.Date(Date, "%m/%d/%y")) %>%
na.omit()
bitcoinLSTM <- read.csv("DataPrediction/Output/LSTM/bitcoin_LSTM.csv")
bitcoinARIMA <- readRDS("DataPrediction/Output/ARIMA/bitcoin_ARIMA.RData")
bitcoinLSTM <- bitcoinLSTM %>%
mutate(Type = "predict-LSTM",
Value = value) %>%
select(Date, Value, Type)
bitcoinARIMA <- bitcoin_data %>%
filter(Date > "2020-09-09") %>%
mutate(Value = bitcoinARIMA,
Type = "predict-ARIMA")
bitcoin_final <- bitcoin_data %>%
mutate(Type = "original-raw") %>%
rbind(bitcoinLSTM) %>%
rbind(bitcoinARIMA)
```
```{r}
bitcoin_final %>%
ggplot(aes(x = Date,
y = Value,
color = Type)) +
geom_line() +
scale_color_manual(values = c(O, B, DB))
bitcoin_final %>%
filter(Date >= "2020-09-09") %>%
ggplot(aes(x = Date,
y = Value,
color = Type)) +
geom_line() +
scale_color_manual(values = c(O, B, DB))
```
```{r}
MSE_ARIMA <- bitcoin_data %>%
filter(Date >= "2020-09-10") %>%
mutate(Raw = Value) %>%
select(-Date, -Value) %>%
cbind(bitcoinARIMA) %>%
mutate(dif = (Raw -Value)^2) %>%
summarise(MSE = sum(dif) / n()) %>%
pull()
MSE_ARIMA
```