diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-12-08 21:37:41 -0800 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-12-08 21:37:41 -0800 |
| commit | 0e082b3065d8c3bafbd82cbaf24d6efb85825b05 (patch) | |
| tree | 60df92a77a6d298aed851315ffad80d4d1e937ef /ricky/binaryclassifier.py | |
| parent | 518f5b63f5b61308a8d3df64eb9ff715bb3c0e2c (diff) | |
made progress in binaryclassifier rewrite, restructured file tree
Diffstat (limited to 'ricky/binaryclassifier.py')
| -rw-r--r-- | ricky/binaryclassifier.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ricky/binaryclassifier.py b/ricky/binaryclassifier.py new file mode 100644 index 0000000..f6d8ae6 --- /dev/null +++ b/ricky/binaryclassifier.py @@ -0,0 +1,34 @@ +from pybrain.tools.shortcuts import buildNetwork +from pybrain.structure import SoftmaxLayer +from pybrain.datasets import SupervisedDataSet +from pybrain.supervised.trainers import BackpropTrainer + + +class BinaryClassifier(object): + def __init__(self): + self._default_hidden_layers = 3 + pass + + def _train(self, dataset): + """ + pybrain.tools.shortcuts.buildNetwork(*layers, **options) + Build arbitrarily deep networks. + + layers should be a list or tuple of integers, that + indicate how many neurons the layers should have. + bias and outputbias are flags to indicate whether + the network should have the corresponding biases; + both default to True. + """ + net = buildNetwork( + dataset.params_length, + self._default_hidden_layers, + 1 # a binary classifier only requires one output layer + ) + ds = SupervisedDataSet(dataset) + trainer = BackpropTrainer(net, ds) + trainer.trainUntilConvergence() + net.activate(params.as_serialized) + + def classify(self, dataset): + return False |
