Multi-type power time sequence prediction method, device and equipment
Through the construction of custom workflow assembly line framework and automated algorithm models, the complexity and time-consuming problems of power timing prediction tasks are solved, efficient data processing and model training are realized, and a variety of data sources and models are suitable for power systems, reducing the number of data sources and models. Reliance on professionals.
Patent Information
- Application Number
- CN202411604040.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2024-12-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The power timing prediction task is complex and time-consuming, and requires a lot of manual time for basic construction and tuning, especially data preprocessing, feature engineering, model selection and adjustment, requiring high professional knowledge and skills.
Provide a variety of power timing prediction methods, customize the workflow framework by obtaining the task parameters set by users, generate task files and automate the algorithm model construction and prediction process, and support data reading from multiple sources, feature processing and model training. , including training, prediction and tuning tasks, automatically deal with data missing and anomalies, and reduce manual intervention.
Reduces the complexity and time-consuming of power timing prediction, automated processing of data missing and abnormalities, reduces dependence on professionals, improves prediction efficiency and accuracy, supports multi-source heterogeneous data and multiple models, suitable for power systems time series data prediction.
Smart Images

Figure CN119150256A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power time series prediction, and in particular to a method, device and equipment for predicting multiple types of power time series. Background Art
[0002] The power system will generate a large amount of time series data during operation, including electricity prices, loads, etc. The prediction of power time series data can provide a quantitative basis for forward-looking optimization decisions of the power system, so as to improve the effectiveness and safety of power system operation.
[0003] With the rapid development of technologies such as machine learning, more and more algorithms for time series prediction have emerged, but the overall time series prediction task is complex. First, there are many prediction objects, including electricity prices, power sources, and loads. Second, the time span of the prediction is diverse, covering medium- and long-term predictions, short-term predictions, and ultra-short-term predictions. In addition, the diversity of data also increases the complexity. Common problems include missing data and inconsistent fields. Finally, the complete process of the prediction task involves types such as training, prediction, backtesting, and tuning, and there are procedural differences between tasks.
[0004] In order to cope with the above complexity, a lot of manual time is usually required for basic construction and tuning work. This includes data preprocessing, feature engineering, model selection and adjustment, and model verification and optimization. These steps are not only time-consuming and labor-intensive, but also require high professional knowledge and skills of personnel, making the entire prediction process more complicated and time-consuming. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a variety of power time series prediction methods, devices and equipment to overcome the problem that the current power time series prediction requires professionals to carry out basic construction, resulting in a complex and time-consuming prediction process.
[0006] To achieve the above objectives, the present invention adopts the following technical solutions: In a first aspect, the present application provides a method for predicting multiple types of power time series, including: Obtaining task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task type includes: training task, prediction task, backtesting task and tuning task; Customize and adjust operators in the workflow framework according to the task parameters; Generate a task file through a scheduler according to the task parameters; According to the task file, the variables are assigned through the executor, the corresponding algorithm model is built through the workflow framework, the task workflow of the specified type is executed, the prediction is completed through the task file corresponding to the prediction task, and the prediction results are stored in the preset database.
[0007] Furthermore, in the above method, if the task type is a training task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: The data of the task file is read through the ImportData function; wherein the readable data includes at least: relational database, NoSQL database, big data platform, cloud database service and file system; the readable data categories include at least: structured data, semi-structured data and unstructured data; Performing feature processing on the read data; wherein the feature processing at least includes: outlier processing, feature specification, outlier processing and excluding other time periods; Performing feature engineering on the read data after feature processing; wherein the feature engineering at least includes: one-hot encoding, data standardization, PCA dimension reduction, time feature determination, lag feature determination, rolling window feature determination, nearest neighbor n_days determination, and stratified sampling screening based on target value; According to the read data after feature engineering, a prediction model type is selected, and the prediction model is filled into the regressor template to create a new class; wherein the prediction model type includes at least: a linear regression model, a KNN model, an ensemble learning model, a neural network model, and a tree model; According to the algorithm characteristics of the prediction model, a training function train, a prediction function forecast and an auxiliary function are created to train the prediction model; If the task type is a prediction task, the corresponding algorithm model is constructed through the workflow pipeline framework to execute the task workflow of the specified type, including: Read the data of the task file through the ImportData function; Perform feature processing on the read data; Performing feature engineering on the read data after feature processing; Obtaining user instructions, determining whether to retrain the model according to the user instructions, and if not, determining a target prediction model from the trained prediction models, and performing predictions based on the target prediction model and data after feature engineering is completed; Post-processing the prediction results of the prediction model; wherein the post-processing includes at least: data smoothing, interpolation, and upper and lower limit correction; If the task type is a backtesting task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: Acquire historical data, and divide the historical data into a test data set and a result data set; Select the trained prediction model to predict the test data set; Obtaining prediction results, and evaluating the selected prediction model based on the prediction results and the result data set; If the task type is a tuning task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: Read the data of the task file through the ImportData function; Construct multiple prediction models based on the data of the task file, as well as all feature processing methods, sample selection methods and prediction model types; Backtest all constructed forecasting models to determine the optimal forecasting model.
[0008] Furthermore, in the above method, the outlier processing includes: Detecting illegal characters in the read data and removing the illegal characters; The feature specification includes: Feature assignment is accomplished by combining the performance of different feature combinations determined by the combined search calculation and user-defined combinations; The outlier processing includes: The outlier data were removed by 3-sigma method and IQR method.
[0009] Furthermore, in the above method, the data standardization includes: The read data is standardized by using a Scaler standardization calculation formula and a Minmax standardization calculation formula; The Scaler normalization calculation formula is:
[0010] in, Represents the data value after Scaler standardization. Represents the original data value, represents the mean of the data, Indicates the standard deviation of the data; The Minmax normalization calculation formula is:
[0011] in, Represents the data value after Minmax standardization, Represents the original data value, Indicates the maximum value in the data. Indicates the minimum value in the data; The PCA dimensionality reduction includes: For the read data, determine a data set, and calculate a covariance matrix of the data set; Performing eigenvalue decomposition on the covariance matrix; A preset number of features are determined in the read data, the cumulative contribution rates of the features are calculated, and the cumulative contribution rates and the decomposed eigenvalues are projected onto the data set to complete PCA dimensionality reduction.
[0012] Furthermore, the method described above is characterized in that the data smoothing comprises: Data smoothing is performed using a simple moving average formula and a weighted moving average formula; wherein the simple moving average formula is:
[0013] in, Indicates The simple moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The value of the data point; The weighted moving average formula is:
[0014] in, Indicates The weighted moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The weight of the data point, Indicates The value of the data point; The interpolation includes: The interpolation calculation is completed by the interpolation formula; wherein the interpolation formula is:
[0015] in, represents the estimated value of the target interpolation point, Represents the window radius, which determines the number of left and right data points used for interpolation. Indicates the window relative to The offset from arrive , Indicates the location The data point value at ; The upper and lower limit corrections include: The prediction result is corrected by a correction formula; wherein the correction formula is:
[0016] in, represents the revised forecast result, represents the original prediction result, Indicates the lower threshold of the result, Indicates the upper threshold of the result.
[0017] Furthermore, the above method is characterized in that the evaluating the selected prediction model according to the prediction result and the result data set comprises: The selected prediction model is evaluated according to the prediction result and the result data set by using the MAPE formula, RMSE formula, MAE formula, ACC formula and RMSPE formula; wherein the MAPE formula is:
[0018] in, represents the calculated mean absolute percentage error, Indicates the number of data points to be calculated. Indicates the actual value, represents the predicted value; The RMSE formula is:
[0019] in, represents the calculated root mean square error, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The MAE formula is:
[0020] in, represents the calculated mean absolute error, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The ACC formula is: 00% in, represents the calculated percentage accuracy, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The RMSPE formula is:
[0021] in, represents the calculated root mean square percentage error, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
[0022] Furthermore, the above method further includes: Customize operators based on operator templates.
[0023] In a second aspect, the present application provides a variety of power time series prediction devices, including: The task parameter acquisition module is used to obtain the task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task type includes: training task, prediction task, backtesting task and tuning task; A workflow framework adjustment module, used to customize the operators in the workflow framework according to the task parameters; A scheduler module, used to generate a task file according to the task parameters; The executor module is used to assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow pipeline framework, execute the task workflow of the specified type, complete the prediction through the task file corresponding to the prediction task, and store the prediction results in a preset database.
[0024] In a third aspect, the present application provides a multi-type power time series prediction device, including a processor and a memory, wherein the processor is connected to the memory: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store the program, and the program is at least used to execute any one of the above-mentioned multiple types of power time series prediction methods.
[0025] The beneficial effects of the present invention are: This application first obtains the task parameters set by the user according to business needs; wherein the task parameters include at least: prediction object, task type, training and prediction date; wherein the task types include: training task, prediction task, backtesting task and tuning task; customize the operators in the workflow framework according to the task parameters; generate a task file through the scheduler according to the task parameters; assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow framework, execute the specified type of task workflow, complete the prediction through the task file corresponding to the prediction task, and store the prediction result in the preset database. In this application, the scheduler automatically generates a task file based on the task parameters, the executor automatically assigns values to the variables, and completes the prediction by using the workflow framework to complete the task file. When the workflow framework encounters data missing exceptions when executing the task flow, it supports automatic creation of pre-order prediction tasks and repairs the exceptions, thereby reducing the number of people performing basic construction, thereby solving the problem that the current power time series prediction requires professionals to perform basic construction, resulting in a complex prediction process and a long time-consuming problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Figure 1 It is a flow chart provided by an embodiment of a method for predicting multiple types of power time series according to the present invention; Figure 2 It is a structural schematic diagram provided by an embodiment of a multi-type power time series prediction device of the present invention; Figure 3 It is a structural schematic diagram provided by an embodiment of a multi-type power time series prediction device of the present invention. DETAILED DESCRIPTION
[0028] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0029] Figure 1 This is a flowchart provided by an embodiment of a method for predicting multiple types of power time series according to the present invention. Figure 1, this embodiment may include the following steps: S1. Obtain task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task types include: training task, prediction task, backtesting task and tuning task.
[0030] S2. Customize the operators in the workflow framework according to the task parameters.
[0031] S3. Generate a task file through the scheduler according to the task parameters.
[0032] S4. Assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow pipeline framework, execute the specified type of task workflow, complete the prediction through the task file corresponding to the prediction task, and store the prediction results in the preset database.
[0033] It can be understood that the present application first obtains the task parameters set by the user according to business needs; wherein the task parameters include at least: prediction object, task type, training and prediction date; wherein the task types include: training task, prediction task, backtesting task and tuning task; customize the operators in the workflow framework according to the task parameters; generate a task file through the scheduler according to the task parameters; assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow framework, execute the specified type of task workflow, complete the prediction through the task file corresponding to the prediction task, and store the prediction results in the preset database. In the present application, the scheduler automatically generates a task file based on the task parameters, the executor automatically assigns values to the variables, and completes the prediction by using the workflow framework to complete the task file. When the workflow framework encounters data missing exceptions when executing the task flow, it supports automatic creation of pre-order prediction tasks and repairs the exceptions, thereby reducing the number of people performing basic construction, thereby solving the problem that the current power time series prediction requires professionals to perform basic construction, resulting in a complex prediction process and a long time-consuming problem.
[0034] It supports full coverage of various application scenarios under power system time series data, supports the reading of multi-source heterogeneous inputs, including various types of databases and different data items, and the alignment and splicing of results at different time granularities. It provides a rich operator library of various feature generation, sample screening, error evaluation criteria, etc., and supports custom operators. It supports various common models such as machine learning and neural networks. It supports post-processing of model prediction results in combination with specific business scenarios and rules; it provides interactive pages and visualizes task processes, and can create training, prediction, backtesting, and tuning task flows for various types of power time series predictions: it supports the creation of training, prediction, backtesting, and tuning task flows for batch objects, supports many-to-one and one-to-one relationships between objects and pipelines when building training and prediction task flows, and supports one-to-many and many-to-many relationships between objects and pipelines when building backtesting and tuning task flows. The preceding task is automatically constructed, and when the pipeline executes the task flow and encounters abnormal problems such as missing data, it supports the automatic creation of preceding prediction tasks and repairs the abnormalities. When executing the prediction task flow in the pipeline, it can support two modes: retraining the model and reading the trained model.
[0035] It should be noted that the workflow pipeline framework is centered on a two-layer architecture consisting of a scheduler and an executor. It uses the two template files TEMPLATE_TASK and TEMPLATE_PIPELINE to implement user-defined task requirements, and solves abnormal situations that occur during system operation through the interaction between the scheduler and the executor to achieve successful execution of tasks.
[0036] The workflow framework can be pipeline.
[0037] On the front-end page, users can set multiple parameters such as prediction object, task type, training and prediction date according to business needs, and customize the workflow framework by dragging and dropping through the interactive interface. The scheduler generates a task file based on the information entered by the user on the front end and starts the executor to execute the task. After the executor assigns values to the relevant variables according to the task file, it executes the code of the corresponding module according to the task processing flow set by the user to complete the task flow, and finally outputs the results into the library. In addition, debugging is supported on the web page. If the execution encounters an exception, the component will throw the exception information, analyze, warn and make modification suggestions for the thrown error.
[0038] It is understandable that in power series forecasting, the system can divide task types into training, forecasting, backtesting and tuning according to different task requirements to meet the needs of different scenarios.
[0039] For training tasks, historical power time series data is used to generate an accurate prediction model by performing data preprocessing, feature extraction, and model selection on the input data, and then training the model to capture the trends and patterns of the data, providing a basis for subsequent prediction tasks.
[0040] For prediction tasks, input the time range that needs to be predicted, call the trained model or use historical data to train a new model for prediction, and generate the predicted value of future power load to help the power system optimize resource allocation and scheduling.
[0041] For backtesting tasks, a part of the historical data is used as a test set. While avoiding data leakage, the trained model is used for prediction. The predicted results are compared with the actual results to evaluate the accuracy and stability of the model, identify the advantages and disadvantages of the model, and provide a basis for improvement.
[0042] For tuning tasks, we build corresponding pipelines based on different feature selection, sample selection, model selection and other tuning strategies, and then perform backtesting tasks to select the optimal pipeline to provide support for future predictions.
[0043] The task file format is shown in Table 1. The above four tasks basically cover all the time series prediction scenarios that may be encountered. As shown in Table 2, by adopting a modular construction method, the framework redundancy caused by the overlapping parts of different tasks can be effectively avoided.
[0044] Table 1 Task file format
[0045] Table 2 Workflow pipeline framework diagram
[0046] Preferably, as shown in Table 2, if the task type is a training task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: The ImportData function is used to read the data of the task file. The readable data includes at least relational databases, NoSQL databases, big data platforms, cloud database services, and file systems. The readable data categories include at least structured data, semi-structured data, and unstructured data. Performing feature processing on the read data; wherein the feature processing at least includes: outlier processing, feature specification, outlier processing and excluding other time periods; Perform feature engineering on the read data after feature processing; wherein, feature engineering at least includes: one-hot encoding, data standardization, PCA dimension reduction, time feature determination, lag feature determination, rolling window feature determination, nearest neighbor n_days determination and stratified sampling screening based on target value; According to the data read after feature engineering, a prediction model type is selected, and the prediction model is filled into the regressor template to create a new class; wherein the prediction model types include at least: linear regression model, KNN model, ensemble learning model, neural network model and tree model; According to the algorithm characteristics of the prediction model, create the training function train, prediction function forecast and auxiliary functions and train the prediction model; If the task type is a prediction task, the corresponding algorithm model is built through the workflow pipeline framework to execute the task workflow of the specified type, including: Read the data of the task file through the ImportData function; Perform feature processing on the read data; Perform feature engineering on the read data after feature processing; Obtain user instructions, and determine whether to retrain the model based on the user instructions. If not, determine the target prediction model from the trained prediction models, and make predictions based on the target prediction model and the data after feature engineering is completed; Post-processing the prediction results of the prediction model; wherein the post-processing includes at least: data smoothing, interpolation, and upper and lower limit correction; If the task type is a backtesting task, the corresponding algorithm model is built through the workflow pipeline framework, and the task workflow of the specified type is executed, including: Obtain historical data and divide the historical data into a test data set and a result data set; Select the trained prediction model to predict the test data set; Obtain prediction results, and evaluate the selected prediction model based on the prediction results and result data sets; If the task type is a tuning task, the corresponding algorithm model is built through the workflow pipeline framework to execute the task workflow of the specified type, including: Read the data of the task file through the ImportData function; Build multiple prediction models based on the data in the task file, as well as all feature processing methods, sample selection methods, and prediction model types; Backtest all constructed forecasting models to determine the optimal forecasting model.
[0047] It is understandable that during the creation of the workflow pipeline framework, necessary data such as the task name, object, processing operator order, prediction training time range, and training task type are defined in the initial conversion function.
[0048] After creation, call related functions according to the task type, such as train and forecaste methods. During the execution process, traverse each operator in steps in order, execute the train method during training, and execute the forecast method during prediction.
[0049] It should be noted that the user specifies the predicted object, the path of the data source, and the time granularity in the front-end interface. The scheduler converts this information into a task file. The executor parses the task file, parameterizes the data source information, and executes the data reading module to query the required file from the data table or database. It can also align and splice results of different time granularities. Whether it is minute-level, 15-minute-level, hour-level or day-level data, it can be integrated and analyzed through a unified processing logic to ensure efficient use and consistency of data. Currently, it supports reading in heterogeneous data from multiple sources, including relational databases (such as MySQL, PostgreSQL, Oracle, etc.), NoSQL databases (such as MongoDB, Cassandra, Redis, etc.), big data platforms (such as Hadoop, Spark, etc.), cloud database services (such as Amazon RDS, Google BigQuery, Azure SQL Database, etc.) and file systems (such as CSV, JSON, Parquet, etc.). In addition, it also supports reading in different data types, such as structured data, semi-structured data, and unstructured data.
[0050] Preferably, outlier processing includes: Detect illegal characters in the read data and remove them; Feature designations include: Feature assignment is accomplished by combining the performance of different feature combinations determined by the combined search calculation and user-defined combinations; Outlier processing includes: The outlier data were removed by 3-sigma method and IQR method.
[0051] It is understandable that after the data is imported in the previous step, the data can be preprocessed, mainly including outlier processing, feature specification, outlier processing and elimination of other time period operators.
[0052] Outlier processing includes: For the input data, there may be some illegal characters, such as ", @#¥%……&", etc., or some unreasonable values, which will be removed before executing the task using this operator.
[0053] Feature specification includes: for a series of features in the read data, calculating the performance of different feature combinations through combined search or determining the features based on user-defined combinations.
[0054] Outlier processing includes: For the 3-sigma method, first calculate the mean of the data set and standard deviation , and then calculate the distance between each data point in the data set and the mean ,if , then the data point is considered as an outlier and is removed.
[0055] For the IQR method, first calculate the lower and upper quartiles of the data, that is, and , and then calculate . Based on these three items, the upper and lower boundaries are calculated respectively:
[0056] Data points outside this range will be considered as outliers, and data within this range will be considered normal values.
[0057] Eliminating other time periods includes: when executing a task, there may be some special situations that do not require prediction or use of time series data at a certain time, so this time interval needs to be eliminated from the data. This operator will compare the time interval entered by the user with the time of the samples in the data set and eliminate the specified time period.
[0058] In addition, users only need to drag and drop modules on the front-end page to define the task chain of the workflow framework, avoiding the professional requirements for writing general code. In actual use, you can freely choose the combination of the above operators and customize the processing order according to your needs.
[0059] Preferably, data normalization includes: The read data is standardized by the Scaler standardization calculation formula and the Minmax standardization calculation formula; Among them, the Scaler normalization calculation formula is:
[0060] The Minmax normalization calculation formula is:
[0061] PCA dimensionality reduction includes: For the read data, determine the data set and calculate the covariance matrix of the data set; Perform eigenvalue decomposition on the covariance matrix; Determine a preset number of features in the read data, calculate the cumulative contribution rate of the features, and project them to the data set based on the cumulative contribution rate and the decomposed eigenvalues to complete PCA dimensionality reduction.
[0062] It is understandable that feature engineering can convert raw data into features that can improve model performance, so feature engineering is also the most important and most skillful step in actual prediction tasks. After data preprocessing, you can select appropriate operators for feature processing based on your needs. This mainly includes: one-hot encoding, data standardization, and PCA dimensionality reduction conventional feature processing methods.
[0063] One-hot encoding is: For a categorical variable , whose value range is ,in Define the processing function for the total number of categories.
[0064]
[0065] Data normalization is: For a given data set , which contains samples, each sample Features.
[0066] The Scaler normalization calculation formula is:
[0067] Where: Represents the data value after Scaler standardization. Represents the original data value, represents the mean of the data, Represents the standard deviation of the data.
[0068] The Minmax normalization calculation formula is:
[0069] Where: Represents the data value after Minmax standardization, Represents the original data value, Indicates the maximum value in the data. Indicates the minimum value in the data.
[0070] PCA dimensionality reduction is: For a given data set , calculate the covariance matrix,
[0071] Perform eigenvalue decomposition,
[0072] Calculates the cumulative contribution rate based on the user-given threshold selection Features,
[0073] Projected into the principal component space, 。
[0074] Based on the characteristics of time series data, unique processing methods for generating time features, lag features and rolling window features for time series prediction scenarios are also added.
[0075] The time feature is determined as follows: For the heavy task of power time series prediction, time is a feature that cannot be ignored, because whether it is load or power, etc., the time series characteristics often have periodicity or some time rules.
[0076] Therefore, the recording time for each sample is According to the time granularity, time features such as month, day, hour, minute, and weekday can be segmented, and whether it is a holiday and the time away from the holiday can be calculated based on the time.
[0077] The lag feature is determined as follows: The lag feature is to use the past observation value as the feature of the current moment.
[0078] For example, the value for the previous day was ,but , The value of is entered by the user.
[0079] The rolling window characteristics are determined as follows: the rolling statistics calculate the statistical characteristics within a window, such as the mean, standard deviation, etc.
[0080] Rolling mean: The window size is The mean 。
[0081] Rolling standard deviation: The window size is Standard Deviation 。
[0082] Sample screening is performed on the data after feature operation, which mainly includes historical nearest neighbor n_days, stratified sampling screening based on target value, and leave-one-out validation evaluation screening.
[0083] The nearest neighbor n_days is determined as follows: First calculate the time difference:
[0084] Select the n nearest neighbor samples:
[0085] The stratified sampling screening based on the target value is: Assume a The target value of each sample is First, the data set is divided into layers, each layer Include samples whose target values are within a specific range.
[0086]
[0087] Calculate the proportion of sample size in each stratum:
[0088] Sampling in each stratum:
[0089] Finally, merge the samples.
[0090] In some optional embodiments, according to the algorithm characteristics of the prediction model, a training function train, a prediction function forecast and an auxiliary function are created and prediction is performed through the prediction model, including: For creating a tree model, take creating an XGBoostRegressor class as an example. Based on the XGBoost algorithm, multiple training and parameter adjustment modes are provided.
[0091] Initializes the XGBoostRegressor object, accepting parameters such as time column, prediction label, prediction date range, prediction step, model parameters, whether to adjust parameters, cross-validation folds, evaluation indicators, and early stopping rounds. Sets the initial state of the object, including default model parameters and other properties.
[0092] Check the input parameters and data to make sure they are of the expected types and conditions. Check that the features are in the dataset, the time column exists, the forecast date is valid, and that other parameters are specified correctly.
[0093] Updates the model parameters using the provided dictionary.
[0094] Use Optuna for model parameter tuning. Define an objective function that Optuna optimizes to find the best hyperparameters based on a specified evaluation metric.
[0095] Trains a single XGBoost model using the provided training data and weights. Updates feature importances and adds the trained model to the list of models.
[0096] Perform K-fold cross validation training. Split the data into multiple folds, train a model for each fold, and update the feature importance and model list.
[0097] Combine K-fold cross validation with hyperparameter tuning using Optuna. Tune the parameters for each fold and train the model using the best parameters found.
[0098] train function: the main training method, checks parameters, prepares data sets, and sets up training models based on parameter adjustment and fold number. Supports three modes: parameter adjustment mode, fold number mode, and default mode.
[0099] forecast function: Use the trained model to make forecasts for new data. Check whether the input data meets the forecast step size requirements, prepare test data, and calculate the average of all training model forecasts.
[0100] This class encapsulates the entire process from initializing the model, validating inputs, tuning hyperparameters, training the model, and making predictions.
[0101] For creating a KNN model, the KNeighborsRegressor class is a regression prediction method class based on the K nearest neighbor (KNN) algorithm, which provides two training modes: integrated mode and single mode.
[0102] Initializes a KNeighborsRegressor object, accepting parameters such as time column, prediction label, prediction date range, prediction step, number of neighbors, weight function, number of integrated neighbors, etc. Sets the initial state of the object, including default parameters and other properties.
[0103] Check the input parameters and data to make sure they are of the expected types and conditions. Check that the features are in the dataset, the time column exists, the forecast date is valid, and that other parameters are specified correctly.
[0104] The ensemble training method trains multiple KNN models according to the number of neighbors and the weight function combination in the ens_neighbors parameter and adds them to the model list.
[0105] A single training method that trains a single KNN model using the specified number of neighbors and weight function and adds it to the list of models.
[0106] train function: the main training method, checks parameters, prepares datasets, and sets the training model according to the ens_neighbors parameter. Supports two modes: ensemble mode and single mode. Standardizes features before training.
[0107] forecast function: Use the trained model to make forecasts for new data. Check if the input data meets the forecast step size requirements, prepare test data, and calculate the average of all trained model forecasts. Normalize the test data before forecasting.
[0108] This class encapsulates the entire process from initializing the model, validating the input, training the model, and making predictions.
[0109] Preferably, data smoothing includes: Data smoothing is performed using the simple moving average formula and the weighted moving average formula; the simple moving average formula is:
[0110] The weighted moving average formula is:
[0111] Interpolation includes: The interpolation calculation is completed through the interpolation formula; wherein the interpolation formula is:
[0112] The upper and lower limit corrections include: The prediction results are corrected by the correction formula; the correction formula is: .
[0113] It is understandable that after obtaining the prediction results of the model, the results can be post-processed based on some business knowledge or prior information to improve the practical application value and reliability of the prediction results. For example, in electricity price forecasting, the ceiling price (upper limit) and floor price (lower limit) can be used to correct the prediction results to ensure that the predicted electricity price does not exceed a reasonable range. In load forecasting, negative values can be corrected and adjusted to zero or other reasonable minimum values. In addition, data smoothing techniques such as moving average and exponential smoothing can be used to reduce the volatility of the prediction results and make them more stable and continuous. These post-processing steps can help improve the quality of the prediction results and make them more reliable and effective in practical applications. The main processing methods include: data smoothing, interpolation, and upper and lower limit correction.
[0114] Data smoothing is: Moving average method smoothes data by taking the average value of data over a period of time. Currently includes: Simple Moving Average:
[0115] Where: Indicates The simple moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The value of the data point.
[0116] Weighted Moving Average:
[0117] Where: Indicates The weighted moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The weight of the data point, Indicates The value of the data point.
[0118] Interpolation is: Interpolation is also a method for data smoothing. Currently, it includes moving average interpolation, for a time series , the smoothing method is as follows:
[0119] Where: represents the estimated value of the target interpolation point, Represents the window radius, which determines the number of left and right data points used for interpolation. Indicates the window relative to The offset from arrive , Indicates the location The data point value at .
[0120] The upper and lower limits are revised as follows: , in the given upper and lower limits , the correction formula is as follows:
[0121] Where: represents the revised forecast result, represents the original prediction result, Indicates the lower threshold of the result, Indicates the upper threshold of the result.
[0122] Preferably, the selected prediction model is evaluated based on the prediction results and the result data set, including: According to the prediction results and result data sets, the selected prediction model is evaluated by MAPE formula, RMSE formula, MAE formula, ACC formula and RMSPE formula; among which, MAPE formula is:
[0123] Where: represents the calculated mean absolute percentage error, Indicates the number of data points to be calculated. Indicates the actual value, Represents the predicted value.
[0124] The RMSE formula is:
[0125] Where: represents the calculated root mean square error, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
[0126] The MAE formula is:
[0127] Where: represents the calculated mean absolute error, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
[0128] The ACC formula is: 00% Where: represents the calculated percentage accuracy, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
[0129] The RMSPE formula is:
[0130] Where: represents the calculated root mean square percentage error, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
[0131] It is understandable that the current prediction algorithms are mainly regression algorithms, so the results are a series of continuous values. The current evaluation indicators include MAPE, RMSE, MAE, ACC, RMSPE, etc., as well as the State Grid / Southern Grid evaluation methods commonly used in power systems.
[0132] Preferably, it also includes: Customize operators based on operator templates.
[0133] It is understandable that in the previous modules, each part provides a rich set of operators for user convenience. At the same time, the front-end page also allows the selection of user-defined operators, which can be stored in the library for reuse. The template of the custom operator is as follows. The operator template is a function call that the operator will make when it is initialized. In this function, you can put the data processing configuration items required for the operator. The train method is a function called by the model during training to obtain the training set. Therefore, the data mainly returned by this method is the training set. The forecast method is mainly used to obtain the prediction input when the model predicts the result.
[0134] The operator template is: class Usefunction(Module): """Custom Operator""" def __init__(self, params): #params contains some specific processing configuration items self.params = params def train (self, X, y=None): # Get the training set X X = get_train_X(X) ... return X, feature_list def forecast(self, X): # Get the input X for prediction ... # Prediction set X X = get_forecast_X(self.X) return result .
[0135] The present invention also provides a variety of power time series prediction devices for implementing the above method embodiments. Figure 2 1 is a schematic diagram of a structure of a multi-type power time series prediction device according to an embodiment of the present invention. Figure 2 As shown, this embodiment includes: Task parameter acquisition module 1, used to obtain task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task type includes: training task, prediction task, backtesting task and tuning task; Workflow pipeline framework adjustment module 2, used to customize the operators in the workflow pipeline framework according to task parameters; Scheduler module 3, used to generate task files according to task parameters; Executor module 4 is used to assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow framework, execute the task workflow of the specified type, complete the prediction through the task file corresponding to the prediction task, and store the prediction results in the preset database.
[0136] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0137] The present invention also provides a variety of power time series prediction devices for implementing the above method embodiments. Figure 3 This is a schematic diagram of the structure of an embodiment of a multi-type power time series prediction device provided by the present invention. Figure 3 As shown, the multi-type power time series prediction device of this embodiment includes a processor 21 and a memory 22, and the processor 21 is connected to the memory 22. The processor 21 is used to call and execute the program stored in the memory 22; the memory 22 is used to store the program, and the program is at least used to execute the multi-type power time series prediction method in the above embodiment.
[0138] The specific implementation schemes of the various types of power time series prediction devices provided in the embodiments of the present application can refer to the implementation schemes of the various types of power time series prediction methods in any of the above embodiments, and will not be repeated here.
[0139] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0140] It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0141] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0142] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0143] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0144] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0145] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0146] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0147] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A multi-class power time series forecasting method, It is characterized in that include: Obtaining task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task type includes: training task, prediction task, backtesting task and tuning task; Customize and adjust operators in the workflow framework according to the task parameters; Generate a task file through a scheduler according to the task parameters; According to the task file, the variables are assigned through the executor, the corresponding algorithm model is built through the workflow framework, the task workflow of the specified type is executed, the prediction is completed through the task file corresponding to the prediction task, and the prediction results are stored in the preset database.
2. The method according to claim 1, It is characterized in that If the task type is a training task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: The data of the task file is read through the ImportData function; wherein the readable data includes at least: relational database, NoSQL database, big data platform, cloud database service and file system; the readable data categories include at least: structured data, semi-structured data and unstructured data; Performing feature processing on the read data; wherein the feature processing at least includes: outlier processing, feature specification, outlier processing and excluding other time periods; Performing feature engineering on the read data after feature processing; wherein the feature engineering at least includes: one-hot encoding, data standardization, PCA dimension reduction, time feature determination, lag feature determination, rolling window feature determination, nearest neighbor n_days determination, and stratified sampling screening based on target value; According to the read data after feature engineering, a prediction model type is selected, and the prediction model is filled into the regressor template to create a new class; wherein the prediction model type includes at least: a linear regression model, a KNN model, an ensemble learning model, a neural network model, and a tree model; According to the algorithm characteristics of the prediction model, a training function train, a prediction function forecast and an auxiliary function are created to train the prediction model; If the task type is a prediction task, the corresponding algorithm model is constructed through the workflow pipeline framework to execute the task workflow of the specified type, including: Read the data of the task file through the ImportData function; Perform feature processing on the read data; Performing feature engineering on the read data after feature processing; Obtaining user instructions, determining whether to retrain the model according to the user instructions, and if not, determining a target prediction model from the trained prediction models, and performing predictions based on the target prediction model and data after feature engineering is completed; Post-processing the prediction results of the prediction model; wherein the post-processing includes at least: data smoothing, interpolation, and upper and lower limit correction; If the task type is a backtesting task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: Acquire historical data, and divide the historical data into a test data set and a result data set; Selecting the trained prediction model to predict the test data set; Obtaining prediction results, and evaluating the selected prediction model according to the prediction results and the result data set; If the task type is a tuning task, the corresponding algorithm model is constructed through the workflow pipeline framework, and the task workflow of the specified type is executed, including: Read the data of the task file through the ImportData function; Construct multiple prediction models based on the data of the task file, as well as all feature processing methods, sample selection methods and prediction model types; Backtest all constructed forecasting models to determine the optimal forecasting model.
3. The method according to claim 2, It is characterized in that The outlier processing includes: Detecting illegal characters in the read data and removing the illegal characters; The feature specification includes: Feature assignment is accomplished by combining the performance of different feature combinations determined by the combined search calculation and user-defined combinations; The outlier processing includes: The outlier data were removed by 3-sigma method and IQR method.
4. The method according to claim 3, It is characterized in that The data standardization includes: The read data is standardized by using a Scaler standardization calculation formula and a Minmax standardization calculation formula; The Scaler normalization calculation formula is: in, Represents the data value after Scaler standardization. Represents the original data value, represents the mean of the data, Indicates the standard deviation of the data; The Minmax normalization calculation formula is: in, Represents the data value after Minmax standardization, Represents the original data value, Indicates the maximum value in the data. Indicates the minimum value in the data; The PCA dimensionality reduction includes: For the read data, determine a data set, and calculate a covariance matrix of the data set; Performing eigenvalue decomposition on the covariance matrix; A preset number of features are determined in the read data, the cumulative contribution rates of the features are calculated, and the cumulative contribution rates and the decomposed eigenvalues are projected onto the data set to complete PCA dimensionality reduction.
5. The method according to claim 4, It is characterized in that The data smoothing includes: Data smoothing is performed using a simple moving average formula and a weighted moving average formula; wherein the simple moving average formula is: in, Indicates The simple moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The value of the data point; The weighted moving average formula is: in, Indicates The weighted moving average of time, Indicates the window size, that is, the number of data points involved in calculating the average value. Indicates The weight of the data point, Indicates The value of the data point; The interpolation includes: The interpolation calculation is completed by the interpolation formula; wherein the interpolation formula is: in, represents the estimated value of the target interpolation point, Represents the window radius, which determines the number of left and right data points used for interpolation. Indicates the window relative to The offset from arrive , Indicates the location The data point value at ; The upper and lower limit corrections include: The prediction result is corrected by a correction formula; wherein the correction formula is: in, represents the revised forecast result, represents the original prediction result, Indicates the lower threshold of the result, Indicates the upper threshold of the result.
6. The method according to claim 5, It is characterized in that The evaluating the selected prediction model according to the prediction result and the result data set includes: The selected prediction model is evaluated according to the prediction result and the result data set by using the MAPE formula, RMSE formula, MAE formula, ACC formula and RMSPE formula; wherein the MAPE formula is: in, represents the calculated mean absolute percentage error, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The RMSE formula is: in, represents the calculated root mean square error, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The MAE formula is: in, represents the calculated mean absolute error, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The ACC formula is: 00% in, represents the calculated percentage accuracy, represents the number of data points to be calculated, Indicates the actual value, represents the predicted value; The RMSPE formula is: in, represents the calculated root mean square percentage error, represents the number of data points to be calculated, Indicates the actual value, Represents the predicted value.
7. The method according to claim 6, It is characterized in that Also includes: Customize operators based on operator templates.
8. A multi-type power time series prediction device, It is characterized in that include: The task parameter acquisition module is used to obtain the task parameters set by the user according to business needs; wherein the task parameters at least include: prediction object, task type, training and prediction date; wherein the task type includes: training task, prediction task, backtesting task and tuning task; A workflow framework adjustment module, used to customize the operators in the workflow framework according to the task parameters; A scheduler module, used for generating a task file according to the task parameters; The executor module is used to assign values to variables through the executor according to the task file, complete the corresponding algorithm model construction through the workflow pipeline framework, execute the task workflow of the specified type, complete the prediction through the task file corresponding to the prediction task, and store the prediction results in a preset database.
9. A multi-type power time series prediction device, It is characterized in that The invention comprises a processor and a memory, wherein the processor is connected to the memory: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store the program, and the program is at least used to execute the multiple types of power time series prediction methods described in any one of claims 1-7.
Citation Information
Patent Citations
Prediction method and system for configuration machine learning modeling task description
CN114169531A
Zero code modeling method and system based on automatic machine learning
CN115080021A
Automatic learning method and system for time series data prediction
CN117010444A
Power time series data prediction algorithm integrated management system and method
CN117473440A
Ensemble learning model for time-series forecasting
US20240346389A1
