R中预测的预处理尺度-预测的尺度不相同
我正在使用caret软件包中的训练函数在R中训练神经网络。我正在使用以下示例代码: 网络训练的输出告诉我,它已被重新缩放到[0,1],但当我使用预测函数时,我的预测没有缩放到[0,1]。首先,我如何知道数据是否已正确规范化?第二,我如何得到标准化的预测 这是我的密码:R中预测的预处理尺度-预测的尺度不相同,r,machine-learning,neural-network,r-caret,R,Machine Learning,Neural Network,R Caret,我正在使用caret软件包中的训练函数在R中训练神经网络。我正在使用以下示例代码: 网络训练的输出告诉我,它已被重新缩放到[0,1],但当我使用预测函数时,我的预测没有缩放到[0,1]。首先,我如何知道数据是否已正确规范化?第二,我如何得到标准化的预测 这是我的密码: timeSlices <- createTimeSlices(1:nrow(mytsframe3), initialWindow = 36, horizon = 12,
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" ...
网络训练的输出告诉我,它已被重新缩放到[0,1],但当我使用预测函数时,我的预测没有缩放到[0,1]
结果是数字的,您正在拟合回归模型(而不是分类)。preProc
选项将预测值重新缩放为[0,1],并且不会将结果或预测值重新缩放为该范围
网络训练的输出告诉我,它已被重新缩放到[0,1],但当我使用预测函数时,我的预测没有缩放到[0,1]
结果是数字的,您正在拟合回归模型(而不是分类)。
preProc
选项将预测值重新缩放为[0,1],并且不会将结果或预测值重新缩放为该范围 也许predict
默认为您提供对数赔率,您需要将其转换为0-1?您是否尝试将type=“response”
包含在对predict
的调用中?@ulfeld包含type=“response”
会产生以下形式的错误:predict.train中的错误(nn,mytsframe3[testSlices[[1]],type=“response”):类型必须是“raw”或“prob”
那么,您是否尝试过type=“prob”
?@ulfelder,使用type=“prob”
生成包含0列和12行的数据框,其中行仅为时间片的行号扫描您发布的数据,以允许我们复制您的结果和测试修复?也许预测
默认为您提供日志赔率,您需要将其转换为0-1?您是否尝试将type=“response”
包含在对predict
的调用中?@ulfeld包含type=“response”
会产生以下形式的错误:predict.train中的错误(nn,mytsframe3[testSlices[[1]],type=“response”):类型必须是“raw”或“prob”
那么,您是否尝试过type=“prob”
?@ulfeld,使用type=“prob”
生成包含0列和12行的数据帧,其中行仅为时间片的行号扫描您发布的数据,以允许我们复制您的结果和测试修复?
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")