在eval(expr,envir,enclos)中:Fold01的模型拟合失败:

时间:2016-04-15 17:43:41

标签: r r-caret nnet

我正在尝试将package caret和nnet一起使用,但是得到了以下错误。我使用警告()来查看它是什么,但在互联网上找不到任何东西。请告诉我。感谢。

> str(Std_data)
'data.frame':   1628 obs. of  18 variables:
 $ Seed   : num  1 1 1 1 1 1 1 1 1 1 ...
 $ Pyth   : num  0.882 0.904 0.295 0.882 0.671 ...
 $ EFG    : num  0.709 -0.212 -0.992 0.709 -0.291 ...
 $ PPP    : num  0.506 0.2393 0.3952 0.506 0.0309 ...
 ...

 $ PD     : num  2.17 2.03 1.47 1.4 1.19 ...
 $ OppSeed: num  16 16 16 9 16 5 3 3 12 3 ...
 $ Win    : Factor w/ 2 levels "0","1": 2 2 2 2 2 2 1 1 2 1 ... 

> model <- train(Win ~ . - PD, data=Std_data, method='nnet', linout=TRUE, trace = FALSE,
+                tuneGrid=expand.grid(.size=c(2:8),.decay=c(0,0.0001, 0.001,0.01,0.1)), trControl = trainControl(method = "cv"))

Something is wrong; all the Accuracy metric values are missing:
...
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)

> warnings()
Warning messages:
1: In eval(expr, envir, enclos) :
model fit failed for Fold01: size=2, decay=0e+00 Error in nnet.default(x, y, w, entropy = TRUE, ...) : 
entropy fit only for logistic units

1 个答案:

答案 0 :(得分:1)

如果将linout设置为False,您的代码可能会有效。 Linout设置为线性输出单元的True开关。您的Win变量是二进制变量而不是连续变量。至少它只会消除物流单位信息的熵拟合。