Skip to content

Predict Bitcoin prices using deep learning models (CNN, LSTM, GRU) and visualize results in an interactive Streamlit web app. Built with TensorFlow, scikit-learn, pandas, and more.

License

Notifications You must be signed in to change notification settings

HagAli22/Bitcoin-Price-Prediction-with-Deep-Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’² Bitcoin Price Prediction with Deep Learning & Streamlit Web App

This project implements three different deep learning models (CNN, LSTM, GRU) to predict Bitcoin prices using historical OHLCV data. The project includes both a comprehensive training pipeline and an interactive Streamlit web application for real-time price predictions.

🌟 Features

  • πŸš€ Interactive Web App: User-friendly Streamlit interface for real-time predictions
  • 🧠 Multiple Model Architectures: CNN, LSTM, GRU models
  • ⚑ Real-time Predictions: Input OHLCV data and get instant price predictions
  • πŸ“Š Model Comparison: Compare predictions from all three models
  • πŸ”§ Modular Design: Easy to extend and modify individual components
  • πŸ“ˆ Comprehensive Training Pipeline: Complete data preprocessing and model training

This project was collaboratively developed by:

  • Mahmoud Emad Khairy
  • Ammar Ahmed Farag
  • Mostafa Mohamed Abdullah

πŸ“§ Contact & Support

πŸ“ Project Structure

bitcoin_price_prediction/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/
β”‚   β”‚   └── BTC_USDT_ohlcv_data.parquet
β”‚   └── processed/
β”‚       └── BTC_USDT_ohlcv_data.csv
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ cnn/
β”‚   β”‚   β”œβ”€β”€ cnn_model.py           # CNN model architecture
β”‚   β”‚   β”œβ”€β”€ train_cnn.py          # CNN training script
β”‚   β”‚   β”œβ”€β”€ predict_cnn.py        # CNN prediction script
β”‚   β”‚   └── saved_models/         # Saved CNN models
β”‚   β”œβ”€β”€ lstm/
β”‚   β”‚   β”œβ”€β”€ lstm_model.py         # LSTM model architecture
β”‚   β”‚   β”œβ”€β”€ train_lstm.py         # LSTM training script
β”‚   β”‚   β”œβ”€β”€ predict_lstm.py       # LSTM prediction script
β”‚   β”‚   └── saved_models/         # Saved LSTM models
β”‚   β”œβ”€β”€ gru/
β”‚   β”‚   β”œβ”€β”€ gru_model.py          # GRU model architecture
β”‚   β”‚   β”œβ”€β”€ train_gru.py          # GRU training script
β”‚   β”‚   β”œβ”€β”€ predict_gru.py        # GRU prediction script
β”‚   β”‚   └── saved_models/         # Saved GRU models
β”‚   └── ensemble/
β”‚       β”œβ”€β”€ ensemble_model.py     # Ensemble model architecture
β”‚       β”œβ”€β”€ train_ensemble.py     # Ensemble training script
β”‚       └── predict_ensemble.py   # Ensemble prediction script
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ data_preprocessing.py     # Data preprocessing utilities
β”‚   β”œβ”€β”€ visualization.py         # Visualization utilities
β”‚   └── evaluation.py            # Model evaluation utilities
β”œβ”€β”€ config/
β”‚   └── config.py                # Configuration parameters
β”œβ”€β”€ notebooks/
β”‚   └── exploration.ipynb        # Original exploration notebook
β”œβ”€β”€ app.py                       # 🌟 Streamlit Web Application
β”œβ”€β”€ scaler.pkl                  # Saved data scaler
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md                   # This file

Models Implemented & Performance

πŸ“Š Model Comparison Table

Model Test RΒ² Validation RΒ² Test Loss Val Loss Notes
🧠 CNN 0.936 0.693 0.002 0.001 Strong on patterns, overfitting signs
πŸ“ˆ LSTM 0.910 0.870 0.003 0.0002 Best generalization
πŸ“‰ GRU 0.862 0.737 0.005 0.0005 Lightweight & reliable

πŸš€ Quick Start - Web Application

1. Install Dependencies

pip install -r requirements.txt

