Reusable CNN and RNN model doing time series binary classification
Watch run.py
,utils.py
, models.py
for detail code
Run run.py
to use model
- to run cnn :
python3 run.py --model="cnn" --gen_png=True
- to run rnn :
python3 run.py --model="rnn"
- to use saved model :
python3 run.py --model="cnn" --ckptfile="./ckpt/cnn2.py"
so on ...
Can compare the accuracy of CNN and RNN doing time series binary classification
- python Version: 3.5.3
- numpy Version: 1.13.0
- tensorflow Version: 1.2.1
- matplotlib Version: 2.0.2
The dataset I used.
Bitcoin Ticker Data
- 1 minite
- korbit
- btc_krw
- last, volume
- from 2016.06.28 to 2017.07.14
You can change dataset and train and test easily.
Inspired by this paper
Change 30 minite time series data into 2-d graph and save it into .png file.
Convert .png file into numpy array, for example [50,50,4] (imgsize = 50*50, channel = 4).
Put that numpy array into CNN model and train .
CNN model predicts whether data goes up or down after 5 minite .
I applied this model into Bitcoin Ticker Data.
Just simple RNN model
input : 30 minite time seies data
predicts : whether data goes up or down after 5 minite
You can save trained variables and reuse it easily.
Just use option flag.
If you reuse trained variables, it automatically calculate accuracy on validation set.
$ python3 run.py --name="cnn1reuse" --model="cnn" --ckptfile="./ckpt/cnn1.ckpt"
You can visuaize CNN model filters easily by running visualize_weight.py