{"id":14958268,"url":"https://github.com/khuangaf/cryptocurrencyprediction","last_synced_at":"2025-04-12T17:41:41.706Z","repository":{"id":40763646,"uuid":"103018636","full_name":"khuangaf/CryptocurrencyPrediction","owner":"khuangaf","description":"Predict Cryptocurrency Price with Deep Learning","archived":false,"fork":false,"pushed_at":"2023-03-10T06:55:12.000Z","size":6491,"stargazers_count":918,"open_issues_count":15,"forks_count":342,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-04-03T19:16:01.471Z","etag":null,"topics":["bitcoin","cnn","cryptocurrency","deep-learning","final-year-project","gru","lstm","machine-learning","sklearn"],"latest_commit_sha":null,"homepage":"https://blog.goodaudience.com/predicting-cryptocurrency-price-with-tensorflow-and-keras-e1674b0dc58a","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khuangaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-10T09:44:16.000Z","updated_at":"2025-03-28T08:59:48.000Z","dependencies_parsed_at":"2024-09-02T16:20:54.149Z","dependency_job_id":"24a19e96-63f9-4ce3-94f6-5a5ef30a35b3","html_url":"https://github.com/khuangaf/CryptocurrencyPrediction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khuangaf%2FCryptocurrencyPrediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khuangaf%2FCryptocurrencyPrediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khuangaf%2FCryptocurrencyPrediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khuangaf%2FCryptocurrencyPrediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khuangaf","download_url":"https://codeload.github.com/khuangaf/CryptocurrencyPrediction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248607964,"owners_count":21132643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","cnn","cryptocurrency","deep-learning","final-year-project","gru","lstm","machine-learning","sklearn"],"created_at":"2024-09-24T13:16:38.852Z","updated_at":"2025-04-12T17:41:41.685Z","avatar_url":"https://github.com/khuangaf.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep Learning for Cryptocurrency Price Prediction\n\u003cdiv float=\"left\"\u003e\n  \u003cimg src=\"https://www.tensorflow.org/images/tf_logo_transp.png\" height=\"120\" \u003e\n  \u003cimg src=\"https://s3.amazonaws.com/keras.io/img/keras-logo-2018-large-1200.png\" height=\"120\"\u003e\n\u003c/div\u003e\n\u003cdiv float=\"right\"\u003e\n\n\u003c/div\u003e\n\n## \n\n### Introduction\nThis repo makes use of the state-of-art Deep Learning algorithm to predict the price of Bitcoin, which has the potential to generalize to other cryptocurrency. It leverages models such as CNN and RNN implemented by [Keras](https://github.com/keras-team/keras) running on top of [Tensorflow](https://github.com/tensorflow/tensorflow). You can find more detailed illustration in this [blog post](https://blog.goodaudience.com/predicting-cryptocurrency-price-with-tensorflow-and-keras-e1674b0dc58a).\n\n### Getting Started\nTo run this repo, be sure to install the following environment and library:\n\n1. Python 2.7\n2. Tensorflow=1.2.0\n3. Keras=2.1.1\n4. Pandas=0.20.3\n5. Numpy=1.13.3\n6. h5py=2.7.0\n7. sklearn=0.19.1\n\n### File Illustration\n#### There are currently three different models:\n1. LSTM.py\n2. GRU.py\n3. CNN.py (1 dimensional CNN)\n\n#### The validation result is plotted in:\n1. Plot_LSTM.ipynb\n2. Plot_GRU.ipynb\n3. Plot_CNN.ipynb\n\n#### Data is collected from [poloniex](https://poloniex.com) and parse to h5py file:\n1. DataCollection.ipynb\n2. PastSampler.ipynb\n\n### Run\nTo run the prediction model, select one of the model. For instance, \n```\npython CNN.py\n```\nTo run iPython file, you need to run jupyter notebook\n```\njupyter notebook\n```\n__Be sure to run DataCollection.ipynb and PastSampler.ipynb first to create database for training models.__\n### Input \u0026 Output \u0026 Loss\nThe input consists of a list of past Bitcoin data with step size of 256.\nThe output is the predicted value of the future data with step size of 16. Note that since the data is ticked every five minutes, the input data spans over the past 1280 minutes, while the output cover the future 80 minutes. The datas are scaled with MinMaxScaler provided by sklearn over the entire dataset. The loss is defined as Mean Square Error (MSE).\n\n### Result\n|Model | #Layers  |  Activation    | Validation Loss   |Test Loss (Scale Inverted) |\n|----------| ------------- |------|-------| -----|\n|   CNN    | 2       | ReLU       |    0.00029     | 114308 |\n|   CNN    | 2       | Leaky ReLU       |    0.00029     | 115525 |\n|   CNN    | 3       | ReLU       |    0.00029     | 201718 |\n|   CNN    | 3       | Leaky ReLU       |    0.00028     | 108700 |\n|   CNN    | 4       | ReLU       |    0.00030     | 117947 |\n|   CNN    | 4       | Leaky ReLU       |    0.03217     | 12356304 |\n|   LSTM    | 1      | tanh + ReLU       |    0.00007     | 26649 |\n|   LSTM    | 1      | tanh + Leaky ReLU       |    0.00004     | 15364 |\n|   GRU    | 1      | tanh + ReLU       |    0.00004     | 17667 |\n|   GRU    | 1      | tanh + Leaky ReLU       |    0.00004     | 15474 |\n|   Baseline (Lag)    | -     | -       |    -     | 19122 |\n|   Linear Regression   | -     | -       |    -     | 19789 |\n\n\n\nEach row of the above table is the model that derives the best validation loss from the total 100 training epochs. From the above result, we can observe that LeakyReLU always seems to yield better loss compared to regular ReLU. However, 4-layered CNN with Leaky ReLU as activation function creates a large validation loss, this can due to wrong deployment of model which might require re-validation. CNN model can be trained very fast (2 seconds/ epoch with GPU), with slightly worse performance than LSTM and GRU. The best model seems to be LSTM with tanh and Leaky ReLU as activation function, though 3-layered CNN seems to be better in capturing local temporal dependency of data.\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"result/bitcoin2015to2017_close_LSTM_1_tanh_leaky_result.png\" width=\"80%\" /\u003e\n\u003c/div\u003e\n\n_LSTM with tanh and Leaky ReLu as activation function._\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"result/bitcoin2015to2017_close_CNN_3_leaky_result.png\" width=\"80%\" /\u003e\n\u003c/div\u003e\n\n_3-layered CNN with Leaky ReLu as activation function._\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"result/bitcoin2015to2017_close_rw.png\" width=\"80%\" /\u003e\n\u003c/div\u003e\n\n_Baseline_\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"result/bitcoin2015to2017_close_lr.png\" width=\"80%\" /\u003e\n\u003c/div\u003e\n\n_Linear Regression_\n\n## Update\nRegularization has been done, which can be viewed in PlotRegularization.ipynb.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhuangaf%2Fcryptocurrencyprediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhuangaf%2Fcryptocurrencyprediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhuangaf%2Fcryptocurrencyprediction/lists"}