我正在尝试使用神经网络解决这个Kaggle问题.我正在使用Pybrain Python Library.
这是一个经典的监督学习问题.在下面的代码中:'data'变量是numpy数组(892*8).7个字段是我的功能,1个字段是我的输出值,可以是"0"或"1".
from pybrain.datasets import ClassificationDataSet
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.tools.shortcuts import buildNetwork
dataset = ClassificationDataSet(7,1)
for i in data:
dataset.appendLinked(i[1:],i[0])
net = buildNetwork(7,9,7,1, bias = True,hiddenclass = SigmoidLayer, outclass = TanhLayer)
trainer = BackpropTrainer(net, learningrate = 0.04, momentum = 0.96, weightdecay = 0.02, verbose = True)
trainer.trainOnDataset(dataset, 8000)
trainer.testOnData(verbose = True)
Run Code Online (Sandbox Code Playgroud)
在训练我的神经网络之后,当我在训练数据上测试它时,它总是为所有输入提供单个输出.喜欢:
Testing on data:
out: [ 0.075]
correct: [ 1.000]
error: 0.42767858
out: [ 0.075]
correct: [ 0.000]
error: 0.00283875
out: [ 0.075] …Run Code Online (Sandbox Code Playgroud) artificial-intelligence machine-learning data-mining neural-network pybrain