我正在尝试使用神经网络包构建神经网络,但遇到了一些麻烦。我的nnet
包裹很成功,但没有运气neuralnet
。我已经阅读了整个文档包并且找不到解决方案,或者我无法发现它。
我正在使用的训练命令是
nn<-neuralnet(V15 ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10 + V11 + V12 + V13 + V14,data=test.matrix,lifesign="full",lifesign.step=100,hidden=8)
和预测
result<- compute(nn,data.matrix)$net.result
训练比 nnet 训练花费的时间要长得多。我尝试使用与nnet
(反向传播而不是弹性反向传播)相同的算法,但什么也没改变,也改变了激活函数(和linear.output=F
)以及几乎所有其他东西,结果没有改善。预测值都是一样的。我不明白为什么 nnet 对我有用,而 nnetneuralnet
却不行。
我真的可以使用一些帮助,我(缺乏)对这两件事(神经网络和 R)的理解可能是原因,但找不到原因。
我的数据集来自UCI。我想使用神经网络进行二元分类。数据样本为:
25,Private,226802,11th,7,Never-married,Machine-op-inspct,Own-child,Black,Male,0,0,40,United-States,<=50K.
38,Private,89814,HS-grad,9,Married-civ-spouse,Farming-fishing,Husband,White,Male,0,0,50,United-States,<=50K.
28,Local-gov,336951,Assoc-acdm,12,Married-civ-spouse,Protective-serv,Husband,White,Male,0,0,40,United-States,>50K.
44,Private,160323,Some-college,10,Married-civ-spouse,Machine-op-inspct,Husband,Black,Male,7688,0,40,United-States,>50K.
18,?,103497,Some-college,10,Never-married,NA,Own-child,White,Female,0,0,30,United-States,<=50K.
34,Private,198693,10th,6,Never-married,Other-service,Not-in-family,White,Male,0,0,30,United-States,<=50K.
29,?,227026,HS-grad,9,Never-married,?,Unmarried,Black,Male,0,0,40,United-States,<=50K.
63,Self-emp-not-inc,104626,Prof-school,15,Married-civ-spouse,Prof-specialty,Husband,White,Male,3103,0,32,United-States,>50K.
24,Private,369667,Some-college,10,Never-married,Other-service,Unmarried,White,Female,0,0,40,United-States,<=50K.
55,Private,104996,7th-8th,4,Married-civ-spouse,Craft-repair,Husband,White,Male,0,0,10,United-States,<=50K.
65,Private,184454,HS-grad,9,Married-civ-spouse,Machine-op-inspct,Husband,White,Male,6418,0,40,United-States,>50K.
36,Federal-gov,212465,Bachelors,13,Married-civ-spouse,Adm-clerical,Husband,White,Male,0,0,40,United-States,<=50K.
26,Private,82091,HS-grad,9,Never-married,Adm-clerical,Not-in-family,White,Female,0,0,39,United-States,<=50K.
转换为矩阵,因子为数值:
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
39 7 77516 10 13 5 1 2 5 2 2174 0 40 39 0
50 6 83311 10 13 3 4 1 5 2 0 0 13 39 0
38 4 215646 12 9 1 6 2 5 2 0 0 40 39 0
53 4 234721 2 7 3 6 1 3 2 0 0 40 39 0
28 4 338409 10 13 3 10 6 3 1 0 0 40 5 0
37 4 284582 13 14 3 4 6 5 1 0 0 40 39 0
49 4 160187 7 5 4 8 2 3 1 0 0 16 23 0
52 6 209642 12 9 3 4 1 5 2 0 0 45 39 1
31 4 45781 13 14 5 10 2 5 1 14084 0 50 39 1
42 4 159449 10 13 3 4 1 5 2 5178 0 40 39 1
37 4 280464 16 10 3 4 1 3 2 0 0 80 39 1
30 7 141297 10 13 3 10 1 2 2 0 0 40 19 1
23 4 122272 10 13 5 1 4 5 1 0 0 30 39 0
预测值总结:
V1
Min. :0.2446871
1st Qu.:0.2446871
Median :0.2446871
Mean :0.2451587
3rd Qu.:0.2446871
Max. :1.0000000
Wilcoxon-Mann-Whitney 检验的值(曲线下面积)表明预测性能几乎与随机相同。
performance(predneural,"auc")@y.values
[1] 0.5013319126