Overview
TheProphetCryptoPredictor class implements Meta’s (Facebook) Prophet algorithm, specialized for medium to long-term cryptocurrency price forecasting. Prophet excels at detecting trend changes and seasonal patterns in volatile time series data.
Best for: Medium to long-term predictions (1 week to 1 month)
Constructor
Parameters
Controls flexibility in detecting trend changes. Higher values allow the model to fit more flexible trends.Effect on crypto:
- Low (0.001-0.1): Conservative, smooth trends. Good for stable markets.
- Medium (0.1-0.5): Balanced. Recommended for most crypto assets.
- High (0.5-1.0): Highly flexible. Better for volatile altcoins.
- Underfitting (too smooth)? Increase this value
- Overfitting (too wiggly)? Decrease this value
Controls strength of seasonal components (daily/weekly patterns).Effect:
- Low (1-5): Weak seasonality, focuses more on trend
- Medium (5-15): Balanced. Recommended for most cases.
- High (15-30): Strong seasonality. Use if you see clear daily/weekly patterns.
Width of uncertainty intervals in predictions.Common values:
0.80: 80% confidence (narrower bands)0.90: 90% confidence0.95: 95% confidence (wider bands, recommended)0.99: 99% confidence (very wide bands)
Methods
prepare_data()
Converts DataFrame to Prophet’s required format (ds, y).DataFrame with:
- Datetime index
closecolumn with price data
DataFrame with Prophet format:
ds: Date/timestamp columny: Price values (fromclosecolumn)
train()
Trains the Prophet model on historical data.Historical price data with datetime index and
close column.Requirements:- Minimum 100 data points
- Regular frequency (hourly or daily recommended)
- No large gaps in time series
Dictionary with training metrics:Interpreting metrics:
mape: Lower is better (good: <10%, acceptable: <15% for crypto)direction_accuracy: Higher is better (>50% = better than random)rmse: Absolute error in price units
predict_future()
Generates forecasts with confidence intervals.Number of time periods to forecast.Examples:
168: 7 days (if freq=‘H’)720: 30 days (if freq=‘H’)7: 1 week (if freq=‘D’)
Frequency of predictions.Common values:
'H': Hourly'D': Daily'W': Weekly
DataFrame with datetime index and columns:
predicted_price(yhat): Point forecastlower_bound(yhat_lower): Lower confidence intervalupper_bound(yhat_upper): Upper confidence intervaltrend: Underlying trend component (without seasonality)
Utility Functions
backtest_prophet()
Performs time series cross-validation backtesting.Historical OHLCV data with datetime index.
Initialized predictor instance (not yet trained).
Number of periods to hold out for testing.Common values:
168: 1 week (hourly data)336: 2 weeks7: 1 week (daily data)
Comprehensive backtest results:Use test metrics to evaluate real-world performance.
Complete Example
Model Configuration Guide
Configuration for Prophet
The Prophet model includes several built-in configurations:Tuning for Different Cryptocurrencies
Bitcoin (BTC) / Ethereum (ETH) - Large Cap:Key Characteristics
Strengths:- Excellent for trend detection and long-term forecasting
- Automatically handles seasonality (daily/weekly patterns)
- Built-in confidence intervals
- Robust to missing data and outliers
- Interpretable components (trend, seasonality)
- Handles changepoints (sudden trend shifts) automatically
- Slower training than XGBoost
- Not ideal for very short-term predictions (<24 hours)
- Requires minimum 100 data points
- Less effective in highly erratic markets
- Cannot use external features/regressors in this implementation
- MAPE: 5-12% for 7-day predictions
- Direction Accuracy: 52-60%
- Best for: 3-day to 30-day forecasts
- Forecasting 1 week to 1 month ahead
- Need confidence intervals
- Want to understand trend vs. seasonality
- Historical data shows clear patterns
- Presenting forecasts to non-technical stakeholders