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.
- π 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
- Mahmoud Emad Khairy
- Ammar Ahmed Farag
- Mostafa Mohamed Abdullah
- π GitHub: mahmoud554377
- π GitHub: ammarelbordeny
- π GitHub: HagAli22
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
| 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 |
pip install -r requirements.txtstreamlit run app.py- Open your browser to
http://localhost:8501 - Input Bitcoin OHLCV data:
- Date: Select prediction date
- Open Price: Opening price
- High Price: Highest price
- Low Price: Lowest price
- Volume: Trading volume
- Click "Predict" to get price predictions from all models
- View results from CNN, LSTM, and GRU models
- Python 3.8 or higher
- pip package manager
- Clone the repository:
git clone
cd bitcoin_price_prediction- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Ensure you have the trained models:
btc_cnn_model.pklbtc_lstm_model.h5btc_gru_model.h5scaler.pkl
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
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
streamlit run app.pyTrain 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.pyMake 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.pyModify config/config.py to adjust:
- Window size for time series sequences
- Model hyperparameters
- Training parameters
- File paths
The project expects Bitcoin OHLCV data with the following columns:
timestamp: Date/time informationopen: Opening pricehigh: Highest pricelow: Lowest priceclose: Closing price (target variable)volume: Trading volume
- Two 1D convolutional layers with max pooling
- Dropout layers for regularization
- Dense layers for final prediction
- Two LSTM layers with return sequences
- Dropout layers for regularization
- Dense layers for final prediction
- Two GRU layers with return sequences
- Dropout layers for regularization
- Dense layers for final prediction
- Voting regressor combining LSTM and GRU
- Provides uncertainty estimation through model disagreement
- RΒ² Score: Coefficient of determination
- MSE: Mean Squared Error
- MAE: Mean Absolute Error
- RMSE: Root Mean Squared Error
The project includes comprehensive visualizations:
- Price and volume time series plots
- Training history plots
- Prediction vs actual value plots
- Model comparison plots
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
This project is provided as-is for educational and research purposes.
Feel free to open issues or submit pull requests for improvements.
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


