Code Monkey home page Code Monkey logo

how-to-predict-stock-prices-easily-demo's Introduction

How-to-Predict-Stock-Prices-Easily-Demo

How to Predict Stock Prices Easily - Intro to Deep Learning #7 by Siraj Raval on Youtube

##Overview

This is the code for this video on Youtube by Siraj Raval part of the Udacity Deep Learning nanodegree. We use an LSTM neural network to predict the closing price of the S&P 500 using a dataset of past prices.

##Dependencies

  • keras
  • tensorflow

Install Keras from here and Tensorflow from here.

##Usage

Run this using jupyter notebook. Just type jupyter notebook in the main directory and the code will pop up in a browser window.

#Coding Challenge - Due Date, Thursday, March 2nd 2017 at 12 PM PST

Use the price history AND two other metrics of your choice to predict the price of GOOGL stock with an LSTM network. You can find the CSV here. Metrics could be sentiment analysis from Twitter of what people have said about Google, dividends, etc.

##Credits

Credits go to jaungiers. I've merely created a wrapper to get people started.

how-to-predict-stock-prices-easily-demo's People

Contributors

danilbaibak avatar llsourcell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

how-to-predict-stock-prices-easily-demo's Issues

Running the code in Python 3.6

I changed lstm.py code , so I can test it on Python 3.6:
change xraneg to range.
change range(len(data)/prediction_len): to range(len(data)//prediction_len):
I got this error:
TypeError: %i format: a number is required, not list

any help please

Could I get a link to the csv?

Google blocks me from that link because i might be sending automated requests... While I'm clearly not.
Could you direct me to the dataset?

Cannot get the result as yours ...

Hi,

I run this demo code in my ubuntu 16.04.2 installed with tensorflow 1.0, keras 2.0.2 and python 2.7.12. Everything runs fine without error and warning, all console printout are similar to yours. However, the output prediction diagram is quite different from yours.

All those prediction lines are just pointing upwards of nearly the same slope.

What's wrong with it ? Thanks.

The prediction result looks not so good.

Thanks for your sharing!
However, the prediction result looks not so good as shown in the last figure. how do you think about this prediction result?
image

Besides, could you share your thoughts that why you design 2 LSTM layers with the output length of 50 and 100 for this price prediction problem? What's your detailed consideration behind this design ?

Windows 7 Install & Python 3.5 Upgrade - An Exciting Story [Solved]

Thank you for the example. I get the following error:

Using Theano backend.
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
File "C:\BrainPorn\How-to-Predict-Stock-Prices-Easily-Demo-master\lstm.py", line 17
print 'yo'
^
SyntaxError: Missing parentheses in call to 'print'

I'm more then confused.

I have Anaconda with a TensorFlow Env and a Keras lib.
But I can't start a notebook on the TensorFlow shell, so I start the notebook on the Anaconda shell, where the above output appears in the browser.
Who can provide a descent "how to start the example" (cross-platform or Win7)?

Update Day Two:

The environment of the example is not install able on Windows, so trying other ways.

Install native on Windows: Keras install failed, probably because of Scipy
Install Anaconda way: Keras install failed, Notebook showing up in Browser (incl. failed dependency Keras)
Install Docker way: Jupyter install failed...

Trying the docker way. Would be nice to have a container, so more people could follow.

I got a functional container with TensorFlow + Keras from here:

https://blog.thoughtram.io/machine-learning/2016/09/23/beginning-ml-with-keras-and-tensorflow.html

Now I have a running TensorFlow with Keras but no jupyter notebook option.

Unfortunately 'pip install jupyter' in the environment leads to errors too.

So still no success.

Does someone has a Docker container with TensorFlow + Keras + Jupitor Notebook?

Update: Found an all in one docker image here:

https://github.com/floydhub/dl-docker (Python2 and iTouch Kernel)

docker run -it -p 192.168.99.100:8888:8888 -p 192.168.99.100:6006:6006 -v /sharedfolder:/root/sharedfolder floydhub/dl-docker:cpu jupyter notebook

...does not show the example (empty notebook)...sadly giving up.

Update:

Turns out Docker on Win needs a special syntax....

docker run -it -p 192.168.99.100:8888:8888 -p 192.168.99.100:6006:6006 -v //c/Users//sharedfolder:/root/sharedfolder floydhub/dl-docker:cpu jupyter notebook

...finally does the trick....but after a while in the browser I get this:

The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened.

What a disaster after such a long journey!!!

Which Kernel do we need?

NameError: name 'xrange' is not defined

Testing this on python3 and jupyter notebook, I get:


NameError Traceback (most recent call last)
in ()
1 #Step 4 - Plot the predictions!
----> 2 predictions = lstm.predict_sequences_multiple(model, X_test, 50, 50)
3 lstm.plot_results_multiple(predictions, y_test, 50)

~\git\How-to-Predict-Stock-Prices-Easily-Demo\lstm.py in predict_sequences_multiple(model, data, window_size, prediction_len)
99 #Predict sequence of 50 steps before shifting prediction run forward by 50 steps
100 prediction_seqs = []
--> 101 for i in xrange(len(data)/prediction_len):
102 curr_frame = data[i*prediction_len]
103 predicted = []

NameError: name 'xrange' is not defined

must these code run in jupyter ?

I just copy the code from stockdemo.ipynb into a .py file. Then, put all other 3 files into a folder and run under my ubuntu. Everything runs fine except the output prediction plot looks quite different from yours.

Must it be run under jupyter ?

Bytes-Like Object Required, not 'str'

When calling lstm.load_data('sp500.csv', 50, True) in ipython notebooks I get:


TypeError Traceback (most recent call last)
in ()
1 #Step 1 Load Data
----> 2 X_train, y_train, X_test, y_test = lstm.load_data('sp500.csv', 50, True)

How-to-Predict-Stock-Prices-Easily-Demo/lstm.py in load_data(filename, seq_len, normalise_window)
25 def load_data(filename, seq_len, normalise_window):
26 f = open(filename, 'rb').read()
---> 27 data = f.split('\n')
28
29 sequence_length = seq_len + 1

TypeError: a bytes-like object is required, not 'str'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.