问题描述
我正在使用 nnet 包构建一个神经网络来对二元结果变量进行分类。有20个连续预测变量,数据已经标准化。
为了防止过拟合,我在训练数据中添加了高斯噪声。
以下模型使用一个隐藏层和 6 个神经元,衰减 = .1,同样是为了防止过拟合。
我相信以下输出显示了模型训练中的二元交叉熵值。为什么这些值这么大,即使模型已经成功转换?
noise <- add.Gaussian.noise(as.matrix(train[-1]),mean = 0,stddev = 1,symm = FALSE)
label <- train[1]
noise_train <- cbind(label,as.data.frame(noise))
network1 <- nnet(cd ~ .,data = noise_train,decay = .1,entropy = TRUE,size = 6,maxit = 500)
initial value 1941.747555
iter 10 value 1671.661065
iter 20 value 1618.610748
iter 30 value 1587.053793
iter 40 value 1567.133276
iter 50 value 1552.854282
iter 60 value 1545.600975
iter 70 value 1538.712525
iter 80 value 1534.572274
iter 90 value 1533.595648
iter 100 value 1533.045905
iter 110 value 1532.807396
iter 120 value 1532.614578
iter 130 value 1532.463034
iter 140 value 1532.414884
iter 150 value 1532.314791
iter 160 value 1532.214113
iter 170 value 1532.170627
iter 180 value 1532.156034
final value 1532.155682
converged
但是,在根据训练和测试数据评估模型时,准确性似乎不错。 例如,测试数据的准确率为 0.6727。
test_prob <- data.frame(actual = test[1],prediction = predict(network1,test[-1]))
test_class <- data.frame(sapply(test_prob,round,digits = 0))
test_matrix <- table(test_class$actual,test_class$prediction)
confusionMatrix(test_matrix)
Accuracy : 0.6727
95% CI : (0.6478,0.6968)
No information Rate : 0.5891
P-Value [Acc > NIR] : 3.554e-11
Kappa : 0.3393
Mcnemar's Test P-Value : 2.918e-05
Sensitivity : 0.6682
Specificity : 0.6790
Pos Pred Value : 0.7490
Neg Pred Value : 0.5881
Prevalence : 0.5891
Detection Rate : 0.3936
Detection Prevalence : 0.5256
Balanced Accuracy : 0.6736
'Positive' Class : 0
以下代码在训练数据上显示了类似的准确性,以证明没有发生过拟合。
train_prob <- data.frame(actual = train[1],prediction = network1$fitted.values)
train_class <- data.frame(sapply(train_prob,digits = 0))
train_matrix <- table(train_class$actual,train_class$prediction)
confusionMatrix(train_matrix)
Accuracy : 0.7486
95% CI : (0.7325,0.7642)
No information Rate : 0.5369
P-Value [Acc > NIR] : < 2e-16
Kappa : 0.4956
Mcnemar's Test P-Value : 0.07744
Sensitivity : 0.7503
Specificity : 0.7465
Pos Pred Value : 0.7744
Neg Pred Value : 0.7206
Prevalence : 0.5369
Detection Rate : 0.4029
Detection Prevalence : 0.5202
Balanced Accuracy : 0.7484
'Positive' Class : 0
为什么这些二元交叉熵率如此之高?
非常感谢您的帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)