Bitcoin Price Prediction with LSTM
Project Overview
This project aims to predict Bitcoin (BTC) prices for the next 60 days using a Long Short-Term Memory (LSTM) neural network. The dataset used contains historical BTC/USD prices from 2014 to early 2024. The project leverages PyTorch for deep learning and includes data preprocessing, feature engineering, and model evaluation.
Table of Contents
- Introduction
- Dataset Description
- Project Workflow
- Model Architecture
- Results
- How to Run
- Future Work
- References
Introduction
Bitcoin is a highly volatile cryptocurrency, making price prediction a challenging task. This project uses sequential data modeling with LSTM to capture patterns in historical BTC prices and provide reliable predictions.
Dataset Description
- Source: Kaggle
- File:
Dataset/BTC-USD.csv
- Columns:
Date
,Open
,High
,Low
,Close
,Adj Close
,Volume
- Timeframe: 2014 to early 2024
- Frequency: Minute-level data aggregated to daily prices.
Project Workflow
1. Data Preparation
- Import libraries and load the dataset.
- Perform initial exploration to understand the data structure.
2. Data Cleaning
- Handle missing values and duplicates.
- Normalize and standardize the data for better model performance.
3. Exploratory Data Analysis (EDA)
- Visualize trends in BTC prices and trading volume.
- Analyze correlations between features.
4. Feature Engineering
- Create sequences of 30 days as input features.
- Scale features using
MinMaxScaler
.
5. Modeling
- Build LSTM and GRU models using PyTorch.
- Train the models with Mean Squared Error (MSE) loss and Adam optimizer.
6. Evaluation
- Evaluate the model using Root Mean Squared Error (RMSE).
- Visualize predictions against actual prices.
7. Prediction
- Predict BTC prices for the next 60 days.
- Compare predictions with actual future prices.
Model Architecture
The LSTM model consists of:
- Input Layer: Sequence of 30 days of closing prices.
- Hidden Layers: 2 LSTM layers with 64 hidden units.
- Output Layer: Single neuron for predicting the next day's price.
Results
- LSTM Test RMSE: ~1,118 USD
- GRU Test RMSE: ~21,445 USD
- The LSTM model outperformed the GRU model, demonstrating its ability to capture sequential patterns in BTC prices.
How to Run
Clone the repository:
git clone <repository-url> cd Bitcoin-Prediction
Install dependencies:
pip install -r requirements.txt
Run the Jupyter Notebook:
jupyter notebook Notebook.ipynb
Follow the steps in the notebook to train the model and visualize predictions.
Future Work
- Add additional features such as macroeconomic indicators, Moving Average, RSI or sentiment analysis.
- Perform hyperparameter tuning to further improve model performance.
- Deploy the model as a web application for real-time predictions.
References
- Kaggle Dataset: BTC-USD Historical Data
- PyTorch Documentation: https://pytorch.org/
- CoinGecko API: https://www.coingecko.com/
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
๐
Ask for provider support