Enterprise load-oriented incremental multi-step time series prediction method
By using an incremental multi-step time-series forecasting method, the problems of insufficient load forecasting accuracy and lagging model updates in existing technologies are solved, achieving efficient enterprise load forecasting, supporting the integration of lightweight databases, improving the timeliness and accuracy of forecasts, and reducing implementation costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINGHE ARTIFICIAL INTELLIGENCE TECHNOLOGY (JIAXING) CO LTD
- Filing Date
- 2025-11-05
- Publication Date
- 2026-06-09
Smart Images

Figure CN121434968B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power system operation and energy management technology, and more specifically, to an incremental multi-step time-series forecasting method for enterprise load. Background Technology
[0002] Enterprise power load forecasting is one of the key technologies for power system operation and energy management. Its accuracy and timeliness are of great significance for the stable operation of the power system and the energy management of enterprises. Traditional load forecasting methods mainly rely on statistical analysis of historical data and simple mathematical models, which have shown some effectiveness in handling linear relationships and short-term trends. However, with the increasing complexity of enterprise production activities and the enhanced uncertainty of external environmental factors (such as weather conditions), load sequences exhibit significant nonlinear, non-stationary, and multi-periodic characteristics, which limits the forecasting accuracy and adaptability of traditional methods.
[0003] In recent years, with the development of machine learning and deep learning technologies, several data-driven forecasting models have been proposed for load forecasting. These models, by learning complex patterns in historical data, are better able to handle nonlinear and non-stationary problems. However, these methods still face some challenges in practical applications. For example, model training typically requires a large amount of historical data, and when faced with new data, model updates lag, leading to the accumulation of prediction errors. Furthermore, existing methods often do not adequately consider efficient integration with real-world industrial data systems (such as relational databases) and automated closed-loop update mechanisms, limiting their effectiveness in practical engineering applications.
[0004] In implementing the embodiments of the present invention, the prior art has at least the following problems or defects: the existing methods are not accurate enough when dealing with nonlinear and non-stationary data, and are difficult to adapt to concept drift in the data; although some machine learning-based prediction models have improved prediction accuracy to a certain extent, they often require a large amount of historical data for training, and the model updates lag when facing new data, resulting in the accumulation of prediction errors; the prior art has not fully considered the efficient integration and automated closed-loop update mechanism with actual industrial data systems, which limits its application effect in actual engineering. Summary of the Invention
[0005] This invention provides an incremental multi-step time-series forecasting method for enterprise load, comprising:
[0006] Historical records containing time fields, total enterprise power, and multiple meteorological features are read from a relational database. The historical records are then parsed for time, sorted by time, and missing values are handled. Feature columns with zero variance are removed.
[0007] A normalizer is used to jointly normalize the features and target variables in the processed historical records, and the normalizer is persistently saved; a supervised learning dataset is constructed using a historical time series of a first set duration as the input window and a future time series of a second set duration as the output window;
[0008] A deep learning model comprising a shared feature encoder, an attention fusion layer, and a multi-task output layer is constructed. The deep learning model is trained using the supervised learning dataset to obtain a trained model that can directly output multi-step prediction results. The shared feature encoder is used to extract deep spatiotemporal features of the input sequence, the attention fusion layer is used to generate a context vector reflecting key historical information, and the multi-task output layer is used to simultaneously output the predicted values of load power and the classification probabilities of load state in the future multi-step process.
[0009] When a saved model file and its corresponding normalizer file are detected, incremental training is performed on the trained model based on the latest data of the third set duration to update the model parameters. The number of training rounds in the incremental training is controlled within a preset number of rounds and a learning rate lower than that in the initial training phase is used.
[0010] Using the input window data before the target time point, the updated model directly outputs the prediction results for multiple future steps, and the persistently saved normalizer is used to perform denormalization processing on the prediction results to restore the physical quantity values.
[0011] The inverse normalized prediction results and their corresponding timestamps are written into the specified prediction result table in the database using an insert or update operation based on the unique constraints of the timestamps, and the prediction generation time or batch identifier is recorded in the prediction result table.
[0012] Furthermore, the duration of the input window is 48 hours, and the duration of the output window is 24 hours.
[0013] Furthermore, the meteorological characteristics include shortwave radiation, diffuse radiation, air temperature, saturated vapor pressure difference, wind direction, and wind speed. The historical records also include a flag field indicating whether the enterprise is on a rest day.
[0014] Furthermore, the deep learning model includes:
[0015] The shared feature encoder consists of two layers of Long Short-Term Memory (LSTM) networks. The first LSTM layer receives the input window data and outputs the sequence of all time steps, while the second LSTM layer receives the sequence output by the first LSTM layer and outputs the hidden state of the final time step.
[0016] The attention fusion layer receives all time step sequences output by the first LSTM layer and the final hidden state output by the second LSTM layer, performs attention weighting calculation on all time step sequences, and generates a context vector.
[0017] The multi-task output layer includes a main task regression branch and an auxiliary task classification branch;
[0018] The main task regression branch receives the context vector and sequentially passes through a first fully connected layer with 16 units and a first linear output layer using the ReLU activation function to calculate and output the regression prediction value of future multi-step load power.
[0019] The auxiliary task classification branch receives the final hidden state output by the second LSTM layer, and sequentially passes it through a second fully connected layer with 8 units and a Sigmoid output layer to calculate and output the classification probability of future multi-step load states.
[0020] The deep learning model is trained using a joint loss function.
[0021] Furthermore, the first LSTM layer has 64 cells, and the second LSTM layer has 32 cells.
[0022] Furthermore, the attention fusion layer generates the context vector by calculating the attention weights of each time step in the sequence of all time steps and the final hidden state, and then performing a weighted summation of the sequence of all time steps.
[0023] Furthermore, the regression prediction value output by the main task regression branch is a load power prediction vector of length 24; the classification probability output by the auxiliary task classification branch is a vector of length 24, representing the probability that the load exceeds a preset threshold at each time point in the next 24 hours.
[0024] Furthermore, the joint loss function is a weighted sum of the mean squared error of the regression loss of the main task and the binary cross-entropy of the classification loss of the auxiliary task;
[0025] The formula for calculating the joint loss function L is as follows: ;in, and is the weighting coefficient, MSE represents the mean squared error, and BCE represents the binary cross-entropy.
[0026] Furthermore, the incremental training step uses data from the most recent N days to fine-tune the model, where N is a positive integer, and the preset number of rounds does not exceed 20 rounds.
[0027] Furthermore, the relational database is an SQLite database, and the insert or update operation is specifically a UPSERT operation; the method also includes the steps of: adding a true value field to the prediction result table or establishing a comparison table, automatically calculating the prediction error index when the true load value is reached, and automatically triggering additional incremental training or model hyperparameter adjustment if the error exceeds a set threshold.
[0028] The embodiments of the present invention have at least the following beneficial effects:
[0029] 1. By introducing an incremental training mechanism, the model can be quickly fine-tuned using newly arrived data, improving its adaptability to concept drift. This effectively solves the problem of lagging model updates in existing technologies, enabling the prediction model to better adapt to dynamic changes in data and improving the timeliness and accuracy of predictions.
[0030] 2. By adopting a direct multi-step prediction output structure, the problem of gradual error accumulation in recursive prediction is avoided, the accuracy of medium- and long-term prediction is improved, and the error accumulation problem caused by recursive prediction in existing technologies is solved. This provides enterprises with more reliable medium- and long-term load forecast results, which helps enterprises to better manage energy and arrange production plans.
[0031] 3. It achieves full automation of the entire process from data reading, preprocessing, model training and updating to result storage, especially supporting efficient integration with lightweight databases (such as SQLite). It has strong engineering practicality and scalability, solves the problem of high difficulty in system engineering integration in existing technologies, reduces the cost and complexity of enterprises implementing load forecasting systems, and improves the availability and ease of use of the system.
[0032] 4. By using a deep learning model that includes an attention fusion layer, it can dynamically focus on the most critical moments in the historical sequence for predicting the future (such as yesterday's peak or the start of a specific working condition), generating more informative context vectors, effectively improving prediction accuracy and enhancing the ability to predict peak loads.
[0033] 5. By employing a multi-task output layer that includes a main task regression branch and an auxiliary task classification branch, and using a joint loss function for training, the auxiliary classification task plays a regularizing role on the shared feature encoder, forcing the model to learn more generalizable feature representations, thus making it more stable when facing data noise or distribution changes. Attached Figure Description
[0034] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated in the drawings by way of example and not limitation, wherein:
[0035] Figure 1 This is a flowchart illustrating an incremental multi-step time-series forecasting method for enterprise load provided in an embodiment of the present invention.
[0036] Figure 2 This is a schematic diagram of a deep learning model structure provided in an embodiment of the present invention;
[0037] Figure 3 This is a schematic diagram of a data table structure provided in an embodiment of the present invention. Detailed Implementation
[0038] The principles and spirit of the invention will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are provided merely to enable those skilled in the art to better understand and implement the invention, and are not intended to limit the scope of the invention in any way. Rather, these embodiments are provided to make the invention more thorough and complete, and to fully convey the scope of the invention to those skilled in the art.
[0039] It should be noted that the number of any elements in the accompanying drawings is for illustrative purposes only and not as a limitation, and any naming is for distinction only and has no limiting meaning.
[0040] The following is for reference. Figure 1 , Figure 1 This is a flowchart illustrating an incremental multi-step time-series forecasting method for enterprise load provided in an embodiment of the present invention. Figure 1 As shown, an incremental multi-step time-series forecasting method for enterprise load includes:
[0041] Historical records containing time fields, total enterprise power, and multiple meteorological features are read from a relational database. The historical records are then parsed for time, sorted by time, and missing values are handled. Feature columns with zero variance are removed.
[0042] A normalizer is used to jointly normalize the features and target variables in the processed historical records, and the normalizer is persistently saved; a supervised learning dataset is constructed using a historical time series of a first set duration as the input window and a future time series of a second set duration as the output window;
[0043] A deep learning model comprising a shared feature encoder, an attention fusion layer, and a multi-task output layer is constructed. The deep learning model is trained using the supervised learning dataset to obtain a trained model that can directly output multi-step prediction results. The shared feature encoder is used to extract deep spatiotemporal features of the input sequence, the attention fusion layer is used to generate a context vector reflecting key historical information, and the multi-task output layer is used to simultaneously output the predicted values of load power and the classification probabilities of load state in the future multi-step process.
[0044] When a saved model file and its corresponding normalizer file are detected, incremental training is performed on the trained model based on the latest data of the third set duration to update the model parameters. The number of training rounds in the incremental training is controlled within a preset number of rounds and a learning rate lower than that in the initial training phase is used.
[0045] Using the input window data before the target time point, the updated model directly outputs the prediction results for multiple future steps, and the persistently saved normalizer is used to perform denormalization processing on the prediction results to restore the physical quantity values.
[0046] The inverse normalized prediction results and their corresponding timestamps are written into the specified prediction result table in the database using an insert or update operation based on the unique constraints of the timestamps, and the prediction generation time or batch identifier is recorded in the prediction result table.
[0047] It should be noted that the incremental multi-step time-series forecasting method for enterprise load provided by this invention aims to solve problems such as model update lag, error accumulation, and difficulty in system engineering integration in existing technologies. In the data access and cleaning steps, historical records containing time fields, total enterprise power, and one or more meteorological characteristics are read from a relational database, and these records undergo time parsing, sorting, and missing value processing. Here, the relational database refers to a database based on a relational model, capable of storing and managing structured data such as total enterprise power and meteorological characteristics. These steps ensure the quality and consistency of the input data, providing a reliable data foundation for subsequent forecasting model training.
[0048] Specifically, in the data normalization and supervised dataset construction steps, the features and target variables in the processed data are jointly normalized. A supervised learning dataset is constructed using a historical time series of a first predetermined duration as the input window and a future time series of a second predetermined duration as the output window. Here, the first and second predetermined durations refer to the lengths of the input and output time windows used to define the time windows when constructing the supervised learning dataset. For example, the input window can be set to 48 hours, and the output window can be set to 24 hours. Normalization scales the data to a specific range, such as 0 to 1, to improve the efficiency and stability of model training. In this way, historical data can be converted into a format that the model can understand and process, laying the foundation for the neural network modeling and training steps.
[0049] Preferably, in the neural network modeling and training steps, a deep learning model is constructed that includes a shared feature encoder, an attention fusion layer, and a multi-task output layer. The shared feature encoder consists of two layers of Long Short-Term Memory (LSTM) networks. The first LSTM layer receives the input window data and outputs the sequence of all time steps, while the second LSTM layer receives the sequence output by the first LSTM layer and outputs the hidden state of the final time step. The attention fusion layer performs weighted calculations on the sequence of all time steps output by the first LSTM layer to generate a context vector reflecting key historical information. The multi-task output layer includes a main task regression branch and an auxiliary task classification branch. The main task regression branch is used to calculate the regression prediction value of the load power in the future multi-step process, while the auxiliary task classification branch is used to calculate the classification probability of the load state in the future multi-step process. Training is performed using a joint loss function, which is a weighted sum of the mean squared error of the main task regression loss and the binary cross-entropy of the auxiliary task classification loss. This method not only directly outputs multi-step prediction results but also improves the model's generalization ability and prediction accuracy through a multi-task learning framework.
[0050] In some embodiments, the duration of the input window is 48 hours, and the duration of the output window is 24 hours.
[0051] It should be noted that the input window duration mentioned in this invention is 48 hours, and the output window duration is 24 hours. This setting is the result of optimization based on the actual needs and data characteristics of enterprise load forecasting. The input window refers to the historical data time range used for model training, while the output window refers to the future time range that the model needs to predict. By setting the input window to 48 hours, it can be ensured that the model can fully learn sufficient historical information, thereby better capturing the patterns and trends of load changes. Setting the output window to 24 hours is to meet the actual needs of enterprises in short- to medium-term load forecasting, so that enterprises can make corresponding energy management and production planning arrangements in advance.
[0052] Specifically, the duration of the input and output windows is determined based on the periodicity and variation characteristics of the enterprise's load data. A 48-hour input window means the model will use data from the past 48 hours as input features, including variations in enterprise load across different time periods, such as daytime and nighttime load differences, and load changes between weekdays and weekends. A 24-hour output window indicates the model will predict load conditions for the next 24 hours, which is of significant reference value for the enterprise's daily operations and energy scheduling. In practical applications, these two parameters can be adjusted according to the specific needs and data characteristics of the enterprise, but settings of 48 hours and 24 hours generally provide satisfactory predictive results.
[0053] Preferably, when constructing the supervised learning dataset, historical data can be divided into multiple training samples based on the duration of the input and output windows. For example, for each 48-hour historical data segment, the model will learn how to predict the load situation for the next 24 hours. During model training, the model parameters are adjusted to better fit these training samples, thereby improving prediction accuracy. Furthermore, to further optimize model performance, a validation set can be introduced during training to evaluate the model's generalization ability, and the model can be adjusted based on the validation results. This time-window-based supervised learning method effectively utilizes historical data and improves the model's ability to predict load changes.
[0054] In some embodiments, the meteorological features include shortwave radiation, diffuse radiation, air temperature, saturated vapor pressure difference, wind direction, and wind speed. The historical records also include a flag field indicating whether the enterprise is on a rest day.
[0055] It should be noted that the meteorological characteristics mentioned in this invention include shortwave radiation, diffuse radiation, air temperature, saturated vapor pressure difference, wind direction, and wind speed. The historical records also include a flag field indicating whether it is a rest day for the enterprise. These meteorological characteristics are important external factors affecting enterprise load changes. By incorporating these characteristics into the model input, the patterns of load changes can be captured more comprehensively. The flag field refers to a specific data field used to identify whether it is a rest day for the enterprise; this field is crucial for distinguishing load differences between weekdays and rest days.
[0056] Specifically, shortwave radiation and diffuse radiation in meteorological characteristics refer to two forms of solar radiation propagation in the atmosphere, which directly affect the energy consumption of enterprises, especially those with solar energy utilization facilities. Meteorological conditions such as temperature, saturated vapor pressure difference, wind direction, and wind speed also affect the enterprise's load; for example, temperature affects the frequency of use of air conditioning or heating systems. The flag field indicating whether it is a rest day is a binary field, typically using 1 to represent a rest day and 0 to represent a work day. This field helps the model distinguish load changes under different working conditions. When building the model, these meteorological characteristics and flag fields are used as input variables, along with the enterprise's total power, for training and prediction.
[0057] Preferably, during the data processing stage, these meteorological features can be preprocessed, for example, by normalizing continuous variables such as temperature and vapor pressure difference to improve model training efficiency and prediction accuracy. For directional features such as wind direction and speed, they can be converted into a format easier for the model to process, such as converting wind direction into an angle or decomposing it into east-west and north-south components. Furthermore, during model training, feature importance analysis can be used to evaluate the contribution of these meteorological features to enterprise load forecasting, thereby further optimizing the model's input feature set. This method, which comprehensively considers meteorological features and the enterprise rest day flag field, can significantly improve the accuracy and reliability of load forecasting.
[0058] In some embodiments, such as Figure 2 As shown, the deep learning model includes:
[0059] The shared feature encoder consists of two layers of Long Short-Term Memory (LSTM) networks. The first LSTM layer receives the input window data and outputs the sequence of all time steps, while the second LSTM layer receives the sequence output by the first LSTM layer and outputs the hidden state of the final time step.
[0060] The attention fusion layer receives all time step sequences output by the first LSTM layer and the final hidden state output by the second LSTM layer, performs attention weighting calculation on all time step sequences, and generates a context vector.
[0061] The multi-task output layer includes a main task regression branch and an auxiliary task classification branch;
[0062] The main task regression branch receives the context vector and sequentially passes through a first fully connected layer with 16 units and a first linear output layer using the ReLU activation function to calculate and output the regression prediction value of future multi-step load power.
[0063] The auxiliary task classification branch receives the final hidden state output by the second LSTM layer, and sequentially passes it through a second fully connected layer with 8 units and a Sigmoid output layer to calculate and output the classification probability of future multi-step load states.
[0064] The deep learning model is trained using a joint loss function.
[0065] It should be noted that the deep learning model mentioned in this invention includes a shared feature encoder, an attention fusion layer, and a multi-task output layer. These components work together to achieve multi-step prediction of enterprise load. The shared feature encoder is used to extract deep spatiotemporal features from the input sequence, the attention fusion layer is used to generate context vectors reflecting key historical information, and the multi-task output layer is used to simultaneously output predicted load power values and classification probabilities for future multi-step load states. This model structure design aims to fully utilize information from historical data and improve the accuracy and stability of predictions through multi-task learning.
[0066] Specifically, the shared feature encoder consists of two layers of Long Short-Term Memory (LSTM) networks. The first LSTM layer receives the input window data and outputs the sequence of all time steps. The second LSTM layer receives the sequence output by the first LSTM layer and outputs the hidden state of the final time step. Here, the input window data refers to preprocessed and normalized historical load data and meteorological feature data, and the time step refers to the position of the data in the time series. For example... Figure 3 As shown, the output sequence of the first LSTM layer contains the feature representation of each time step, while the hidden state of the second LSTM layer captures the long-term dependencies of the entire input sequence. The attention fusion layer receives all time step sequences from the first LSTM layer and the final hidden state of the second LSTM layer, weights the sequences through an attention mechanism, and generates a context vector that highlights the most valuable historical information for prediction. The multi-task output layer includes a main task regression branch and an auxiliary task classification branch. The main task regression branch is used to predict the load power in the next few steps, and the auxiliary task classification branch is used to predict the classification probability of the load state in the next few steps. This multi-task learning approach can improve the model's generalization ability.
[0067] Preferably, each component can be configured and optimized in detail when constructing the deep learning model. For example, the first LSTM layer can be set to 64 units, and the second LSTM layer can be set to 32 units. These unit numbers are determined based on experiments and experience to balance model complexity and prediction performance. In the attention fusion layer, the context vector is generated by calculating the attention weights between each time step and the final hidden state and then weighting and summing all time step sequences. In the multi-task output layer, the main task regression branch can include a fully connected layer with 16 units, using the ReLU activation function, followed by a linear output layer to output the predicted values of the load power in the future multi-step process; the auxiliary task classification branch can include a fully connected layer with 8 units, using the ReLU activation function, followed by a sigmoid output layer to output the classification probabilities of the load states in the future multi-step process. The joint loss function is a weighted sum of the mean squared error (MSE) of the main task regression loss and the binary cross-entropy (BCE) of the auxiliary task classification loss. By adjusting the weight coefficients α and β, the losses of the two tasks can be balanced, thereby achieving joint optimization of the model. This detailed model building and optimization process ensures that the model is efficient and accurate when handling enterprise load forecasting tasks.
[0068] In some embodiments, the first LSTM layer has 64 cells and the second LSTM layer has 32 cells.
[0069] It should be noted that the first LSTM layer mentioned in this invention has 64 units, and the second LSTM layer has 32 units. These parameters are set based on considerations of balancing model performance and computational resources. LSTM (Long Short-Term Memory) networks are a special type of recurrent neural network (RNN) capable of effectively handling long-term dependencies in time-series data. The number of units, or neurons, determines the complexity and richness of features that each LSTM layer can learn. The 64 units in the first LSTM layer mean that it can capture relatively rich feature information from the input sequence, while the 32 units in the second LSTM layer further extract features while reducing computational load, allowing the model to operate more efficiently while maintaining high prediction accuracy.
[0070] Specifically, the first LSTM layer receives input window data, which refers to preprocessed and normalized historical load data and meteorological characteristic data, arranged in time series. The 64 units of the first LSTM layer process the data at each time step and output sequence features for all time steps. These sequence features contain the feature representations of the input data at each time step, providing rich information for subsequent processing. The second LSTM layer receives the sequence features output from the first LSTM layer and outputs the hidden state for the final time step. The 32 units of the second LSTM layer further extract features, and the final output hidden state contains long-term dependency information of the entire input sequence, which is crucial for subsequent prediction tasks. In model construction, the number of units in the LSTM layer is an important hyperparameter and needs to be adjusted according to the specific dataset and task. The unit count settings of 64 and 32 have been experimentally verified and achieve a good balance between model complexity and prediction performance.
[0071] Preferably, the number of units in the LSTM layer can be further optimized when building the deep learning model. For example, the optimal number of units can be determined through methods such as cross-validation. During model training, experiments can be conducted using different combinations of unit numbers to find the configuration best suited for the current dataset and prediction task. In addition to the number of units, other hyperparameters, such as the learning rate and batch size, can be adjusted to further improve model performance. In practical applications, the number of units in the LSTM layer can be fine-tuned according to the specific needs and data characteristics of the enterprise to ensure that the model achieves optimal performance when predicting enterprise load. This detailed configuration and optimization process of the number of units in the LSTM layer ensures that the model is efficient and accurate in handling enterprise load prediction tasks.
[0072] In some embodiments, the attention fusion layer generates the context vector by calculating the attention weights of each time step in the sequence of all time steps and the final hidden state, and then performing a weighted summation of the sequence of all time steps.
[0073] It should be noted that the attention fusion layer mentioned in this invention generates a context vector by calculating the attention weights of each time step in the time-step sequence with respect to the final hidden state, and then summing the weighted sums of all time-step sequences. Here, the attention weights represent the quantitative representation of the importance of different time steps when the model processes time-series data. The attention mechanism allows the model to dynamically focus on the historical information most valuable for prediction, thereby improving the accuracy and stability of predictions. The context vector, obtained by summing the weighted time-step sequences, contains key information from the historical data, providing important feature representations for subsequent prediction tasks.
[0074] Specifically, the attention fusion layer receives the sequence of all time steps from the output of the first LSTM layer and the final hidden state from the output of the second LSTM layer. The sequence output of the first LSTM layer contains the feature representation of each time step, while the final hidden state of the second LSTM layer captures the long-term dependencies of the entire input sequence. Attention weights are obtained by calculating the similarity or correlation between the feature representation of each time step and the final hidden state, typically using dot products, scaled dot products, or other similarity metrics. The weighted summation process multiplies the feature representation of each time step by its corresponding attention weight, and then sums the results for all time steps to generate a context vector. This context vector highlights the most valuable historical information for prediction, providing important feature representations for subsequent prediction tasks.
[0075] Preferably, a scaled dot product attention mechanism can be used when implementing the attention fusion layer. Specifically, first, the dot product between the feature representation and the final hidden state at each time step is calculated, and then scaled using a scaling factor, typically the square root of the feature dimension, to prevent gradient vanishing or exploding. Next, a softmax function is applied to the scaled dot product result to obtain the attention weights for each time step. These weights reflect the importance of each time step in the prediction. Finally, the feature representation at each time step is multiplied by its corresponding attention weight, and the results for all time steps are summed to generate a context vector. This attention mechanism allows the model to focus more on the historical information most valuable for prediction, thereby improving the accuracy and stability of the prediction.
[0076] In some embodiments, the regression prediction value output by the main task regression branch is a load power prediction vector of length 24; the classification probability output by the auxiliary task classification branch is a vector of length 24, representing the probability that the load exceeds a preset threshold at each time point in the next 24 hours.
[0077] It should be noted that the regression prediction value output by the main task regression branch mentioned in this invention is a load power prediction vector of length 24, and the classification probability output by the auxiliary task classification branch is a vector of length 24, representing the probability that the load exceeds a preset threshold at each time point within the next 24 hours. Here, the regression prediction value refers to the load power value predicted by the model for the next 24 hours, while the classification probability refers to the probability that the load exceeds the preset threshold at each time point within the next 24 hours. This multi-task output structure enables the model to simultaneously provide specific numerical predictions of load power and classification predictions of load status, thereby providing enterprises with more comprehensive decision support.
[0078] Specifically, the main task regression branch receives the context vector generated by the attention fusion layer. It then uses a fully connected layer with 16 units and a linear output layer to calculate and output the predicted load power for the next 24 hours. This context vector, generated by the attention fusion layer, contains key information from historical data, helping the model to make better predictions. The auxiliary task classification branch receives the final hidden state output from the second LSTM layer. It uses an 8-unit fully connected layer and a sigmoid output layer to calculate and output the probability that the load exceeds a preset threshold at each time point within the next 24 hours. This final hidden state, output from the second LSTM layer, contains long-term dependency information for the entire input sequence. The preset threshold is set based on the company's actual needs and historical data, used to distinguish between normal and abnormal load conditions.
[0079] Preferably, when constructing the main task regression branch, the number of units in the fully connected layer can be adjusted to optimize model performance. For example, the optimal number of units can be determined through methods such as cross-validation. In the auxiliary task classification branch, the sigmoid output layer maps the output value at each time point to a range of 0 to 1, representing the probability that the load at that time point exceeds a preset threshold. This probability output can help enterprises prepare in advance, such as adjusting production plans or increasing energy supply when a high load probability is predicted. In practical applications, the preset threshold can be adjusted according to the specific needs and data characteristics of the enterprise to ensure that the model's output better meets the enterprise's decision-making needs.
[0080] In some embodiments, the joint loss function is a weighted sum of the mean squared error of the regression loss of the main task and the binary cross-entropy of the classification loss of the auxiliary task;
[0081] The formula for calculating the joint loss function L is as follows: ;in, and is the weighting coefficient, MSE represents the mean squared error, and BCE represents the binary cross-entropy.
[0082] It should be noted that the joint loss function mentioned in this invention is a weighted sum of the mean squared error (MSE) of the primary task regression loss and the binary cross-entropy (BCE) of the auxiliary task classification loss. This joint loss function is designed to improve the model's generalization ability and prediction accuracy by simultaneously optimizing both the primary task (load power prediction) and the auxiliary task (load state classification). In this way, the model can not only predict specific load power values but also classify load states, thereby providing enterprises with more comprehensive decision support.
[0083] Specifically, the mean squared error (MSE) in the joint loss function is a commonly used metric to measure the difference between the predicted and true values in the primary task regression. It calculates the average of the squared differences between the predicted and true values. The binary cross-entropy (BCE) measures the difference between the predicted probability and the true label in the auxiliary task classification. It is applicable to binary classification problems and calculates the log loss between the predicted probability and the true label. The weighting coefficients α and β are used to balance the losses of the two tasks. By adjusting these weights, the relative importance of the primary and auxiliary tasks during model training can be controlled. During model training, by minimizing the joint loss function, the model can simultaneously learn the feature representations of load power prediction and load state classification.
[0084] Preferably, when constructing the joint loss function, the optimal values of the weight coefficients α and β can be determined experimentally. For example, cross-validation and other methods can be used to evaluate the model performance under different weight combinations, thereby finding the weight configuration most suitable for the current dataset and prediction task. During model training, optimization algorithms, such as gradient descent, can be used to minimize the joint loss function. Specifically, by calculating the gradient of the joint loss function with respect to the model parameters and updating the model parameters based on these gradients, the model performance is gradually optimized. This joint optimization approach enables the model to simultaneously ensure accurate prediction of load power and accurate classification of load status when handling enterprise load forecasting tasks, thereby improving the overall performance and practicality of the model.
[0085] In some embodiments, the incremental training step uses data from the most recent N days to fine-tune the model, where N is a positive integer, and the preset number of rounds does not exceed 20 rounds.
[0086] It should be noted that the incremental training step mentioned in this invention uses data from the most recent N days for model fine-tuning, where N is a positive integer, and the preset number of rounds does not exceed 20. Incremental training is a model update mechanism designed to fine-tune a trained model using new data to adapt to concept drift in the data, thereby improving the model's adaptability to new data and its prediction accuracy. Here, the N days of data refers to data from the most recent time period used for incremental training, and the preset number of rounds refers to the maximum number of iterations the model can undergo during incremental training, used to control the complexity and time cost of training.
[0087] Specifically, the data from the most recent N days mentioned in the incremental training step refers to historical data from the current point in time back N days. This data contains the latest load information and related features, reflecting recent load change trends. The specific value of N can be determined based on the data update frequency and the model's adaptability requirements. For example, if the data updates quickly, N can be set smaller; if the data updates slowly, N can be appropriately increased. The preset number of epochs refers to the maximum number of iterations the model will undergo during incremental training. This parameter controls the training complexity and time cost. For example, if the preset number of epochs is set to 20, the model will perform a maximum of 20 iterations during incremental training. This parameter setting needs to balance model update efficiency and computational resources.
[0088] Preferably, during the incremental training step, the value of N and the preset number of epochs can be further optimized. For example, the most suitable value of N for the current data characteristics and model requirements can be determined experimentally. During incremental training, an early stopping mechanism can be used to avoid overfitting; that is, the loss on the validation set is monitored during training, and training is stopped early if the loss does not decrease significantly over several consecutive iterations. Furthermore, to further improve the model's adaptability, a lower learning rate can be used in incremental training. This ensures that the model is more stable during updates and avoids performance degradation due to an excessively high learning rate. Through these optimization measures, the incremental training step can effectively improve the model's adaptability to new data while maintaining model stability and prediction accuracy.
[0089] In some embodiments, the relational database is an SQLite database, and the insert or update operation is specifically a UPSERT operation; the method further includes the steps of: adding a true value field to the prediction result table or establishing a comparison table, automatically calculating the prediction error index when the true load value is reached, and automatically triggering additional incremental training or model hyperparameter adjustment if the error exceeds a set threshold.
[0090] It should be noted that the relational database mentioned in this invention is an SQLite database, and the insert or update operation is specifically a UPSERT operation. SQLite is a lightweight database widely used in scenarios requiring simple and efficient data storage and management. The UPSERT operation is a database operation used to perform an update operation instead of reporting an error when a primary key or unique constraint conflict is found during the insertion of new data. This operation method is very useful when processing prediction results because it ensures that the data in the database is always up-to-date while avoiding data duplication.
[0091] Specifically, SQLite is a self-contained, serverless database management system that stores all data in a single disk file, making it suitable for embedded systems and small applications. In this invention, using SQLite to store historical data and prediction results simplifies the system architecture and reduces maintenance costs. The UPSERT operation is a special operation supported by SQLite, combining the functionality of INSERT and UPDATE operations. In the prediction result insertion step, the UPSERT operation ensures that if a record with the same timestamp already exists in the prediction results table, the new prediction result will overwrite the old record; if there is no conflict, the new record is directly inserted. This operation method guarantees the uniqueness and timeliness of the prediction results, avoiding data redundancy and errors.
[0092] Preferably, the use of the UPSERT operation can be further optimized when implementing the step of storing the prediction results. For example, a true value field can be added to the prediction results table or a comparison table can be created. When the true load value is reached, the system can automatically calculate prediction error indicators, such as mean absolute error (MAE) or mean absolute percentage error (MAPE). If the error exceeds a set threshold, the system can automatically trigger additional incremental training or model hyperparameter adjustment. This automated error monitoring and model update mechanism can further improve the accuracy and reliability of the prediction system. In practical applications, the UPSERT operation and error monitoring mechanism can be customized according to the specific needs and data characteristics of the enterprise to ensure that the prediction system can meet the actual operational needs of the enterprise.
[0093] The above embodiments of the present invention have the following beneficial effects:
[0094] 1. By introducing an incremental training mechanism, the model can be quickly fine-tuned using newly arrived data, improving its adaptability to concept drift. This effectively solves the problem of lagging model updates in existing technologies, enabling the prediction model to better adapt to dynamic changes in data and improving the timeliness and accuracy of predictions.
[0095] 2. By adopting a direct multi-step prediction output structure, the problem of gradual error accumulation in recursive prediction is avoided, the accuracy of medium- and long-term prediction is improved, and the error accumulation problem caused by recursive prediction in existing technologies is solved. This provides enterprises with more reliable medium- and long-term load forecast results, which helps enterprises to better manage energy and arrange production plans.
[0096] 3. It achieves full automation of the entire process from data reading, preprocessing, model training and updating to result storage, especially supporting efficient integration with lightweight databases (such as SQLite). It has strong engineering practicality and scalability, solves the problem of high difficulty in system engineering integration in existing technologies, reduces the cost and complexity of enterprises implementing load forecasting systems, and improves the availability and ease of use of the system.
[0097] Furthermore, the storage medium in the embodiments of this application stores program instructions capable of implementing all the above methods. These program instructions can be stored in the storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets.
[0098] The above description is merely an explanation of some preferred embodiments of the present invention and the technical principles employed. Those skilled in the art should understand that the scope of the invention as described in the embodiments of the present invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of the present invention.
Claims
1. An incremental multi-step time-series forecasting method for enterprise load, characterized in that, Includes the following steps: Historical records containing time fields, total enterprise power, and multiple meteorological features are read from a relational database. The historical records are then parsed for time, sorted by time, and missing values are handled. Feature columns with zero variance are removed. A normalizer is used to jointly normalize the features and target variables in the processed historical records, and the normalizer is persistently saved; a supervised learning dataset is constructed using a historical time series of a first set duration as the input window and a future time series of a second set duration as the output window; A deep learning model comprising a shared feature encoder, an attention fusion layer, and a multi-task output layer is constructed. The deep learning model is trained using the supervised learning dataset to obtain a trained model that can directly output multi-step prediction results. The shared feature encoder is used to extract deep spatiotemporal features of the input sequence, the attention fusion layer is used to generate a context vector reflecting key historical information, and the multi-task output layer is used to simultaneously output the predicted values of load power and the classification probabilities of load state in the future multi-step process. When a saved model file and its corresponding normalizer file are detected, incremental training is performed on the trained model based on the latest data of the third set duration to update the model parameters. The number of training rounds in the incremental training is controlled within a preset number of rounds and a learning rate lower than that in the initial training phase is used. Using the input window data before the target time point, the updated model directly outputs the prediction results for multiple future steps, and the persistently saved normalizer is used to perform denormalization processing on the prediction results to restore the physical quantity values. The inverse normalized prediction results and their corresponding timestamps are written into the specified prediction result table in the database using an insert or update operation based on the unique constraints of the timestamps, and the prediction generation time or batch identifier is recorded in the prediction result table.
2. The method according to claim 1, characterized in that, The duration of the input window is 48 hours, and the duration of the output window is 24 hours.
3. The method according to claim 1, characterized in that, The meteorological features include shortwave radiation, diffuse radiation, air temperature, saturated vapor pressure difference, wind direction, and wind speed. The historical records also include a flag field indicating whether the company is on a rest day.
4. The method according to claim 1, characterized in that, The deep learning model includes: The shared feature encoder consists of two layers of Long Short-Term Memory (LSTM) networks. The first LSTM layer receives the input window data and outputs the sequence of all time steps, while the second LSTM layer receives the sequence output by the first LSTM layer and outputs the hidden state of the final time step. The attention fusion layer receives all time step sequences output by the first LSTM layer and the final hidden state output by the second LSTM layer, performs attention weighting calculation on all time step sequences, and generates a context vector. The multi-task output layer includes a main task regression branch and an auxiliary task classification branch; The main task regression branch receives the context vector and sequentially passes through a first fully connected layer with 16 units and a first linear output layer using the ReLU activation function to calculate and output the regression prediction value of future multi-step load power. The auxiliary task classification branch receives the final hidden state output by the second LSTM layer, and sequentially passes it through a second fully connected layer with 8 units and a Sigmoid output layer to calculate and output the classification probability of future multi-step load states. The deep learning model is trained using a joint loss function.
5. The method according to claim 4, characterized in that, The first LSTM layer has 64 cells, and the second LSTM layer has 32 cells.
6. The method according to claim 4, characterized in that, The attention fusion layer calculates the attention weights of each time step in the sequence of all time steps and the final hidden state, and then performs a weighted summation of the sequence of all time steps to generate the context vector.
7. The method according to claim 4, characterized in that, The regression prediction value output by the main task regression branch is a load power prediction vector of length 24; the classification probability output by the auxiliary task classification branch is a vector of length 24, representing the probability that the load exceeds a preset threshold at each time point in the next 24 hours.
8. The method according to claim 4, characterized in that, The joint loss function is a weighted sum of the mean squared error of the regression loss of the main task and the binary cross-entropy of the classification loss of the auxiliary task. The formula for calculating the joint loss function L is as follows: ;in, and is the weighting coefficient, MSE represents the mean squared error, and BCE represents the binary cross-entropy.
9. The method according to claim 1, characterized in that, The incremental training step uses data from the most recent N days to fine-tune the model, where N is a positive integer, and the preset number of rounds does not exceed 20 rounds.
10. The method according to claim 1, characterized in that, The relational database is an SQLite database, and the insert or update operation is specifically a UPSERT operation; the method also includes the steps of: adding a true value field to the prediction result table or establishing a comparison table, automatically calculating the prediction error index when the true load value is reached, and automatically triggering additional incremental training or model hyperparameter adjustment if the error exceeds a set threshold.
Citation Information
Patent Citations
Recurrent neural network training method
CN114418071A
Short-term load prediction method based on time deep convolutional network
CN117477539A