2. Run the Streamlit App

streamlit run app.py

3. Use the Web Interface

πŸ“± Web Application Features

Bitcoin Price Prediction App

  1. Open your browser to http://localhost:8501
  2. Input Bitcoin OHLCV data:
    • Date: Select prediction date
    • Open Price: Opening price
    • High Price: Highest price
    • Low Price: Lowest price
    • Volume: Trading volume
  3. Click "Predict" to get price predictions from all models
  4. View results from CNN, LSTM, and GRU models

πŸ“‹ Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation Steps

  1. Clone the repository:
git clone 
cd bitcoin_price_prediction
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Ensure you have the trained models:
    • btc_cnn_model.pkl
    • btc_lstm_model.h5
    • btc_gru_model.h5
    • scaler.pkl

πŸ“ˆ Data Analysis & Visualizations

Bitcoin Trading Volume Over Time

Bitcoin Trading Volume

The trading volume analysis reveals:

  • Peak Activity: Massive volume spikes during 2023 (up to 40,000+ units)
  • Market Cycles: Volume correlates with major price movements
  • Volatility Indicator: High volume periods coincide with market uncertainty

Bitcoin Price Evolution (2018-2025)

Bitcoin Price Chart

Key price milestones:

  • πŸš€ 2021 Bull Run: Reached ~$65,000
  • πŸ“‰ 2022-2023 Correction: Market consolidation around $15,000-$30,000
  • πŸŒ™ 2025 Surge: Dramatic rise to over $100,000

🎯 Usage Options

Option 1: Web Application (Recommended)

streamlit run app.py

Option 2: Individual Model Training

Train specific models:

# Train CNN model
cd models/cnn
python train_cnn.py

# Train LSTM model
cd models/lstm
python train_lstm.py

# Train GRU model
cd models/gru
python train_gru.py

Option 3: Command Line Predictions

Make predictions with trained models:

# CNN predictions
cd models/cnn
python predict_cnn.py

# LSTM predictions
cd models/lstm
python predict_lstm.py

# GRU predictions
cd models/gru
python predict_gru.py

Configuration

Modify config/config.py to adjust:

  • Window size for time series sequences
  • Model hyperparameters
  • Training parameters
  • File paths

Data Requirements

The project expects Bitcoin OHLCV data with the following columns:

  • timestamp: Date/time information
  • open: Opening price
  • high: Highest price
  • low: Lowest price
  • close: Closing price (target variable)
  • volume: Trading volume

Model Architectures

CNN Model

  • Two 1D convolutional layers with max pooling
  • Dropout layers for regularization
  • Dense layers for final prediction

LSTM Model

  • Two LSTM layers with return sequences
  • Dropout layers for regularization
  • Dense layers for final prediction

GRU Model

  • Two GRU layers with return sequences
  • Dropout layers for regularization
  • Dense layers for final prediction

Ensemble Model

  • Voting regressor combining LSTM and GRU
  • Provides uncertainty estimation through model disagreement

Evaluation Metrics

  • RΒ² Score: Coefficient of determination
  • MSE: Mean Squared Error
  • MAE: Mean Absolute Error
  • RMSE: Root Mean Squared Error

Visualization

The project includes comprehensive visualizations:

  • Price and volume time series plots
  • Training history plots
  • Prediction vs actual value plots
  • Model comparison plots

Dependencies

Key dependencies include:

  • TensorFlow/Keras for deep learning
  • scikit-learn for preprocessing and ensemble methods
  • pandas for data manipulation
  • matplotlib/seaborn for visualization
  • joblib for model persistence

License

This project is provided as-is for educational and research purposes.

Contributing

Feel free to open issues or submit pull requests for improvements.


requirements.txt

tensorflow>=2.10.0 scikit-learn>=1.1.0 pandas>=1.5.0 numpy>=1.21.0 matplotlib>=3.5.0 seaborn>=0.11.0 joblib>=1.1.0 scikeras>=0.10.0


About

Predict Bitcoin prices using deep learning models (CNN, LSTM, GRU) and visualize results in an interactive Streamlit web app. Built with TensorFlow, scikit-learn, pandas, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published