
In this project, you will learn how to build a Machine Learning model with Python. We will build a XGBoost Model that will help us in forecasting of electricity demand in a city.
You will learn how to handle time-series data, create powerful features, train a machine learning model and and evaluate its performance.
Here, we have used a historical data of last 5 years. Based on this data we will predict the future demand using our model.
This is a time series dataset with Per Hour information. In this dataset, we have multiple useful columns like - Temperature, Humidity, Demand etc.
From the datetime column, we created other useful columns like day_of_year, week_of_year, is_weekend, is_holiday etc.
We have used the line chart, box plot for visualization.
We will import all the required libraries like Pandas, Matplotlib, Seaborn, Numpy etc.
We will import our dataset and check some information about the dataset using the Python built-in functions like info, describe etc.
We will set the Timestamp column as our DataFrame's index to create a Time-Series.
Here, we will learn how to find out Missing or Null Values from the dataset, and deal with these values.
We used isnull().sum() function to check the sum of missing values in each column.
We used isna().any() function to show the records with missing values.
We used dropna() function to delete the records that contain missing values.
We used bfill (backward fill) , ffill (forward fill) , interpolate method for imputation.
Here, we will create new features (columns) that will us in building our ML model.
We used the insert( ) function to add new columns in the dataset at a particular index.
We created the following features - Quarter of the year, Week of the year, is_weekend,
We converted the datatype of one column into other datatype using astype() function.
We created Lagged Features to check the demand at last data points like at last_24_hours, last_week.
We created new features to get Rolling Window Mean and Rolling Window Standard Deviation.
We used holidays module to check national holidays.
We plot a chart to check Demand over the Time.
We plot a Boxplot to see Demand by Hour of the Day.
We plot a Boxplot to see Demand by Month.
We plot a Scatter Plot to check Demand vs Temperature.
We built a Correlation Matrix of numerical columns in the form of Heat Map.
Now, we will start building our ML model.
We will define the training and testing data.
We will initialize our XGBoost model.
We will make the prediction using this model, and evaluate its performance by RMSE, MAE.
Then we will visualize our final prediction wrt to the actual prediction.
Finally, we will save the model for future use.
In this project, you will learn how to build a Machine Learning model with Python. We will build a XGBoost Model that will help us in forecasting of electricity demand in a city.
You will learn how to handle time-series data, create powerful features, train a machine learning model and and evaluate its performance.
Here, we have used a historical data of last 5 years. Based on this data we will predict the future demand using our model.
This is a time series dataset with Per Hour information. In this dataset, we have multiple useful columns like - Temperature, Humidity, Demand etc.
From the datetime column, we created other useful columns like day_of_year, week_of_year, is_weekend, is_holiday etc.
We have used the line chart, box plot for visualization.
Key Learnings:
Time Series Data Handling
Feature Engineering for Demand Forecasting
Machine Learning (XGBoost) for Prediction
Model Evaluation (RMSE, MAE)
Understanding Energy Consumption Patterns
We will make use of :
Python: The core programming language
Pandas: Data manipulation and analysis
NumPy: Numerical operations
Matplotlib & Seaborn: Data visualization
Scikit-learn: Machine learning utilities
XGBoost: Gradient Boosting for robust predictions
Holidays: For national holiday data
Master Energy Forecasting: A Python Project for Electricity Demand Prediction.
Thanks all students !