[英]How to use NeuralNet to predict future exchange rate
I have the following data set which extends to 500 values and I would like to create a neural network to predict the future prices.我有以下数据集,它扩展到 500 个值,我想创建一个神经网络来预测未来的价格。 I am using the first 400 for training data and the final 100 to test against.我使用前 400 个作为训练数据,最后 100 个用于测试。
https://imgur.com/a/BMOLFOU https://imgur.com/a/BMOLFOU
The normalization function results in num NaN so I have used scaling instead.归一化 function 导致 num NaN 所以我改用缩放。
I am stuck on the EX_NN <- neuralnet() function as im not sure what function to enter, usually I get an error for object not found.我被困在 EX_NN <- neuralnet() function 上,因为我不确定要输入什么 function,通常我会收到 object 未找到的错误。 What I would like to do is read in the first 400 values and use this to predict and then compare against the next 100 exchange rate values.我想做的是读取前 400 个值并使用它来预测,然后与接下来的 100 个汇率值进行比较。
I have tried converting the data to numeric values.我尝试将数据转换为数值。 Also I have tried with a timeseries.我也尝试过时间序列。
Ex_Train <- ExchangeUSD[1:400,]
Ex_Test <- ExchangeUSD[401:500,]
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
Ex_norm2<-scale(ExchangeUSD$`USD/EUR`)
ExchangeUSD$Wdy <- recode(ExchangeUSD$Wdy,
"Mon"="0",
"Tues"="1",
"Wed"="2",
"Thurs"="3",
"Fri"="4",
"Sat"="5",
"Sun"="6")
EX.timeseries <- ts(ExchangeUSD$`USD/EUR`,start = c(2011,13,10),frequency = 500)
EX_NN <- neuralnet(FORMULA HERE, data = EX_train)
For time series neural network you can use forecast
r package like对于时间序列神经网络,您可以使用forecast
r package 之类的
EX.timeseries <- ts(ExchangeUSD$USD/EUR, start = c(2011, 13, 10), frequency = 365.25) #As your data is daily frequency should be 365.25
fit <- nnetar(EX.timeseries)
fcast <- forecast(fit)
plot(fcast)
plot(forecast(fit, h=15)) #To predict 15 times ahead
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.