python - neural networks regression using pybrain -


i need solve regression problem feed forward network , i've been trying use pybrain it. since there no examples of regression on pybrain's reference, tried adapt it's classification example regression instead, no success (the classification example can found here: http://pybrain.org/docs/tutorial/fnn.html). following code:

this first function converts data in numpy array form pybrain superviseddataset. use superviseddataset because according pybrain's reference dataset use when problem regression. parameters array feature vectors (data) , expected output (values):

def convertdataneuralnetwork(data, values):  fulldata = superviseddataset(data.shape[1], 1)  d, v in zip(data, values):      fulldata.addsample(d, v)      return fulldata 

next, function run regression. train_data , train_values train feature vectors , expected output, test_data , test_values test feature vectors , expected output:

regressiontrain = convertdataneuralnetwork(train_data, train_values)  regressiontest = convertdataneuralnetwork(test_data, test_values)  fnn = feedforwardnetwork()  inlayer = linearlayer(regressiontrain.indim) hiddenlayer = linearlayer(5) outlayer = gaussianlayer(regressiontrain.outdim)  fnn.addinputmodule(inlayer) fnn.addmodule(hiddenlayer) fnn.addoutputmodule(outlayer)  in_to_hidden = fullconnection(inlayer, hiddenlayer) hidden_to_out = fullconnection(hiddenlayer, outlayer)  fnn.addconnection(in_to_hidden) fnn.addconnection(hidden_to_out)  fnn.sortmodules()  trainer = backproptrainer(fnn, dataset=regressiontrain, momentum=0.1, verbose=true, weightdecay=0.01)  in range(10):      trainer.trainepochs(5)      res = trainer.testonclassdata(dataset=regressiontest )      print res 

when print res, it's values 0. i've tried use buildnetwork function shortcut build network, didn't work well. i've tried different kinds of layers , different number of nodes in hidden layer, no luck.

does have idea of doing wrong? also, pybrain regression examples help! couldn't find when looked.

thanks in advance

pybrain.tools.neuralnets.nnregression tool

learns numerically predict targets of set of data, optional online progress plots.

so seems suited constructing neural network regression task.


Comments