Multi-demand load prediction method based on PatchTST algorithm
The channel-independent and batch-based design of the PatchTST algorithm simplifies feature engineering and computing power configuration, solves the data quality and development cycle problems of existing load forecasting algorithms, and achieves rapid development and high-precision load forecasting, which is suitable for industry Multi-domain load forecasting tasks.
Patent Information
- Application Number
- CN202411078169.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-10-15
AI Technical Summary
Existing load forecasting algorithms have problems such as strict data quality requirements, complex feature engineering, reliance on the experience of algorithm engineers, and long development cycles, which results in difficulties in rapid batch application and implementation, and insufficient availability.
A multi-demand load forecasting method based on the PatchTST algorithm is adopted to simplify feature engineering, reduce computing power and server resource requirements through independent channel and batch design, and use low-cost consumer-grade GPUs for model training and deployment to quickly achieve load forecasting.
It achieves rapid development and low-cost deployment in different time periods, improves the accuracy and availability of load forecasting, reduces the requirements for data quality and feature engineering, and is suitable for load forecasting tasks in the industrial field.
Smart Images

Figure CN118780323A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of power or industrial forecasting, and in particular to a multi-demand load forecasting method based on a PatchTST algorithm, which has the advantages of short development cycle, low hardware cost investment and high algorithm availability. Background Art
[0002] Time series prediction is one of the most important tasks in time series analysis. Traditional machine learning algorithms require manual setting of time series features, and are particularly dependent on human experience in selecting features and data characteristics in specific fields. For example, load forecasting is significantly affected by weather changes, and weather contains data feature information collected by multiple sensors; for load forecasting, different industrial users have different industry attributes, so whether their load usage patterns are related to the season, whether they are adjusted according to industry rules, and holidays and other situations may occur. In addition to the need for manual feature setting, traditional machine learning algorithms also require a relatively long-term data collection strategy. However, there are many industrial fields, and long-term data collection and storage are difficult, and there is a shortage of feature selection engineers with professional field knowledge. Therefore, traditional machine learning methods based on complex feature engineering have a long development cycle, high investment, and high accuracy.
[0003] With the significant increase in the research of deep learning models in the field of time series forecasting. Deep models perform well not only in forecasting tasks, but also in representation learning. Representation learning can extract abstract representations and transfer them to various downstream tasks such as classification and anomaly detection to obtain state-of-the-art performance. In deep learning models, great success has been achieved in various application areas such as natural language processing (NLP) speech and recently time series, thanks to its attention mechanism that can automatically learn the connection between elements in the sequence, so it is very suitable for sequence modeling tasks. Improved models of Transformer such as Informer, Autoformer and FEDformer have been successfully applied to time series data forecasting.
[0004] As time series data, load data has certain periodicity and time correlation. Transformer-based algorithms perform well in the fields of natural language processing and computer vision. Therefore, it is feasible to use PatchTST, an improved Transformer algorithm, to predict load time series data.
[0005] PatchTST includes channel independence and Patching (batching), which contains two key designs. Channel independence can greatly reduce the workload of feature engineering, that is, different data channels exist independently. Then, in load forecasting tasks, at least only the data of one observation channel of load data needs to be trained to achieve the load forecasting task. Patching-batching is a time series forecasting that aims to understand the correlation between data in each different time step. However, a single time step does not have semantic meaning like a word in a sentence, so extracting local semantic information is crucial to analyzing their connection. Through batching, the total number of samples involved in training changes from the total data length to the data length divided by the batching step size. Greatly reduce the computing power required for training and the power resource overhead consumed by the server.
[0006] As a summary, the current load forecasting algorithm has the following three problems: 1. Strict requirements on data quality; 2. High requirements on data feature engineering, relying on the personal experience of algorithm engineers and the characteristics of different industrial segments, which is not conducive to batch and rapid algorithm application and implementation. 3. Insufficient availability. Availability combines factors such as the cost required for algorithm development and model accuracy. For example, the development cycle of traditional algorithms to achieve high accuracy is long and the cost-effectiveness is low. Summary of the invention
[0007] In order to solve the above technical problems, the present invention provides a load forecasting method based on the PatchTST algorithm, which has the characteristics of channel independence and batching, and can achieve rapid development of forecasting algorithms for different time periods, low-cost deployment, and high-precision forecasting effects.
[0008] The technical solution adopted by the present invention to solve its technical problem is: A multi-demand load forecasting method based on PatchTST algorithm includes the following steps: Step S1: Computing power configuration: including low-cost server configuration, consumer-grade GPU selection, and basic software selection and configuration to establish a low-cost, high-utilization computing power deployment plan; Step S2: Data processing: Based on the channel independence of PatchTST, data memory is reduced, and basic missing value checks and filling are performed to simplify the workload of feature engineering. Step S3: Model training: Use the advanced algorithm encapsulation library TSAI to quickly perform model training and set the required core parameters; Step S4: Model testing and analysis summary: After model training, the collected data of all sites are obtained from the database, and the load forecasting model is selected to forecast the load of each site. The forecast results are written to the database to facilitate subsequent acquisition of other business logic.
[0009] Further, the step S1 includes the following: Step S1.1. Computing hardware selection: Important recommended selection indicators: CPU: 36 cores or more are recommended, GPU: NVIDIA 4090 graphics card--24G video memory, memory: 128GB and above; Step S1.2. Basic software: GPU-related dependent software: NVIDIA CUDA software environment: GPU Driver, CUDA Toolkit, CUDA Samples.
[0010] Further, the step S2 includes the following: Step S2.1. Perform channel independence: For time series data, each column is considered as a channel to simplify feature engineering. The minimum data requirements for algorithm training are: timestamp and load data; each channel or feature is data collected by the sensor, or data obtained after feature engineering of the collected data; Step S2.2. Data batching-Patching: Use patches to extract local semantic information of time series; the number of patches is approximately equal to the length of the input data training set divided by the stride of the patch.
[0011] Furthermore, step S3 includes the following steps: Step S3.1. Environment deployment and installation; Step S3.2. Data preprocessing: specifically including steps such as feature naming, load forecasting tasks and normalization processing; Step S3.2.1. Feature naming: training load prediction model, depending on the specific number of data columns, the remaining columns and custom extracted feature columns are set by the user; Step S3.2.2. Load forecasting task: Set the step size according to actual needs, based on the sampling frequency and actual business development, for example, set the step size to 2 or 4; Step S3.2.3. Normalization: Normalize the data to between (0, 1). The data usually consists of multiple features, and these features have different measurement units and value ranges; Step S3.3. Model training: set parameters, use GPU for training, training cycle: 60 cycles or set according to the actual data training effect.
[0012] Further, the step S4 includes the following: Step S4.1. Data source: The load data set used is derived from the load data of 243 stations. The first feature of the data set is the timestamp, and the rest are the load information of the station. Then the timestamps and load data of all stations are directly spliced row by row. The spliced data still only contains the timestamp and load data; Step S4.2. Patch extraction: Based on the time series prediction of PatchTST, the data is processed by patch, and each batch of data is used as the basic unit of training; in terms of implementing patch extraction, it is specifically implemented through a sliding window method; the preprocessing code automatically extracts according to the set historical step size and future prediction step size; these features are used for subsequent model building and prediction tasks; Furthermore, by applying sliding windows to time series, for different forecasting tasks, such as forecasting different future durations, new forecasting requirements can be quickly met by modifying the future step length during future model training. This allows for rapid construction of forecasting models; the size of the sliding window can be used to adjust the forecast time range, thereby achieving short-term or long-term forecasts required by the business, significantly reducing development and deployment time.
[0013] Step S4.3. Load forecast result analysis: Select the complex load data of 243 stations during the holiday period to analyze the forecast results of the load forecast model.
[0014] The beneficial effects of the present invention are: The present invention is based on the PatchTST algorithm, which combines the advantages of both the Patch and Transformer algorithms. The algorithm used in the present invention has a short development cycle, flexible parameter settings, and agile development. It is more suitable for the industrial field, especially for situations where data quality is low and data is missing. It can achieve the optimal balance between the development investment and prediction effect of the algorithm implementation, and the development timeliness is greatly improved.
[0015] The present invention comprehensively considers different types of predicted load demands. Due to channel independence, that is, when other important features such as weather are difficult to obtain, load forecasting can still be achieved based only on load data, which helps to improve algorithm availability and better guide power dispatching or other needs for load forecasting.
[0016] After encoding the time series data based on the PatchTST algorithm, the present invention uses such an algorithm to flexibly modify the historical step size and the future prediction step size. According to the historical sampling step size, the load of the future target prediction step size is predicted, and due to the channel-independent algorithm design concept, it is possible to quickly complete multi-demand load forecasting with only timestamps and load data, which is highly available.
[0017] The present invention provides a load forecasting method based on the PatchTST algorithm for training and parameter adjustment. The historical step size and the future prediction step size can be flexibly modified. And due to the channel-independent algorithm design concept, load forecasting can be completed with only timestamps and load data, which greatly reduces the requirements for data quality. And because the channels are independent, complex feature engineering by algorithm engineers is not required.
[0018] In addition, due to batching and flexible parameter adjustment strategies, model training can be implemented on a variety of consumer-grade graphics cards, reducing deployment costs. Finally, in terms of accuracy, the actual load prediction effect is slightly lower than the algorithm of refined feature engineering in some cases, and in some cases exceeds the traditional feature engineering algorithm, achieving high availability with rapid development, low-cost deployment, and high-precision prediction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a time series channel data diagram of the present invention.
[0020] Figure 2 It is a schematic diagram of the composition of the Patch of the present invention.
[0021] Figure 3 This is the prediction effect of the low data volume model of the present invention.
[0022] Figure 4 This is the full data prediction effect of the present invention. DETAILED DESCRIPTION
[0023] The present invention takes the current public data set as an example, and the modeling process mainly includes five parts: server configuration, data processing, model building and model testing, and analysis and summary.
[0024] Step S1. Server configuration includes hardware selection and software selection.
[0025] S1.1 Hardware selection: Important recommended selection indicators: CPU: 36 cores or more are recommended; GPU: NVIDIA4090 graphics card - 24G video memory; Memory: 128GB or more; S1.2 Software Selection: GPU-related dependencies: NVIDIA CUDA software environment: GPUDriver, CUDAToolkit, CUDASamples. Deep learning SDK: CUDNN, deep learning inference engine (TensorRT), Deepstream, etc. Docker / NVIDIADocker container platform: complete deep learning framework application software image, etc.
[0026] Development software configuration: Anaconda: used for virtual environment creation, algorithm environment management, etc. VScode installation: used for code development; auxiliary operation and maintenance software: 1. Frp-intranet penetration software; 2. Supervisor-software process monitoring software; 3. Cron-timed task software; graphical remote software: 1. Sunflower; 2. Todesk; terminal management software: 1. MobaXterm-multiple ssh address management, use; 2. TMUX-terminal multiplexing software; file transfer software: Winscp.
[0027] Step S2. Data processing: Load data is treated as time series data, and data processing includes the following: 1. Timestamp processing: filling in missing values and deleting duplicate values; 2. Overall memory compression; 3. Standardization of the overall data to facilitate subsequent model training; 4. Division of the data set, etc.
[0028] Step S2.1. Channel independence: For time series data, each column is considered as a channel, so for X columns of input data, it represents X time series channel data. Time series channel data is as follows Figure 1 shown. Figure 1 (a) is the basic modeling idea of PatchTST, which divides a data into different channels, encodes and decodes each channel separately through TransformerBackbone, predicts each channel, and finally merges them into the feature channel dimension of the original input data.
[0029] Step S2.2. Data batching-Patching: Use patches to extract local semantic information of time series (multiple historical steps). The number of patches depends on the length of the input data training set and the patch step size. The step size is similar to the step size of the convolution operation of the neural network, which represents the difference in the number of time steps between the start (end) of consecutive patches.
[0030] The advantage of Patching is that the model can observe the semantics of local data within a time step interval. In addition, since the local features with a fixed step length are extracted, the amount of training data can be greatly reduced according to the step length setting. Since each patch is marked as a token, the total number of tokens can be reduced to approximately (training set length / patch step length), reducing the number of tags input to the Transformer encoder. During actual training, the patch step length S can be reasonably set according to the conditions of the server.
[0031] Step S3. Model training Step S3.1. Environment deployment: Create the environment and install darts, fastai, neuralforecast, pytorch-lightning, torchaudio, torchmetrics, torchvision, triton, tsai. Ppip install [library name] -i https: / / pypi.tuna.tsinghua.edu.cn / simple.
[0032] Test verification: 1. import torch; 2. torch.cuda.is_available(); the output is True.
[0033] Step S3.2. Data preprocessing: including feature naming, load forecasting tasks and normalization processing.
[0034] Step S3.2.1. Feature naming: Since the data column names of different sites are different and the total number of data columns is also different, training a large load forecasting model requires sample data as shown in Table 1 below.
[0035]
[0036] Among them, timestamp: uniformly named as date; site serial number: uniformly named as deviceId; load data: uniformly named as load; whether it is a holiday: uniformly named as IsHoliday.
[0037] Depending on the number of data columns, the remaining columns and custom extracted feature columns can be set by the user. In addition, no processing is required for missing values and timestamps.
[0038] Step S3.2.2. Load forecasting task: Since PatchTST can train multiple historical steps to predict multiple historical steps in the future, the step size can be set according to actual needs, generally based on the sampling frequency (interval between timestamps) and actual business development. Taking the load forecast in Table 2 below as an example, the sampling frequency is 15 minutes, so there are 96 sampling points in 24 hours. There are different forecasting tasks for actual needs, and the following table shows the actual tests. For example, a forecast step size of 48 corresponds to a forecast of 12 hours in the future; a step size of 8 corresponds to a forecast of 2 hours in the future.
[0039]
[0040] Step S3.2.3: Normalization: The present invention standardizes the data to between (0, 1). Normalization is a commonly used data preprocessing technology, which converts the data into relative proportions or numerical values within a specific range to eliminate the dimensional effects between different features, making the data easier to compare and analyze. In terms of eliminating dimensional effects, data usually consists of multiple features, and these features may have different units of measurement and value ranges. For example, some optimization algorithms (such as gradient descent) can more stably find the global optimal solution without being disturbed by differences in feature scales. In terms of accelerating convergence, for models optimized using iterative methods, such as neural networks, the range and distribution of data can affect the convergence speed of model training. By performing normalization, the convergence speed and stability of the model can be accelerated. The normalized data can better adapt to the requirements of the optimization algorithm and provide better convergence performance.
[0041] Step S3.3: Model training: Parameter settings are as follows: arch_config=dict(n_layers=3,n_heads=4,d_model=128,d_ff=256,attn_dropout=0.0, dropout=0.3,patch_len=8,stride=2,padding_patch=True,) GPU can be used for training. Training cycle: 60 cycles (reference).
[0042] Step S4: Model specific test case: The calculation rules of the actual response amount of each site in the load forecast. Since the load data is stored every 15 minutes in the load database, 96 points are one day for model training. This algorithm is based on the common future 96 time points, that is, the load forecast business of the next day. The specific historical step size and the predicted future step size can be set according to actual business needs.
[0043] Step S4.1. Data source: The load data set used in the present invention is derived from the load data of more than 243 sites. The data set is from 2023-12-10 16:45:00 to 2024-03-10 17:45:00, with a time span of 4 months; resampling is performed according to 15-minute data to obtain 1945988 data from 243 sites. The first feature of the data set is the timestamp, and the rest are the load information of the site. Part of the load data set is briefly shown in Table 3 below.
[0044]
[0045] Step S4.2. Patch extraction: Based on the time series prediction of PatchTST, the data is patched, and each batch of data is used as the basic unit of training. In terms of implementing the extraction of patches, it is specifically implemented through a sliding window method. The preprocessing code automatically extracts according to the set historical step size and future prediction step size. These features can be used for subsequent model building, classification or prediction tasks. Through the sliding window method, the time series data can be divided into input sequences and target sequences in order to build a prediction model. The size of the sliding window can be used to adjust the time range of the prediction, thereby achieving short-term or long-term predictions. Figure 2 This is a schematic diagram of Patch extraction through a sliding window.
[0046] Further, by Figure 2It can be seen that for the input data: Row×Cloumn, for the prediction task of the future S×Cloumn step length using the historical step length: N×Cloumn, the number of samples. For example, the training set generally accounts for 70%, which contains 1338788 training samples, and the number of patches is approximately: the total number of training samples / model spanning step length. Taking this article as an example, setting the stride to 2 will reduce it by half. In this case, the stride is actually 2.
[0047] Furthermore, when training data, the step size parameter is placed in the third dimension, the training data is M×Cloumn×N, and the label corresponding to the training data is: M×Cloumn×S. For the divided data, the data is divided into 70% training set, 10% validation set, and 20% test set to build a prediction model.
[0048] Further: Model comparison training test, using a single NVIDIA409024GB graphics card for training. The historical step length is 4 days to predict the next day, based on the sampling frequency of 15 minutes, that is, 384 steps to predict the next 96 steps. The historical step length is 3 days to predict the next day, based on the sampling frequency of 15 minutes, that is, 288 steps to predict the next 96 steps.
[0049] Step S4.3. Load forecast result analysis: For the selection of test data, this project uses 243 site data with a time span from 2024-04-03 0:00:00 to 2024-04-10 23:45:00. Since the test data includes statutory holidays, the prediction difficulty of the model is relatively high, which can better test the performance of the model.
[0050] Further: In order to effectively verify the results of the model, this chapter uses LSTM model, regression model and PatchTST for comparative analysis, and uses MAE (refer to Table 4) and effective MAPE (average relative proportional error of power values greater than 100KW) of the data for measurement analysis. The load forecast results for the next day are shown in Table 5.
[0051]
[0052]
[0053] Figure 3 and Figure 4 This is a test result diagram drawn according to 4 random stations, where Figure 3 The selected model was trained with only 6 months of cumulative data, and the overall MAE was 81.6 (mean absolute error, reflecting the absolute value of the deviation between the prediction and the actual load). Figure 4The model used is full data, but its MAE is only 80.9, which reflects PatchTST's low dependence on data volume and high availability. By predicting the user's load, the actual load situation of the next day can be effectively obtained.
Claims
1. A multi-demand load forecasting method based on PatchTST algorithm, characterized in that: The steps include: Step S1: Computing power configuration: including low-cost server configuration, consumer-grade GPU selection, and basic software selection and configuration to establish a low-cost, high-utilization computing power deployment plan; Step S2: Data processing: Based on the channel independence of PatchTST, data memory is reduced, and basic missing value checks and filling are performed to simplify the workload of feature engineering. Step S3: Model training: Use the advanced algorithm encapsulation library TSAI to quickly perform model training and set the required core parameters; Step S4: Model testing and analysis summary: After model training, the collected data of all sites are obtained from the database, and the load forecasting model is selected to forecast the load of each site. The forecast results are written to the database to facilitate subsequent acquisition of other business logic.
2. The multi-demand load forecasting method based on PatchTST algorithm according to claim 1 is characterized in that: The step S1 includes the following: step S1.
1. Computing power hardware selection: important recommended selection indicators: CPU: 36 cores or more are recommended, GPU: NVIDIA 4090 graphics card--24G video memory, memory: 128GB and above; step S1.
2. Basic software: GPU-related dependent software: NVIDIA CUDA software environment: GPU Driver, CUDA Toolkit, CUDA Samples.
3. The multi-demand load forecasting method based on PatchTST algorithm according to claim 1 is characterized in that: The step S2 comprises the following: Step S2.
1. Perform channel independence: For time series data, each column is considered as a channel to simplify feature engineering. The minimum data requirements for algorithm training are: timestamp and load data; each channel or feature is data collected by the sensor, or data obtained after feature engineering of the collected data; Step S2.
2. Data batching-Patching: Use patches to extract local semantic information of time series; the number of patches is approximately equal to the length of the input data training set divided by the stride of the patch.
4. The multi-demand load forecasting method based on PatchTST algorithm according to claim 1 is characterized in that: The step S3 comprises the following steps: Step S3.
1. Environment deployment and installation Step S3.
2. Data preprocessing: specifically including steps such as feature naming, load forecasting tasks and normalization processing; Step S3.2.
1. Feature naming: training load prediction model, depending on the specific number of data columns, the remaining columns and custom extracted feature columns are set by the user; Step S3.2.
2. Load forecasting task: Set the step size according to actual needs, based on the sampling frequency and actual business development, for example, set the step size to 2 or 4; Step S3.2.
3. Normalization: Normalize the data to between (0, 1). The data usually consists of multiple features, and these features have different measurement units and value ranges; Step S3.
3. Model training: set parameters, use GPU for training, training cycle: 60 cycles or set according to the actual data training effect.
5. The multi-demand load forecasting method based on PatchTST algorithm according to claim 1 is characterized in that: The step S4 comprises the following: Step S4.
1. Data source: The load data set used is derived from the load data of 243 stations. The first feature of the data set is the timestamp, and the rest are the load information of the station. Then the timestamps and load data of all stations are directly spliced row by row. The spliced data still only contains the timestamp and load data; Step S4.
2. Patch extraction: Based on the time series prediction of PatchTST, the data is processed by patch, and each batch of data is used as the basic unit of training; in terms of implementing patch extraction, it is specifically implemented through a sliding window method; the preprocessing code automatically extracts according to the set historical step size and future prediction step size; these features are used for subsequent model building and prediction tasks; Step S4.
3. Load forecast result analysis: Select the complex load data of 243 stations during the holiday period to analyze the forecast results of the load forecast model.
6. A multi-demand load forecasting method based on PatchTST algorithm according to claim 5, characterized in that: In step S4.3, by applying the sliding window to the time series, for different prediction tasks, such as predicting different time periods in the future, the new prediction requirements can be quickly realized by modifying the future step length when training the future model, so as to quickly build a prediction model; the size of the sliding window can be used to adjust the time range of the prediction, thereby realizing short-term or long-term predictions required by the business, greatly reducing development and deployment time.
Citation Information
Cited By
Power load prediction method, device, equipment, medium and program product
CN119154288A
Resource index prediction method and device based on Transform framework and medium
CN119537043A
Power load cold start prediction method and system based on pre-training-fine tuning
CN119740697A
A method and system for predicting cold start of electric load based on pre-training and fine-tuning
CN119740697B
