This project uses machine learning to predict Bitcoin prices across different time horizons (1-day, 7-day, and 30-day forecasts) using scikit-learn's Random Forest Regressor. The model incorporates various technical indicators and market features to make its predictions.
python >= 3.6
yfinance
pandas
numpy
scikit-learn
matplotlib
- Clone this repository:
git clone <repository-url>
- Install required packages:
pip install yfinance pandas numpy scikit-learn matplotlib
Simply run the main script:
python bitcoin_predictor.py
The script will:
- Download Bitcoin historical data from Yahoo Finance (2019-present)
- Generate technical indicators and features
- Train models for different prediction windows
- Create visualization plots saved as PNG files
- Display performance metrics for each model
- Multiple Moving Averages (SMA & EMA)
- RSI (Relative Strength Index)
- Bollinger Bands
- Volatility Indicators
- Volume Analysis
- Price Momentum
- Daily Returns
- Log Returns
The script generates three visualization files:
bitcoin_analysis_1day.png
: 1-day forecast analysisbitcoin_analysis_7day.png
: 7-day forecast analysisbitcoin_analysis_30day.png
: 30-day forecast analysis
Each visualization includes:
- Predicted vs Actual price scatter plot
- Prediction error distribution
- Price trends over time
The model's performance is evaluated using:
- Root Mean Square Error (RMSE)
- Mean Absolute Error (MAE)
- Algorithm: Random Forest Regressor
- Training/Test Split: 80/20
- Features are standardized using StandardScaler
- Model Parameters:
- n_estimators: 100
- max_depth: 10
- random_state: 42
- Past performance doesn't guarantee future results
- Market conditions and external factors can impact accuracy
- Predictions should not be used as sole financial advice
Feel free to fork this repository and submit pull requests for improvements.
This project is licensed under the MIT License - see the LICENSE file for details