Pybrain cross-validation method

梦想与她 提交于 2019-12-05 01:43:33

问题


I'm trying to use the cross-validator on my data, but I'm getting 0.0 success rate, which doesn't make sense.

My data is comprised of samples with 5 continuous attributes and two possible classes: "y" and "n".

My code:

net = pybrain.tools.shortcuts.buildNetwork(5, 8, 1)
trainer = BackpropTrainer(net, ds)
evaluation = ModuleValidator.classificationPerformance(trainer.module, ds)
validator = CrossValidator(trainer=trainer, dataset=trainer.ds, n_folds=5, valfunc=evaluation)
print(validator.validate())

When I'm doing a regular training like so

print(trainer.train())

I'm getting a reasonable error rate, so I'm guessing this means the dataset and network are okay, and the problem is in the cross validator.

Any ideas?

Update:

I looked in the cross-validation code and noticed that my network outputs continuous values and not 0/1 as required. I'm guessing these are the probabilities for each class. When the model is used inside the cross-validation methods it does not account for that, and this means all answers are regarded as flase, si I'm getting 0 correct answers. How can I add a layer that looks at the continuous values and returns 0 or 1 according to whichever is bigger? The documentation is unclear.


回答1:


I am working on neural networks too, i recommend your to check the FANN library with python bindings, its better and easier to use than pybrain



来源:https://stackoverflow.com/questions/5757407/pybrain-cross-validation-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!