我正在使用插入符号包中的训练函数在R中训练神经网络。我在这里使用了一些示例代码:Time-series - data spliting and model evaluation。
网络训练的输出告诉我它已经被重新缩放到0,1,但是当我使用预测函数时,我的预测没有缩放到0,1。首先,我如何知道数据是否被正确地标准化?第二,如何获得归一化预测?
下面是我的代码:
timeSlices <- createTimeSlices(1:nrow(mytsframe3), initialWindow = 36,
horizon = 12, fixedWindow = TRUE)
nn <- train(diffREALBRENTSPOT ~ diffF1REALlag + diffF2REALlag, data = mytsframe3[trainSlices[[1]],], method = "mlp"
, size = 1, preProc = c("range"))
> nn
Multi-Layer Perceptron
36 samples
2 predictor
Pre-processing: re-scaling to [0, 1] (2)
Resampling: Bootstrapped (25 reps)
Summary of sample sizes: 36, 36, 36, 36, 36, 36, ...
Resampling results across tuning parameters:
size RMSE Rsquared
1 0.7879697 0.2098693
3 0.7485212 0.2249331
5 0.7571630 0.2246444
RMSE was used to select the optimal model using the smallest value.
The final value used for the model was size = 3.
pred <- predict(nn, mytsframe3[testSlices[[1]],])
str(pred)
Named num [1:12] 0.0734 -0.0214 0.3264 0.0362 -0.1569 ...
- attr(*, "names")= chr [1:12] "37" "38" "39" "40" ...以下是我用于测试的数据的dput:
structure(list(diffREALBRENTSPOT = c(-0.523999999999999, -0.693,
0.386999999999999, 0.453000000000001, -0.842000000000001, 0.369999999999999
), diffF1REALlag = c(0.48597655, -1.61485375, 0.60622805, -0.469351210000001,
0.292303670000001, -0.44088176), diffF2REALlag = c(1.00948236,
0.48597655, -1.61485375, 0.60622805, -0.469351210000001, 0.292303670000001
)), .Names = c("diffREALBRENTSPOT", "diffF1REALlag", "diffF2REALlag"
), row.names = c(NA, 6L), class = "data.frame")发布于 2016-11-05 01:32:35
网络训练的输出告诉我,它已经被重新缩放到0,1,但是当我使用预测函数时,我的预测没有缩放到0,1。
结果是数值的,并且您正在拟合回归模型(而不是分类)。preProc选项将预测值重新调整为0,1,并且不会将结果或预测重新调整为在此范围内。
https://stackoverflow.com/questions/40387190
复制相似问题