Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “LSTM Load Forecasting Class #2: Calendar Features, Temperature, and Lag; Time Series Windowing”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
This is the final result, 11 features that translate time, holidays, and temperature into numbers that the neural network can understand, then arranged into tens of thousands of 168-hour windows to predict the next 24 hours. Let's start. Hello, welcome to episode two of the electric load forecasting series with LSTM. The model is only as good as the features it is given. In the previous episode, we saw that load depends on time, day, season, holidays, and temperature. Today, we are turning all of that into features, normalizing them properly, and arranging the data into windows for a time series model.
Create a file named feature.py Time, day, and month are encoded with sine and cosine, because time is cyclical. Hour 23 should be close to hour 0, but as a regular number, they are far apart. Holidays use the holidays library for Belgium, combined with Saturdays and Sundays. Temperature is converted into heating degrees, which is how far the temperature is below 15 degrees. Lag feature 168 is the load at the same hour from one week prior. The first row without lag is discarded. The Scale class normalizes each feature using only the mean and standard deviation of the training data.
If statistics are calculated from all the data, information from the future leaks into training, making the test results appear better than they are. The prepare function calculates the features on the full data and records the training, validation, and test index boundaries. The window function takes the last 168 hours as input and the next 24 hours of load as the target. The history for the validation and test windows can be taken from the previous period, because in the real world, historical data is indeed available.
Create a file named check_underscore_feature.py and run it. There are 11 features, and about 31 percent of the hours are holidays or weekends. Normalized load in the training data has a mean of 0 and a standard deviation of 1. For training, the window is shifted by 1 hour, resulting in almost 26,000 examples shaped as 168 x 11. For validation, 1 forecast per day at every 00:00, exactly 365 windows.
Let's look at the features for one week. The top row shows load and lag for 168 hours with a pattern that is very similar. The middle row shows sine and cosine of repeating hours smoothly every day. The bottom row shows temperature and weekend markers. With features like these, the model knows when a certain hour occurs and under what conditions.
Done. We have created calendar cycle, holiday, heating degree, and lag features, normalized without data leakage, and arranged the time series window. In the next episode, we create baseline, naive, ridge regression, and SARIMA. Are you working on a thesis, dissertation, or research in the field of load forecasting and time series? Cerdas Inovasi Digital helps with deep learning implementation, from load data exploration, feature engineering, ARIMA and regression, LSTM with PyTorch, up to hyperparameter optimization with genetic algorithms, as well as opening deep learning courses with PyTorch. Want to master the entire series, from hourly load data to forecast evaluation? All 6 episodes, complete with PDF step-by-step guides and source code, are available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want just one class? Buy a single class with lifetime access. Subscribe now at the premium page cerdasinovasidigital.com. Contact us via WhatsApp or visit cerdasinovasidigital.com. Thank you for watching, see you in the next episode. Thank you for watching,
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →