当前位置: 动力学知识库 > 问答 > 编程问答 >

artificial intelligence - How to predict a spike using neural network (preferably using neurolab or pybrain in python)

问题描述:

I want to use neural networks to predict a timeseries B in the next 30 days from now based on a series A (I have the full history of series A), and a list of events E in the next 30 days (E is a list of binary units). Knowing that B is linearly proportional to A and when an event in day i happens (E[i] = 1), it triggers a spike on B (the ratio is unknown). I have training data containing tuples of (A, E, B). I have tested with feed forward network, but it doesn't perform very well (not predicting right spikes). Should I use recurrent networks and how can I do that neurolab or pybrain ? Thanks.

You can have a look at an example here.

Edit: the code is a bit complicated, hence I can't paste here. However the idea is I feed A + E as inputs and predict B, so there are 30 + 30 input units, 30 output units, no hidden layer (I have tested with 1 hidden layer including 30 units and 90 units, but they don't perform better). The timeseries data is shown in the above link. (The red line is B, A is in similar shape without spikes).

A_list, B_list, E_list = input()

X, Y = [A + E for A, E in zip(A_list, E_list)], B_list

indim, outdim = len(X[0]), len(Y[0])

network = nl.net.newp([[-1, 1]]*indim, outdim, transf=nl.trans.LogSig())

errors = network.train(norm_X(X),

norm_Y(Y),

epochs=4000, show=1000,

lr=0.01)

Where norm_X(X) scales X to [-1,1] and norm_Y scales Y to [0, 1].

网友答案:

Try to use neurolab.net.newff, with train_bfgs:

network = nl.net.newff([[-1, 1]]*indim, [10,outdim], transf=nl.trans.LogSig()) 
network.trainf = nl.train.train_bfgs
network.train(...)

Use recurent network you may see that: http://packages.python.org/neurolab/ex_newelm.html

分享给朋友:
您可能感兴趣的文章:
随机阅读: