What I want to do is ask how the pyramids predict new data, for example to predict (0,1,0,1,1,0), and he should deduce what answer he considers.
The question is what code do I need to insert for this to happen.
Additional Information: The weather.csv file that pybrain is studying has 6 attributes, and the answer can be only 1 or 0. There is no other number.
Again, all I want to do is ask pyBrain after he has learned to predict the numbers that I give them. for example, predict (0,1,0,1,1,0) and he should answer. I am very new to python and pybrain. Your advice and help is greatly appreciated. thank
This is my code.
from pybrain.datasets import SupervisedDataSet
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.datasets import ClassificationDataSet
from pybrain.utilities import percentError
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure.modules import SoftmaxLayer
from pylab import ion, ioff, figure, draw, contourf, clf, show, hold, plot
from scipy import diag, arange, meshgrid, where
from numpy.random import multivariate_normal
ds = SupervisedDataSet(6,1)
tf = open('weather.csv','r')
for line in tf.readlines():
try:
data = [float(x) for x in line.strip().split(',') if x != '']
indata = tuple(data[:6])
outdata = tuple(data[6:])
ds.addSample(indata,outdata)
except ValueError,e:
print "error",e,"on line"
n = buildNetwork(ds.indim,8,8,ds.outdim,recurrent=True)
t = BackpropTrainer(n,learningrate=0.001,momentum=0.05,verbose=True)
t.trainOnDataset(ds,3000)
t.testOnData(verbose=True)
Update:
weather.csv 7 ( ). csv. 1970
1 0 1 1 1 1 1
0 0 0 1 1 1 0
1 0 1 1 1 1 1
0 0 0 1 1 1 0
0 0 0 1 1 1 0
0 0 0 1 1 1 0
0 0 0 1 1 1 0
( ) - , .
, 3000 ( ).
Total error: 0.0140074590407
Total error: 0.0139930126505
Total error: 0.0139796724323
Total error: 0.0139656881439
Testing on data:
out: [ 0.732]
correct: [ 1.000]
error: 0.03581333
out: [ 0.101]
correct: [ 0.000]
error: 0.00511758
out: [ 0.732]
correct: [ 1.000]
error: 0.03581333
out: [ 0.101]
correct: [ 0.000]
error: 0.00511758
out: [ 0.101]
correct: [ 0.000]
error: 0.00511758
out: [ 0.101]
correct: [ 0.000]
error: 0.00511758
out: [ 0.101]
correct: [ 0.000]
error: 0.00511758
pybrain , 2014. , . - , 2014.