I am trying to predict the selling price of a given set of products. I am using RecurrentNetwork and BackpropTrainer in pybrain. Here is my code
def nnet(train, target, valid): ds = SupervisedDataSet(52-len(NU)+5, 1) for i in range(len(train)): ds.appendLinked(train[i], target[i]) n = RecurrentNetwork() n.addInputModule(LinearLayer(52-len(NU)+5, name='in')) n.addModule(SigmoidLayer(3, name='hidden')) n.addOutputModule(LinearLayer(1, name='out')) n.addConnection(FullConnection(n['in'], n['hidden'], name='c1')) n.addConnection(FullConnection(n['hidden'], n['out'], name='c2')) n.addRecurrentConnection(FullConnection(n['hidden'], n['hidden'], name='c3')) n.sortModules() t = BackpropTrainer(n,learningrate=0.001,verbose=True) t.trainOnDataset(ds, 20) prediction = np.zeros((11573, 1), dtype = int) for i in range(11573): prediction[i] = n.activate(valid[i]) return prediction
Here, the train and the target, which are numpy arrays, are used to train the model, and 52-len (NU) +5 is the number of attributes (attributes). For each item in action, we must predict the selling price. The problem is that for every item in action I get the same selling price, except for the first one. What have I done wrong? Thanks in advance.
The dimensions of the array are as follows:
train - 401125, 52-len (NU) +5
target - 401125, 1
valid - 11573, 52-len (NU) +5
source share