Reusable CNN and RNN model doing time series binary classification
Jupyter Notebook Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.ipynb_checkpoints
__pycache__
ckpt
x_data
.DS_Store
README.md
bitcoin_ticker.csv
bitcoin_ticker.csv.zip
cnn-stock.ipynb
cnn-x_data.png
models.py
run.py
stock-cnn.pdf
utils.py
visualize_weight.py

README.md

CNN / RNN time series classification model


Abstract

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

Dependancies

  1. python Version: 3.5.3
  2. numpy Version: 1.13.0
  3. tensorflow Version: 1.2.1
  4. matplotlib Version: 2.0.2

Dataset

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.

CNN model

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.

x_data of CNN model

x_data

RNN model

Just simple RNN model

input : 30 minite time seies data

predicts : whether data goes up or down after 5 minite

Key Features

1. reusable

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"

2. visualize filters (CNN)

You can visuaize CNN model filters easily by running visualize_weight.py