Sunspot Cycle Insights + LSTM Time-Series Forecasting
This project performs an end-to-end analysis of solar sunspot cycles and builds an LSTM-based forecasting model to predict future Solar Sunspot Numbers (SSN).
It combines scientific visualization, time-series pattern discovery, and deep learning forecasting to better understand solar activity and its impact on space weather.
Solar cycles are approximately 11-year cycles where the Sun’s magnetic activity fluctuates, influencing:
- Satellite operations
- Communication systems
- Navigation signals
- Power grid stability (space weather impact)
This repository demonstrates both interpretation (analysis) and prediction (modeling) using real historical SSN trends.
- Visualize long-term sunspot activity patterns
- Compare SSN with correlated solar indicators
- Study cyclic behavior, lag patterns, and seasonality
- Forecast SSN values using an LSTM neural network
- Evaluate forecasting quality using MAE and visualization
This project uses historical Sunspot Number data from the Kaggle dataset:
🔗 Sunspots Dataset:
https://www.kaggle.com/datasets/robervalt/sunspots
The dataset contains:
- Monthly sunspot numbers from 1700s to present
- Used for studying solar magnetic activity cycles
- Ideal for time-series analysis and forecasting
- Cyclical pattern repeats roughly every 11 years
- A full cycle can range from 9 to 14 years
- Each cycle transitions through:
- Solar Minimum → Solar Maximum → Solar Minimum
- Sunspot Number: direct indicator of solar magnetic activity
- 10.7 cm Radio Flux: indirect measure via radio energy emission
Both rise and fall together, showing a strong correlation.
This plot highlights an inverse relationship and supports the concept of magnetic polarity reversal approximately every 11 years.
Lag plots show the series is not random, meaning it contains strong predictive structure.
Key historical behavior includes:
- Dip around 1790–1820 → Dalton Minimum
- Major peak around 1960, followed by fluctuations
A positive correlation is observed:
- Higher sunspot activity → higher solar irradiance
The heatmap suggests:
- Short-term ~11-year solar cycle
- Long-term ~100-year brightness cycle
This module uses a Long Short-Term Memory (LSTM) neural network to forecast SSN values from historical time-series data.
- MinMax Scaling for stable neural training
- Lag Feature Engineering using 16 time steps
- 3-layer LSTM architecture with 32 units per layer
- Callbacks
- Learning rate reduction on plateau
- Early stopping to reduce overfitting
- Evaluation using Mean Absolute Error (MAE)
- Model Type: LSTM (Time-Series Forecasting)
- Lag Window: 16 steps
- Loss Function: Mean Squared Error (MSE)
- Optimizer: Adam
- Output: Next-step SSN prediction
- Baseline MAE: (update with your value)
- LSTM MAE: 13.29 (inverse transformed)
SolarCycle-analysis_and_prediction/
│
├── solorcycle_analysis.ipynb # Full solar cycle analysis notebook
├── Lstm_sunspot_predict_model.ipynb # LSTM forecasting notebook
├── image1.png # Historical SSN cycle plot
├── image2.png # SSN vs Radio Flux
├── image3.png # Polar Field vs SSN
├── image4.png # Lag & Seasonality plots
├── image5.png # TSI vs SSN
├── image6.png # Asymmetry heatmap
├── prediction_plot.png # LSTM prediction vs actual
└── README.md
- Python 3.x
- Libraries:
- NumPy
- Pandas
- Matplotlib
- scikit-learn
- statsmodels
- TensorFlow / Keras
Install dependencies:
pip install numpy pandas matplotlib scikit-learn statsmodels tensorflow- Open
solorcycle_analysis.ipynband run all cells - Open
Lstm_sunspot_predict_model.ipynband run all cells
jupyter notebookThis project shows that sunspot data contains strong cyclic patterns, meaningful relationships with solar indicators, and clear forecasting potential.
By combining analysis + LSTM prediction, it provides a strong foundation for extending solar forecasting using more advanced deep learning and hybrid time-series methods.
- Experiment with different lag lengths
- Try alternative architectures (GRU, ConvLSTM)
- Add exogenous features (radio flux, polar field, TSI)
- Perform hyperparameter tuning (Optuna / KerasTuner)
- Multi-step forecasting (predict multiple months ahead)
Nithish Gowda H N - BTech(Hons.) CSE, AI & ML Major
Prajna - BTech(Hons.) CSE, Cloud & Full Stack Major






