kulbear / stock-prediction Goto Github PK
View Code? Open in Web Editor NEWStock price prediction with recurrent neural network. The data is from the Chinese stock.
License: MIT License
Stock price prediction with recurrent neural network. The data is from the Chinese stock.
License: MIT License
Hi
In your notebook, you use values that are initially in the ranges of 20 and then scale them down to between 1 and 0.
If I wanted to plug in values that were already lower than 1 and above 0, (like 0.00000690 for example), would they still need scaling?
If so what do you recommend?
ValueError Traceback (most recent call last)
in
----> 1 get_all_history('000002', start='1995-01-01')
2
3 get_3_years_history('000002')
in get_all_history(stock_index, start, autype)
10 """
11 df = ts.get_h_data(stock_index, start = start, autype = autype)
---> 12 df = wash(df)
13 print('\nSaving DataFrame: \n', df.head(5))
14 df.to_csv('{}-from-{}.csv'.format(stock_index, start), index=False)
in wash(df, target)
11 df = df.reset_index(drop=True)
12 col_list = df.columns.tolist()
---> 13 col_list.remove(target)
14 col_list.append(target)
15 return df[col_list]
ValueError: list.remove(x): x not in list
Hi,
The prediction was only with the actual data and there is no data predicted for next few data or days.
What you done is "If the data was 1000 then the predicted also 1000".
But I'm asking is predicted data for next n number of days.
For example:
if we have 1000 data and we need to predict for next 10 days then it should be predicted for 1010 data.
In the readme you simply list dependencies and then say:
I personally recommend you to use Anaconda to build your virtual environment.
Can you provide an example config/install instructions for that? Because setting up all those dependencies looks rather complicated, and if you already have an anaconda package definition/config file/etc from your development it'd be great if you could add those to the repo
Hi,
I am working on a stock prediction assignment and was trying to get some help from your script. But I am facing some issues in updated keras / tensorflow version. Seems like input_dim, output_dim functions has deprecated. Could you help me to update that code for updated version.
Also, as I can see in your code, you are sending 3 dimensional input data like (None, 20, 6) for model training. When I use same approach, I am getting 0.000 accuracy in every epoch. I do not understand what I am doing wrong.
Please have a look at my model code and correct me if anything wrong:
model = Sequential()
model.add(LSTM(512, input_shape=(X_train.shape[1], X_train.shape[2]), return_sequences=True))
model.add(Dropout(0.4))
model.add(LSTM(256, return_sequences=True))
model.add(Dropout(0.3))
model.add(LSTM(128, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(64, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(32))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
model.summary()
history = model.fit(X_train, y_train, epochs=5, batch_size=64, validation_split=0.10)
Train on 3458 samples, validate on 385 samples
Epoch 1/5
3458/3458 [==============================]3458/3458 [==============================] - 93s 27ms/step - loss: 0.0753 - acc: 0.0000e+00 - val_loss: 0.4183 - val_acc: 0.0000e+00
Epoch 2/5
3458/3458 [==============================]3458/3458 [==============================] - 78s 22ms/step - loss: 0.0145 - acc: 0.0000e+00 - val_loss: 0.1113 - val_acc: 0.0000e+00
Epoch 3/5
3458/3458 [==============================]3458/3458 [==============================] - 80s 23ms/step - loss: 0.0114 - acc: 0.0000e+00 - val_loss: 0.1157 - val_acc: 0.0000e+00
Epoch 4/5
3458/3458 [==============================]3458/3458 [==============================] - 97s 28ms/step - loss: 0.0097 - acc: 0.0000e+00 - val_loss: 0.0560 - val_acc: 0.0000e+00
Epoch 5/5
3458/3458 [==============================]3458/3458 [==============================] - 79s 23ms/step - loss: 0.0097 - acc: 0.0000e+00 - val_loss: 0.0951 - val_acc: 0.0000e+00
Regards,
Ankit Aggarwal
I am getting the following error when running fetch_data.py
[Getting data:]HTTP Error 456:
HTTP Error 456:
HTTP Error 456:
Traceback (most recent call last):
File "fetch_data.py", line 52, in
get_all_history('000002', start='1995-01-01')
File "fetch_data.py", line 47, in get_all_history
df = ts.get_h_data(stock_index, start=start, autype=autype)
File "/usr/local/lib/python3.5/dist-packages/tushare/stock/trading.py", line 432, in get_h_data
retry_count, pause)
File "/usr/local/lib/python3.5/dist-packages/tushare/stock/trading.py", line 572, in _parse_fq_data
raise IOError(ct.NETWORK_URL_ERROR_MSG)
OSError: 获取失败,请检查网络.
Any advice?
python fetch_data.py
/home/smilewater/anaconda3/envs/tensorflow-gpu/lib/python3.6/importlib/_bootstrap.py:205: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
return f(*args, **kwds)
[Getting data:]###################################################HTTP Error 456:
#HTTP Error 456:
HTTP Error 456:
HTTP Error 456:
Traceback (most recent call last):
File "fetch_data.py", line 52, in
get_all_history('000002', start='1995-01-01')
File "fetch_data.py", line 47, in get_all_history
df = ts.get_h_data(stock_index, start=start, autype=autype)
File "/home/smilewater/anaconda3/envs/tensorflow-gpu/lib/python3.6/site-packages/tushare/stock/trading.py", line 440, in get_h_data
retry_count, pause)
File "/home/smilewater/anaconda3/envs/tensorflow-gpu/lib/python3.6/site-packages/tushare/stock/trading.py", line 572, in _parse_fq_data
raise IOError(ct.NETWORK_URL_ERROR_MSG)
OSError: 获取失败,请检查网络.
Hi
Can you please help with scale back those prediction value function?
I tried this but values are bit different
Note: made preprocessor as global variable
def normalize_data(x, y):
global preprocessor
linear_x = x.reshape((x.shape[0], x.shape[1] * x.shape[2]))
#print("x.shape", x.shape)
#print("linear_x.shape", linear_x.shape)
xy = np.c_[ linear_x, y, y, y, y, y, y]
#print("xy.shape", xy.shape)
xy_scaled = preprocessor.inverse_transform(xy, copy=True)
#print("xy_scaled.shape", xy_scaled.shape)
#print(xy_scaled[:, -1].tolist())
return xy_scaled[:, -1].tolist()
Will be waiting for your reply
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.