我试图用给定的数据集来预测GBP / EUR的汇率,该数据集只有两列日期和以前的值。
fxgbp <-exchangeGBP
fxgbp $ GBP/EUR
str(fxgbp)
摘要(fxgbp $ GBP/EUR
)
库(ggplot2) 库(reshape2) 库(gridExtra)
melted_fxgbp <-melt(fxgbp)#melt函数使要堆叠的列数增加了一倍
tail(melted_fxgbp)#tail产生数据集的最后两行
qplot(x = value,data = melted_fxgbp)+ facet_wrap(〜variables,scales ='free')
normalized_fxgbp <-scale(melted_fxgbp $ value)#因为gbp / eur具有钟形分布,我们已使用scale进行了归一化
summary(melted_fxgbp $ value)#如果遇到问题,代码中的标度部分可能会再次困扰您
fxgbp_train <-normalized_fxgbp [1:375,]#75%的样本量将训练25%是测试
fxgbp_test <-normalized_fxgbp [376:500,]
图书馆(神经网络) 图书馆(网格) 图书馆(MASS)
set.seed(12345)
fxgbp_model <-神经网络(melted_fxgbp $ value〜melted_fxgbp $ variable,data = fxgbp_train)
该模型无法正常运行,因为它指出无法识别fxgbp_train。任何帮助将不胜感激