This project implements Long Short-Term Memory (LSTM) neural networks for wind power forecasting using turbine sensor data. The model predicts wind power output 10 minutes ahead based on historical weather and operational parameters.
Long Short-Term Memory (LSTM) is a type of recurrent neural network designed to handle sequential data and learn long-term dependencies. Unlike traditional RNNs, LSTMs can:
- Remember important information over long sequences
- Forget irrelevant information through gating mechanisms
- Handle vanishing gradient problems that plague standard RNNs
- Forget Gate: Decides what information to discard
- Input Gate: Determines what new information to store
- Output Gate: Controls what parts of memory to output
- Cell State: Maintains long-term memory across time steps
LSTMs are particularly effective for time series forecasting because they can capture complex temporal patterns and dependencies in sequential data.
-
prepare_data()
: Loads and cleans raw turbine data- Handles negative power values, turbine shutdowns, and sensor anomalies
- Removes outliers and fills missing values
- Drops unnecessary timestamp columns
-
supervised_dataset()
: Converts time series into supervised learning format with sliding windows- Creates input sequences of specified window length
- Generates corresponding target values for forecasting
- Supports configurable forecast horizons
-
train_val_test_split()
: Splits data into training (70%), validation (20%), and test (10%) sets- Maintains temporal order for time series data
- Returns properly shaped arrays for model training
train_model()
: Enhanced training loop with comprehensive monitoring- Batch progress tracking with real-time loss updates
- Validation monitoring to prevent overfitting
- Device auto-detection (GPU/CPU)
- Change indicators showing improvement/deterioration
-
plot_training_history()
: Visualizes training and validation loss curves over epochs- Identifies optimal stopping points
- Shows convergence patterns
-
plot_predictions()
: Comprehensive 4-panel analysis including:- Time series comparison (actual vs predicted)
- Scatter plot for correlation analysis
- Residual distribution analysis
- Performance metrics (MSE, MAE, RMSE, R²)
Raw Data → Cleaning → Windowing → Scaling → Train/Val/Test Split
- Window Size: 18 timesteps (3 hours of 10-minute intervals)
- Features: Wind speed, direction, external/internal temperature, nacelle direction, blade pitch angles
- Target: Wind power output (Patv)
- Scaling: StandardScaler for both features and target to ensure stable training
Initial Training → Hyperparameter Tuning → Validation Analysis
- Train multiple models with different epoch counts (5, 6, 10 epochs)
- Monitor validation performance to prevent overfitting
- Use validation set to determine optimal training duration
- Analyze training curves to identify convergence patterns
Train + Validation → Combined Training → Test Evaluation
- Combine training and validation sets for final model training
- Retrain for optimal number of epochs (determined from validation experiments)
- Evaluate only on unseen test set for unbiased performance assessment
Input (8 features, 18 timesteps) → LSTM Layers (128 hidden units) → Dense Layer → Output (1 value)
- Input Size: 8 meteorological and operational features
- Hidden Size: 128 units per LSTM layer
- LSTM Layers: 2 stacked layers with 20% dropout for regularization
- Output: Single value representing predicted power output
- Activation: Linear output layer for regression
- Robust Validation Strategy: Separate validation phase prevents overfitting and ensures generalization
- Temporal Pattern Recognition: LSTM architecture captures complex time dependencies in weather patterns
- Comprehensive Evaluation: Multiple metrics and visualizations provide thorough performance assessment
- Modular Pipeline: Utility functions enable easy experimentation and hyperparameter tuning
- Unbiased Testing: Final evaluation on truly unseen test data
- Real-world Applicability: 10-minute ahead forecasting supports practical grid management decisions
The trained model is evaluated using multiple regression metrics:
- MSE (Mean Squared Error): Measures average squared prediction errors
- MAE (Mean Absolute Error): Average absolute prediction errors
- RMSE (Root Mean Squared Error): Standard deviation of prediction errors
- R² Score: Coefficient of determination (explained variance)
The LSTM model demonstrates effective wind power forecasting capabilities with:
- Accurate 10-minute ahead predictions
- Strong correlation between actual and predicted values
- Low prediction errors suitable for grid management applications
- Robust performance across different weather conditions
This forecasting system enables improved renewable energy planning, grid stability management, and power trading decisions.
Technologies: Python, PyTorch, NumPy, Pandas, Matplotlib, Scikit-learn