使用神经网络预测新数据的类 [英] predicting class for new data using neuralnet

查看:163
本文介绍了使用神经网络预测新数据的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用使用R中的Neuronet软件包训练的神经网络来预测测试数据集的类(0或1).

I'm trying to predict the class (0 or 1) for a test dataset using a neural network trained using the neuralnet package in R.

我的数据如下:

火车:

x1          x2          x3          x4          y
0.557       0.6217009   0.4839      0.5606936   0
0.6549      0.6826347   0.4424      0.4117647   1
0.529       0.5744681   0.5017      0.4148148   1
0.6016771   0.5737052   0.3526971   0.3369565   1
0.6353945   0.6445013   0.5404255   0.464       1
0.5735294   0.6440678   0.4385965   0.5698925   1
0.5252      0.5900621   0.4412      0.448       0
0.7258687   0.7022059   0.5347222   0.4498645   1

更多

测试集看起来与训练数据完全相同,只是值不同(如果需要,我会发布一些样本).

The test set looks the exact same as the training data, just with different values (if need be I will post some samples).

我使用的代码如下:

> library(neuralnet)
> nn <- neuralnet(y ~ x1+x2+x3+x4, data=train, hidden=2, err.fct="ce", linear.output=FALSE)
> plot(nn)
> compute(nn, test)

网络训练成功了,我可以成功绘制网络图,但是计算不起作用.当我运行计算时,它会给我以下错误:

The network trains and I can successfully plot the network, but compute doesn't work. When I run compute it gives me the following error:

Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments

因此,基本上,我正在尝试训练神经网络以成功分类新的测试数据.

So basically I'm trying to train a neural network to successfully classify the new test data.

感谢您的帮助.

测试对象的采样是:

x1          x2  x3          x4          y
0.5822  0.6591  0.6445013   0.464       1
0.4082  0.5388  0.5384616   0.4615385   0
0.4481  0.5438  0.6072289   0.5400844   1
0.4416  0.5034  0.5576923   0.3757576   1
0.5038  0.6878  0.7380952   0.5784314   1
0.4678  0.5219  0.5609756   0.3636364   1
0.5089  0.5775  0.6183844   0.5462555   1
0.4844  0.7117  0.6875      0.4823529   1
0.4098  0.711   0.6801471   0.4722222   1

我也尝试过在y列中不包含任何值的情况.

I've also tried it with the y column empty of any values.

推荐答案

在缺乏对测试"对象的良好描述的情况下很难说,但是您能否看得出这是否会带来更好的结果:

Hard to say in the absence of a good description of the 'test'-object, but can you see if this gives better results:

compute(nn, test[, 1:4])

这篇关于使用神经网络预测新数据的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