我正在尝试做一次交叉验证。我遵循所有的指示,但不明白我在做什么,所以我收到一个错误。也许我的数据集太小了,我可以在这里包含它:
clay oc ph_h2o avg_N2O sum_tmax
31.54643 2.654043 6.725000 5.8397204 1644.0
31.54643 2.654043 6.725000 8.9456498 1626.0
31.54643 2.654043 6.725000 36.6636187 1846.5
31.54643 2.654043 6.725000 27.9717408 1651.5
31.54643 2.654043 6.725000 13.7662532 1433.5
31.54643 2.654043 6.725000 28.4065759 1597.5
31.54643 2.654043 6.725000 9.7437375 1585.5
20.15455 1.371111 6.090909 2.8604854 1644.0
20.15455 1.371111 6.090909 11.4821949 1626.0
20.15455 1.371111 6.090909 20.1477475 1846.5
20.15455 1.371111 6.090909 3.9438700 1651.5
20.15455 1.371111 6.090909 4.8634605 1597.5
30.14316 3.224697 7.221811 10.2540652 802.5
30.14316 3.224697 7.221811 17.7039395 841.0
30.14316 3.224697 7.221811 19.3734159 983.5
30.14316 3.224697 7.221811 17.2422255 781.0
30.14316 3.224697 7.221811 17.9839534 412.5
18.06667 1.852857 5.911111 4.1653732 1012.5
18.06667 1.852857 5.911111 4.5732676 1201.0
18.06667 1.852857 5.911111 8.1417138 1003.5
8.11250 0.886250 6.650000 0.4631667 818.0
8.11250 0.886250 6.650000 2.1779861 397.5
8.11250 0.886250 6.650000 1.6355573 641.5
8.11250 0.886250 6.650000 2.8754931 259.5
22.47405 1.816556 5.684229 4.5025055 1324.0
22.47405 1.816556 5.684229 3.6881473 1634.5
22.47405 1.816556 5.684229 4.7470418 1370.0
22.47405 1.816556 5.684229 8.2378739 1559.5
我尝试的代码是:
train_control<-trainControl(method="LOOCV")
control<-train(avg_N2O ~., data=slim, trControl=train_control, method="nb")
所有类都应该是数字,它们是。
我使用线性回归来查看这些变量与avg_N2O的关系,但有人建议我使用LOOCV。我想最终有一个预测模型,这是我的训练集。