Skip to content

rafbot-v7/Electricity-consumption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

This Python script demonstrates how to perform a multi-step forecast using various linear algorithms for time series data. Here's a breakdown of the main components and functionalities:

Importing Libraries: The script starts by importing necessary libraries including math functions, data manipulation tools (NumPy, Pandas), machine learning models (from Scikit-learn), and visualization tools (Matplotlib).

Data Preparation:

The split_dataset function splits the dataset into training and testing sets, organizing them into weekly windows. The to_series function extracts the total power consumption from each week's data and flattens it into a single series. Model Preparation:

The get_models function defines a dictionary of linear regression models including Linear Regression, Lasso, Ridge, Elastic Net, etc. The make_pipeline function constructs a data preprocessing pipeline including standardization, normalization, and the chosen model. Forecasting:

The forecast function generates a multi-step forecast recursively for each day of the week. The to_supervised function prepares the historical data into input-output pairs suitable for supervised learning. Model Evaluation:

The sklearn_predict function fits a model to historical data and generates forecasts using the pipeline. The evaluate_model function evaluates a model's performance by making forecasts on the test data and calculating RMSE scores. The evaluate_forecasts function calculates RMSE scores for each day and overall. Loading Data and Model Evaluation:

The script loads the dataset, splits it into train and test sets, and defines the number of input days for forecasting (n_input). It then evaluates each defined model using the train-test split and prints out the RMSE scores for each day of the week. Plotting:

Finally, the script plots the RMSE scores for each day of the week for all models using Matplotlib. This script provides a comprehensive framework for comparing the performance of various linear algorithms for multi-step time series forecasting and can be adapted for different datasets and model comparisons.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages