Electricity consumption prediction method and device, electronic equipment and storage medium
By combining the time series prediction model and the random forest model, outliers are corrected and predicted for historical electricity consumption data, and the problem of low accuracy of electricity consumption prediction in the prior art is solved, and higher prediction accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202411823862.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-08
AI Technical Summary
The prior art has low accuracy in power load prediction, and it is difficult to effectively capture complex relationships and outliers in power consumption data.
Using a method combining the time series prediction model and the random forest model, the power consumption data of multiple historical periods is obtained, outlier correction is performed, the reference power consumption value is predicted using the time series model, and the final power consumption prediction is performed through the random forest model.
It improves the accuracy and reliability of power consumption prediction, and can more effectively capture trends, seasonalities and outliers in power consumption data, providing more accurate prediction results.
Smart Images

Figure CN119787314A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power consumption prediction, and in particular to a power consumption prediction method, device, electronic equipment and storage medium. Background Art
[0002] The accuracy of power load forecasting is directly related to the planning of power grid enterprises, the layout of the entire power grid, the rationality of power grid operation, and the stability of power grid operation. At present, statistical methods and time series models are mainly used to predict future power consumption by analyzing the regular changes of historical data. Although future power consumption can be predicted, the accuracy of the predicted power consumption is not high. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device and storage medium for predicting power consumption, which improve the accuracy of power consumption prediction.
[0004] In a first aspect, an embodiment of the present application provides a method for predicting power consumption, which is applied to a power consumption prediction system. The power consumption prediction system includes a time series prediction model and a random forest model. The method includes:
[0005] Acquire multiple historical electricity consumption data corresponding to multiple historical year periods; each historical electricity consumption data corresponds to a historical year period;
[0006] Perform outlier correction on multiple historical electricity consumption data to obtain multiple target historical electricity consumption data;
[0007] The reference electricity consumption value corresponding to the target day in the target year segment is predicted based on multiple target historical electricity consumption data through a time series prediction model; the target day in the target year segment is a day in the future;
[0008] The target daily electricity consumption forecast value corresponding to the target day is determined by the random forest model based on multiple target historical electricity consumption data and reference electricity consumption values.
[0009] In a second aspect, an embodiment of the present application provides a power consumption prediction device, which is applied to a power consumption prediction system, the power consumption prediction system includes a time series prediction model and a random forest model, and the power consumption prediction device includes: an acquisition unit and a processing unit;
[0010] An acquisition unit, used to acquire a plurality of historical electricity consumption data corresponding to a plurality of historical year periods; each historical electricity consumption data corresponds to a historical year period;
[0011] A processing unit, used for correcting abnormal values of a plurality of historical power consumption data to obtain a plurality of target historical power consumption data;
[0012] The reference electricity consumption value corresponding to the target day in the target year segment is predicted based on multiple target historical electricity consumption data through a time series prediction model; the target day in the target year segment is a day in the future;
[0013] The target daily electricity consumption forecast value corresponding to the target day is determined by the random forest model based on multiple target historical electricity consumption data and reference electricity consumption values.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor so that the electronic device executes the method of the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, so that a computer executes the method of the first aspect.
[0017] The implementation of the present application has the following beneficial effects:
[0018] It can be seen that the electricity consumption prediction method described in the implementation mode of the present application first obtains multiple historical electricity consumption data corresponding to multiple historical year periods, then corrects the multiple historical electricity consumption data for outliers to obtain multiple target historical electricity consumption data, and then uses a time series prediction model to predict the reference electricity consumption value corresponding to the target day within the target year period based on the multiple target historical electricity consumption data. Finally, a random forest model is used to determine the target day electricity consumption prediction value corresponding to the target day based on the multiple target historical electricity consumption data and the reference electricity consumption value, thereby improving the accuracy of electricity consumption prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the implementation methods of the present application or the background technology, the drawings required for use in the implementation methods of the present application or the background technology will be described below.
[0020] Figure 1 It is a structural schematic diagram of a power consumption prediction system provided in an embodiment of the present application;
[0021] Figure 2 is a flow chart of a method for predicting power consumption provided by an embodiment of the present application;
[0022] Figure 3It is a structural schematic diagram of a power consumption prediction device provided in an embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the implementation mode of the present application. Obviously, the described implementation mode is only a part of the implementation mode of the present application, not all the implementation modes. Based on the implementation mode in the present application, all other implementation modes obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0025] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0026] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0027] See also Figure 1 , Figure 1It is a structural diagram of a power consumption prediction system provided by an embodiment of the present application. The power consumption prediction system 10 includes a time series prediction model 101 and a random forest model 102. The time series prediction model 101 can discover patterns such as trends, seasonality, and periodicity in the data based on historical time series data, and use these patterns to predict power consumption for future values. It has a good ability to capture the inherent patterns of time series data and is suitable for data sets with obvious trends and seasonality. The random forest model 102 is an integrated learning algorithm that predicts by constructing multiple decision trees and combining their results. In power consumption prediction, the random forest can use power consumption and multiple related influencing factors as input features. Through integrated learning of a large number of decision trees, it can effectively handle the complex relationship between features and has good noise resistance and generalization capabilities.
[0028] In this embodiment, first, multiple historical electricity consumption data corresponding to multiple historical year periods are obtained, wherein each historical electricity consumption data corresponds to a historical year period, and then the multiple historical electricity consumption data are corrected for outliers to obtain multiple target historical electricity consumption data. Next, the time series prediction model 101 is used to predict the reference electricity consumption value corresponding to the target day in the target year period based on the multiple target historical electricity consumption data, wherein the target day in the target year period is a day in the future. Finally, the random forest model 102 is used to determine the target day electricity consumption prediction value corresponding to the target day based on the multiple target historical electricity consumption data and the reference electricity consumption value. By combining the time series prediction model 101 and the random forest model 102, the advantages of the time series prediction model 101 and the random forest model 102 can be fully utilized to improve the accuracy and reliability of electricity consumption prediction.
[0029] See also Figure 2 , Figure 2 This is a flow chart of a method for predicting power consumption provided by an embodiment of the present application, including but not limited to the following steps:
[0030] S201: Obtain multiple historical electricity consumption data corresponding to multiple historical years.
[0031] In this embodiment, each historical electricity consumption data corresponds to a historical year period. Each historical electricity consumption data includes electricity consumption value, electricity consumption value recording time, season of electricity consumption, holiday data and weather conditions, etc. In this embodiment, the multiple historical year periods include at least three historical year periods.
[0032] S202: Perform outlier correction on a plurality of historical electricity consumption data to obtain a plurality of target historical electricity consumption data.
[0033] In this embodiment, each target historical electricity consumption data includes multiple daily electricity consumption data. Exemplarily, the daily electricity consumption threshold range corresponding to the multiple historical electricity consumption data is determined. The traditional method of determining abnormal data is to use the 3σ criterion to determine the mean and standard deviation of the historical electricity consumption data, thereby determining the daily electricity consumption threshold range based on the mean and standard deviation. However, in this embodiment, the exponential weighted average corresponding to m daily electricity consumption data in the multiple historical electricity consumption data is first determined, and the exponential weighted average is used to replace the mean value in the 3σ criterion. Then, the standard deviation corresponding to the m daily electricity consumption data is determined based on the exponential weighted average, and the standard deviation is used to replace the standard deviation in the 3σ criterion, thereby determining the maximum electricity consumption threshold and the minimum electricity consumption threshold corresponding to the multiple historical electricity consumption data based on the exponential weighted average and the standard deviation, wherein the maximum electricity consumption threshold and the minimum electricity consumption threshold are specifically calculated according to the following formula:
[0034]
[0035] Among them, max is the maximum threshold of power consumption, min is the minimum threshold of power consumption, and v i is the exponentially weighted mean, σ i is the standard deviation.
[0036] Finally, the daily power consumption threshold range is determined based on the maximum power consumption threshold and the minimum power consumption threshold. The power consumption threshold range is (v i -3σ i , v i +3σ i ).
[0037] It can be seen that the exponentially weighted average gives higher weights to recent data, and can reflect the latest changing trends in electricity consumption more promptly. Compared with the simple average in the traditional method, it is more timely and adaptable. The exponentially weighted average is relatively less affected by outliers, and can provide a more stable and reliable central trend estimate, thereby making the subsequently determined threshold range more accurate. The maximum and minimum thresholds for electricity consumption determined based on the more accurate exponentially weighted average and the corresponding standard deviation, and thus the determined daily electricity consumption threshold range, are more reasonable, which helps to more accurately identify normal and abnormal electricity consumption data and improve the accuracy of electricity consumption forecasting and analysis.
[0038] Exemplarily, k abnormal daily electricity consumption data that are outside the daily electricity consumption threshold range are determined among multiple historical electricity consumption data, wherein the multiple historical electricity consumption data include m daily electricity consumption data, m is a positive integer, and k is a positive integer less than or equal to m, and then a correction value corresponding to each abnormal daily electricity consumption data among the k abnormal daily electricity consumption data is determined to obtain k correction values. First, the correction value corresponding to the first abnormal daily electricity consumption data is determined, and the first abnormal daily electricity consumption data is any one of the k abnormal daily electricity consumption data. The correction value corresponding to each abnormal daily electricity consumption data among the k abnormal daily electricity consumption data is determined according to the method for determining the correction value corresponding to the first abnormal daily electricity consumption data.
[0039] Specifically, the correction value corresponding to the first abnormal daily electricity consumption data is determined according to the following method: illustratively, the first electricity consumption recording time period corresponding to the first abnormal daily electricity consumption data is determined. Specifically, any one of the k daily electricity consumption data determined to be abnormal is selected and defined as the first abnormal daily electricity consumption data. The specific time period corresponding to the first abnormal daily electricity consumption data is found, that is, the first electricity consumption recording time period. Exemplarily, a second electricity consumption recording time period and a third electricity consumption recording time period with the shortest interval with the first electricity consumption recording time period are determined, and the second day's electricity consumption data corresponding to the second electricity consumption recording time period and the third day's electricity consumption data corresponding to the third electricity consumption recording time period are determined, wherein the second electricity consumption recording time period is located before the first electricity consumption recording time period, the third electricity consumption recording time period is located after the first electricity consumption recording time period, and the second day's electricity consumption data and the third day's electricity consumption data are both within the daily electricity consumption threshold range. Specifically, on the basis of the first electricity consumption recording time period that has been determined, it is necessary to determine two electricity consumption recording time periods that are closest to the first electricity consumption recording time period and whose electricity consumption data are within the daily electricity consumption threshold range, namely the second electricity consumption recording time period and the third electricity consumption recording time period, and determine the second day's electricity consumption data corresponding to the second electricity consumption recording time period and the third day's electricity consumption data corresponding to the third electricity consumption recording time period. It needs to be explained that the second electricity consumption recording time period is located before the first electricity consumption recording time period, the third electricity consumption recording time period is located after the first electricity consumption recording time period, and the second day's electricity consumption data and the third day's electricity consumption data are both within the daily electricity consumption threshold range. Exemplarily, the average value of the second day's electricity consumption data and the third day's electricity consumption data is determined to obtain a correction value corresponding to the first abnormal day's electricity consumption data. Specifically, the second day's electricity consumption data and the third day's electricity consumption data obtained previously are averaged, and the obtained average value is used as the correction value of the first abnormal day's electricity consumption data, which is used to adjust or correct the first abnormal day's electricity consumption data.
[0040] According to the above method, the correction value corresponding to each abnormal daily electricity consumption data in the k abnormal daily electricity consumption data is determined. After obtaining the k correction values, the k abnormal daily electricity consumption data in the multiple historical electricity consumption data are replaced based on the k correction values to obtain multiple target historical electricity consumption data. Specifically, the k correction values are used to replace the corresponding k abnormal daily electricity consumption data in the original multiple historical electricity consumption data. After such replacement operation, a group of new electricity consumption data is obtained. This group of new data is called multiple target historical electricity consumption data, that is, the k daily electricity consumption data originally judged to be abnormal are replaced with the recalculated correction values, so that the entire historical electricity consumption data is more accurate and reasonable, which can be used for subsequent analysis and prediction and other work.
[0041] It can be seen that by identifying and correcting abnormal daily electricity consumption data, the historical electricity consumption data can more accurately reflect the actual electricity consumption situation, reduce the interference of abnormal values on subsequent analysis and prediction, determine the correction value in a reasonable way, and make corrections based on the normal data in the time period adjacent to the abnormal value. This increases the reliability and rationality of the corrected data. Instead of simply deleting the abnormal data, the correction and replacement are performed, which retains the integrity of the data and makes full use of all available information. The abnormal values are corrected based on the normal data in the adjacent time period, which is more in line with the continuity and trend of actual electricity consumption and avoids unreasonable fluctuations caused by abnormal values.
[0042] S203: Predicting a reference electricity consumption value corresponding to a target day within a target year period based on a plurality of target historical electricity consumption data using a time series prediction model.
[0043] In this embodiment, the target day in the target year is a day in the future. The time series prediction model can decompose the time series into trend items, cycle items, holiday items, and random fluctuation items. The time series prediction model can be described as y(t)=g(t)+s(t)+h(t)+ε(t), where y(t) represents the time series prediction model, g(t) represents the trend item, s(t) represents the cycle item, h(t) represents the holiday item, and ε(t) represents the random fluctuation item.
[0044] The trend term is used to capture the long-term growth or decline trend of the time series. Usually, the prophet algorithm provides two methods for modeling trends: linear trend and logistic trend. The time series prediction model uses a piecewise linear trend. The prophet algorithm can identify the change points in the trend where the slope changes. The fitting formula of the trend term can be written as:
[0045]
[0046] Where k(t) is the intercept of the initial linear trend, δ i Indicates the change point s iThe subsequent slope change, f(s i ≤t≤s i+1 ) is an exponential function, when t≤s i When s i ≤t≤s i+1 When i , when t≥s i+1 When i+1 -s i .
[0047] The periodic term simulates the seasonality of the time series by using Fourier series to capture the periodic fluctuations in the time series. The fitting formula of the periodic term is:
[0048]
[0049] Among them, U represents the expansion length, α u and β u is the Fourier coefficient to be fitted, P is the period to be set, and considering the impact of leap years and different numbers of days in each month, three periodic items are set for the year, month and week respectively during the forecast.
[0050] The holiday item is used to capture the impact of holidays or special dates on time series. In addition to holidays, some special time periods affected by other factors can also be set accordingly. The calculation formula for the holiday item is:
[0051]
[0052] Where: D i (t) is an exponential function. If the i-th day is a holiday, D i (t) is 1, otherwise it is 0, β i is the size of the fitted holiday effect (regression coefficient).
[0053] The random fluctuation term is used to describe the random errors or noise that cannot be explained by systematic factors such as trend, seasonality and holiday effects. It reflects the random fluctuations that the model fails to capture and is an inevitable part of the time series model. The random fluctuation term can be obtained by subtracting the fitted trend, cycle and holiday terms from the actual term.
[0054] Specifically, the target historical electricity consumption data is first used to fit the corresponding trend items, cycle items and holiday items, and then the reference electricity consumption value corresponding to the target day in the target year period is determined based on the corresponding trend items, cycle items and holiday items.
[0055] It can be seen that decomposing the time series into trend items, cycle items, holiday items and random fluctuation items can more comprehensively capture the various influencing factors in the electricity consumption data, thereby improving the accuracy of the forecast, and by accurately fitting each sub-item, the reference electricity consumption value of the target day can be more accurately determined.
[0056] S204: Determine a target day electricity consumption forecast value corresponding to the target day based on multiple target historical electricity consumption data and reference electricity consumption values through a random forest model.
[0057] In this embodiment, the random forest model includes p random forest sub-models, where p is an integer. Exemplarily, p samplings are performed from a plurality of target historical electricity consumption data to obtain p sample sets, each sample set corresponds to a random forest sub-model. Specifically, p random sampling operations are performed on the plurality of target historical electricity consumption data, each sampling forms an independent sample set, and each sample set is used to be input into a corresponding random forest sub-model for processing.
[0058] Exemplarily, p sample sets are respectively input into p random forest sub-models to obtain p first-day electricity consumption values, each sample set corresponding to a first-day electricity consumption value. Specifically, firstly, based on the first sample set, multiple reference days before the historical target day corresponding to the target day and multiple historical daily electricity consumption values corresponding to the multiple reference days are determined. The first sample set is any sample set among the p sample sets, and the historical target day is the same day as the target day in the historical year segment. Specifically, any one of the p sample sets is called the first sample set, and then according to this sample set, multiple dates before the same date (i.e., the historical target day) of the target day in the past historical year segment are found as reference days, and the historical daily electricity consumption values corresponding to these reference days are obtained. Exemplarily, multiple reference days and multiple historical daily electricity consumption values corresponding to the multiple reference days are input into the first random forest sub-model to obtain the third day electricity consumption value corresponding to the first sample set. The first random forest sub-model is the random forest sub-model corresponding to the first sample set. Specifically, the multiple reference days determined previously and their corresponding historical daily electricity consumption values are input into the random forest sub-model corresponding to the first sample set, thereby obtaining a preliminary electricity consumption value, which is referred to as the third day electricity consumption value. Exemplarily, the holiday data in the first sample set is obtained, and the target optimization factor corresponding to the holiday data is determined. Specifically, it can be a mapping relationship between the preset holiday data and the optimization factor. Based on the mapping relationship, the target optimization factor corresponding to the holiday data can be determined. Exemplarily, the third day electricity consumption value is optimized based on the target optimization factor to obtain the first day electricity consumption value corresponding to the first sample set. Specifically, the specific calculation formula is as follows: the first day electricity consumption value = the third day electricity consumption value × (1 + target optimization factor). According to the above formula, the first day electricity consumption value can be obtained.
[0059] It can be seen that by determining multiple reference days and their electricity consumption values before the historical target date, more useful information can be mined from historical data, providing a richer basis for prediction. Obtaining holiday data in the sample set and determining the corresponding optimization factors can more accurately reflect the special impact of holidays on electricity consumption and improve the accuracy of predictions in special periods. Through multiple random forest sub-models and comprehensive optimization steps, the excessive impact of a single factor or random error on the prediction results is reduced, making the prediction results more stable.
[0060] Exemplarily, the second day's electricity consumption value is determined based on p first day's electricity consumption values. Specifically, a weight can be assigned to each first day's electricity consumption value, and the weight can be determined based on the importance, reliability or other relevant factors of the sample. Then, each first day's electricity consumption value is multiplied by its corresponding weight, all the products are added together, and finally divided by the sum of the weights. The result is used as the second day's electricity consumption value.
[0061] Exemplarily, the second day's electricity consumption value is corrected based on the reference day's electricity consumption value to obtain a target daily electricity consumption forecast value corresponding to the target day. Specifically, the daily electricity consumption difference between the reference day's electricity consumption value and the second day's electricity consumption value is first determined, and then the target correction coefficient corresponding to the daily electricity consumption difference is determined, which may be a preset mapping relationship between the daily electricity consumption difference and the correction coefficient. Based on the mapping relationship, the target correction coefficient corresponding to the daily electricity consumption difference can be determined, and then the second day's electricity consumption value is corrected based on the target correction coefficient to obtain the target daily electricity consumption forecast value corresponding to the target day. Specifically, the specific calculation formula is as follows: target daily electricity consumption forecast value = second day's electricity consumption value × (1 + target correction coefficient). The target daily electricity consumption forecast value can be obtained according to the above formula.
[0062] It can be seen that integrating the results of multiple sub-models and making corrections reduces the sensitivity of the model to individual abnormal data or model errors, making the prediction results more stable and reliable. Considering the reference daily electricity consumption value to correct the second day's electricity consumption value can incorporate prior knowledge or other reliable reference information into the prediction, making the final target daily electricity consumption prediction value more reasonable and closer to reality. The determination of the target correction coefficient corresponding to the daily electricity consumption difference can flexibly adjust the prediction results according to actual conditions, adapt to different data distributions and complex changes in electricity consumption patterns, and make the electricity consumption prediction results more accurate.
[0063] It should be noted that, in this embodiment, based on the method for determining the target day power consumption forecast value corresponding to the target day, the target day power consumption forecast value corresponding to each day in the target year period can be determined, and n target day power consumption forecast values are obtained, where n is an integer. After obtaining the n target day power consumption forecast values, the power consumption forecast effect of the random forest model can be evaluated. Specifically, first, a target historical year period that is closest to the target year period is selected from multiple historical year periods, and then the n target historical daily power consumption values corresponding to each day in the target historical year period are determined. Finally, the power consumption forecast effect value of the random forest model is determined based on the n target day power consumption forecast values and the n target historical daily power consumption values. The smaller the power consumption forecast effect value, the better the power consumption forecast effect of the random forest model. The calculation is specifically performed according to the following formula:
[0064]
[0065] Among them, MAPE is the power consumption prediction effect value of the random forest model, S i is the target daily electricity consumption forecast value corresponding to the i-th day, T i is the target historical daily electricity consumption value corresponding to the i-th day.
[0066] It can be seen that evaluating the electricity consumption prediction effect of the random forest model helps to discover the problems and shortcomings of the random forest model, so as to adjust the parameters, feature selection or algorithm of the random forest model in a targeted manner to improve the prediction accuracy and performance of the random forest model. Comparison and calculation based on specific daily data can more carefully evaluate the prediction performance of the model on different dates, thereby enhancing the reliability and stability of the prediction results.
[0067] In summary, the implementation of the embodiments of this application has the following beneficial effects:
[0068] It can be seen that the electricity consumption prediction method described in the implementation mode of the present application first obtains multiple historical electricity consumption data corresponding to multiple historical year periods, then corrects the multiple historical electricity consumption data for outliers to obtain multiple target historical electricity consumption data, and then predicts the reference electricity consumption value corresponding to the target day in the target year period based on the multiple target historical electricity consumption data through a time series prediction model, and finally determines the target day electricity consumption prediction value corresponding to the target day based on the multiple target historical electricity consumption data and the reference electricity consumption value through a random forest model, thereby improving the accuracy of electricity consumption prediction.
[0069] See also Figure 3 , Figure 3It is a structural schematic diagram of a power consumption prediction device provided in an embodiment of the present application. The power consumption prediction device 300 is applied to a power consumption prediction system. The power consumption prediction system includes a time series prediction model and a random forest model. The power consumption prediction device 300 includes: an acquisition unit 301 and a processing unit 302;
[0070] The acquisition unit 301 is used to acquire a plurality of historical electricity consumption data corresponding to a plurality of historical year periods; each historical electricity consumption data corresponds to a historical year period;
[0071] The processing unit 302 is used to correct the abnormal values of the multiple historical power consumption data to obtain multiple target historical power consumption data;
[0072] The reference electricity consumption value corresponding to the target day in the target year segment is predicted based on multiple target historical electricity consumption data through a time series prediction model; the target day in the target year segment is a day in the future;
[0073] The target daily electricity consumption forecast value corresponding to the target day is determined by the random forest model based on multiple target historical electricity consumption data and reference electricity consumption values.
[0074] In some possible implementations, in obtaining multiple target historical power consumption data by performing abnormal value correction on multiple historical power consumption data, the processing unit 302 is specifically configured to:
[0075] Determine a daily power consumption threshold range corresponding to multiple historical power consumption data;
[0076] Determine k abnormal daily power consumption data outside the daily power consumption threshold range from multiple historical power consumption data; the multiple historical power consumption data include m daily power consumption data, m is a positive integer, and k is a positive integer less than or equal to m;
[0077] According to the determination method in the following steps S1-S3, the correction value corresponding to each abnormal daily power consumption data in the k abnormal daily power consumption data is determined to obtain k correction values, which is specifically the following steps:
[0078] S1. Determine a first power consumption recording time period corresponding to the first abnormal daily power consumption data; the first abnormal daily power consumption data is any one of k abnormal daily power consumption data;
[0079] S2, determine the second electricity consumption recording time period and the third electricity consumption recording time period with the shortest interval with the first electricity consumption recording time period, and determine the second day electricity consumption data corresponding to the second electricity consumption recording time period and the third day electricity consumption data corresponding to the third electricity consumption recording time period; the second electricity consumption recording time period is before the first electricity consumption recording time period, the third electricity consumption recording time period is after the first electricity consumption recording time period, and the second day electricity consumption data and the third day electricity consumption data are both within the daily electricity consumption threshold range;
[0080] S3, determining the average value of the second day's electricity consumption data and the third day's electricity consumption data, and obtaining a correction value corresponding to the first abnormal day's electricity consumption data;
[0081] K abnormal daily electricity consumption data in a plurality of historical electricity consumption data are replaced based on k correction values to obtain a plurality of target historical electricity consumption data.
[0082] In some possible implementations, in determining the daily power consumption threshold range corresponding to the plurality of historical power consumption data, the processing unit 302 is specifically configured to:
[0083] Determine the exponentially weighted average corresponding to m daily electricity consumption data from multiple historical electricity consumption data;
[0084] Determine the standard deviation corresponding to m daily electricity consumption data based on the exponentially weighted average;
[0085] Based on the exponential weighted average and the standard deviation, the maximum power consumption threshold and the minimum power consumption threshold corresponding to the multiple historical power consumption data are determined, wherein the maximum power consumption threshold and the minimum power consumption threshold are specifically calculated according to the following formula:
[0086]
[0087] Among them, max is the maximum threshold of power consumption, min is the minimum threshold of power consumption, and v i is the exponentially weighted mean, σ i is the standard deviation;
[0088] The daily power consumption threshold range is determined based on the maximum power consumption threshold and the minimum power consumption threshold.
[0089] In some possible implementations, in determining the target day power consumption forecast value corresponding to the target day based on multiple target historical power consumption data and reference power consumption values through a random forest model, the processing unit 302 is specifically configured to:
[0090] Extract p times from multiple target historical electricity consumption data to obtain p sample sets; each sample set corresponds to a random forest sub-model;
[0091] Input the p sample sets into the p random forest sub-models respectively to obtain p first-day electricity consumption values; each sample set corresponds to a first-day electricity consumption value;
[0092] Determine the power consumption value for the second day based on the p power consumption values for the first day;
[0093] The second day's electricity consumption value is corrected based on the reference day's electricity consumption value to obtain a target day's electricity consumption forecast value corresponding to the target day.
[0094] In some possible implementations, in terms of inputting the p sample sets into the p random forest sub-models respectively to obtain the p first-day electricity consumption values, the processing unit 302 is specifically configured to:
[0095] Determine multiple reference days before the historical target day corresponding to the target day and multiple historical daily electricity consumption values corresponding to the multiple reference days based on the first sample set; the first sample set is any sample set among the p sample sets, and the historical target day is the same day as the target day in the historical year segment;
[0096] Input multiple reference days and multiple historical daily electricity consumption values corresponding to the multiple reference days into the first random forest sub-model to obtain the third day electricity consumption value corresponding to the first sample set; the first random forest sub-model is the random forest sub-model corresponding to the first sample set;
[0097] Get the holiday data in the first sample set;
[0098] Determine the target optimization factor corresponding to holiday data;
[0099] The electricity consumption value of the third day is optimized based on the target optimization factor to obtain the electricity consumption value of the first day corresponding to the first sample set.
[0100] In some possible implementations, in terms of correcting the second day power consumption value based on the reference day power consumption value to obtain the target day power consumption forecast value corresponding to the target day, the processing unit 302 is specifically configured to:
[0101] Determining a daily power consumption difference between a reference daily power consumption value and a second daily power consumption value;
[0102] Determine the target correction factor corresponding to the daily power consumption difference;
[0103] The second day's electricity consumption value is corrected based on the target correction coefficient to obtain the target day's electricity consumption forecast value corresponding to the target day.
[0104] In some possible implementations, the processing unit 302 is further specifically configured to:
[0105] Determine the target daily electricity consumption forecast value corresponding to each day in the target year period, and obtain n target daily electricity consumption forecast values; n is an integer;
[0106] Select a target historical year segment that is closest to the target historical year segment from among multiple historical year segments;
[0107] Determine n target historical daily electricity consumption values corresponding to each day in the target historical year period;
[0108] The power consumption prediction effect value of the random forest model is determined based on the n target daily power consumption prediction values and the n target historical daily power consumption values. The smaller the power consumption prediction effect value, the better the power consumption prediction effect of the random forest model. The specific calculation is based on the following formula:
[0109]
[0110] Among them, MAPE is the power consumption prediction effect value of the random forest model, S i is the target daily electricity consumption forecast value corresponding to the i-th day, T i is the target historical daily electricity consumption value corresponding to the i-th day.
[0111] See also Figure 4 , Figure 4 Schematic diagram of the structure of an electronic device provided by the embodiment of the present application. Figure 4 As shown, the electronic device 400 includes a transceiver 401, a processor 402 and a memory 403. They are connected via a bus 404. The memory 403 is used to store computer programs and data, and the transceiver 401 can transmit the data stored in the memory 403 to the processor 402. The above program includes instructions for executing the following steps:
[0112] Acquire multiple historical electricity consumption data corresponding to multiple historical year periods; each historical electricity consumption data corresponds to a historical year period;
[0113] Perform outlier correction on multiple historical electricity consumption data to obtain multiple target historical electricity consumption data;
[0114] The reference electricity consumption value corresponding to the target day in the target year segment is predicted based on multiple target historical electricity consumption data through a time series prediction model; the target day in the target year segment is a day in the future;
[0115] The target daily electricity consumption forecast value corresponding to the target day is determined by the random forest model based on multiple target historical electricity consumption data and reference electricity consumption values.
[0116] In some possible implementations, in terms of obtaining multiple target historical power consumption data by performing outlier correction on multiple historical power consumption data, the above program includes instructions for performing the following steps:
[0117] Determine a daily power consumption threshold range corresponding to multiple historical power consumption data;
[0118] Determine k abnormal daily power consumption data outside the daily power consumption threshold range from multiple historical power consumption data; the multiple historical power consumption data include m daily power consumption data, m is a positive integer, and k is a positive integer less than or equal to m;
[0119] According to the determination method in the following steps S1-S3, the correction value corresponding to each abnormal daily power consumption data in the k abnormal daily power consumption data is determined to obtain k correction values, which is specifically the following steps:
[0120] S1. Determine a first power consumption recording time period corresponding to the first abnormal daily power consumption data; the first abnormal daily power consumption data is any one of k abnormal daily power consumption data;
[0121] S2, determine the second electricity consumption recording time period and the third electricity consumption recording time period with the shortest interval with the first electricity consumption recording time period, and determine the second day electricity consumption data corresponding to the second electricity consumption recording time period and the third day electricity consumption data corresponding to the third electricity consumption recording time period; the second electricity consumption recording time period is before the first electricity consumption recording time period, the third electricity consumption recording time period is after the first electricity consumption recording time period, and the second day electricity consumption data and the third day electricity consumption data are both within the daily electricity consumption threshold range;
[0122] S3, determining the average value of the second day's electricity consumption data and the third day's electricity consumption data, and obtaining a correction value corresponding to the first abnormal day's electricity consumption data;
[0123] K abnormal daily electricity consumption data in a plurality of historical electricity consumption data are replaced based on k correction values to obtain a plurality of target historical electricity consumption data.
[0124] In some possible implementations, in terms of determining a daily power consumption threshold range corresponding to a plurality of historical power consumption data, the above program includes instructions for performing the following steps:
[0125] Determine the exponentially weighted average corresponding to m daily electricity consumption data from multiple historical electricity consumption data;
[0126] Determine the standard deviation corresponding to m daily electricity consumption data based on the exponentially weighted average;
[0127] Based on the exponential weighted average and the standard deviation, the maximum power consumption threshold and the minimum power consumption threshold corresponding to the multiple historical power consumption data are determined, wherein the maximum power consumption threshold and the minimum power consumption threshold are specifically calculated according to the following formula:
[0128]
[0129] Among them, max is the maximum threshold of power consumption, min is the minimum threshold of power consumption, and vi is the exponentially weighted mean, σ i is the standard deviation;
[0130] The daily power consumption threshold range is determined based on the maximum power consumption threshold and the minimum power consumption threshold.
[0131] In some possible implementations, in determining the target day electricity consumption forecast value corresponding to the target day based on multiple target historical electricity consumption data and reference electricity consumption values through a random forest model, the above program includes instructions for performing the following steps:
[0132] Extract p times from multiple target historical electricity consumption data to obtain p sample sets; each sample set corresponds to a random forest sub-model;
[0133] Input the p sample sets into the p random forest sub-models respectively to obtain p first-day electricity consumption values; each sample set corresponds to a first-day electricity consumption value;
[0134] Determine the power consumption value for the second day based on the p power consumption values for the first day;
[0135] The second day's electricity consumption value is corrected based on the reference day's electricity consumption value to obtain a target day's electricity consumption forecast value corresponding to the target day.
[0136] In some possible implementations, in terms of inputting the p sample sets into the p random forest sub-models respectively to obtain the p first-day electricity consumption values, the program includes instructions for executing the following steps:
[0137] Determine multiple reference days before the historical target day corresponding to the target day and multiple historical daily electricity consumption values corresponding to the multiple reference days based on the first sample set; the first sample set is any sample set among the p sample sets, and the historical target day is the same day as the target day in the historical year segment;
[0138] Input multiple reference days and multiple historical daily electricity consumption values corresponding to the multiple reference days into the first random forest sub-model to obtain the third day electricity consumption value corresponding to the first sample set; the first random forest sub-model is the random forest sub-model corresponding to the first sample set;
[0139] Get the holiday data in the first sample set;
[0140] Determine the target optimization factor corresponding to holiday data;
[0141] The electricity consumption value of the third day is optimized based on the target optimization factor to obtain the electricity consumption value of the first day corresponding to the first sample set.
[0142] In some possible implementations, in terms of correcting the second day power consumption value based on the reference day power consumption value to obtain the target day power consumption forecast value corresponding to the target day, the above program includes instructions for executing the following steps:
[0143] Determining a daily power consumption difference between a reference daily power consumption value and a second daily power consumption value;
[0144] Determine the target correction factor corresponding to the daily power consumption difference;
[0145] The second day's electricity consumption value is corrected based on the target correction coefficient to obtain the target day's electricity consumption forecast value corresponding to the target day.
[0146] In some possible implementations, the above program includes instructions for performing the following steps:
[0147] Determine the target daily electricity consumption forecast value corresponding to each day in the target year period, and obtain n target daily electricity consumption forecast values; n is an integer;
[0148] Select a target historical year segment that is closest to the target historical year segment from among multiple historical year segments;
[0149] Determine n target historical daily electricity consumption values corresponding to each day in the target historical year period;
[0150] The power consumption prediction effect value of the random forest model is determined based on the n target daily power consumption prediction values and the n target historical daily power consumption values. The smaller the power consumption prediction effect value, the better the power consumption prediction effect of the random forest model. The specific calculation is based on the following formula:
[0151]
[0152] Among them, MAPE is the power consumption prediction effect value of the random forest model, S i is the target daily electricity consumption forecast value corresponding to the i-th day, T i is the target historical daily electricity consumption value corresponding to the i-th day.
[0153] It should be understood that the electronic devices in this application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices MID (Mobile Internet Devices, MID for short) or wearable devices or servers, edge computing nodes, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices.
[0154] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement part or all of the steps of any one of the power consumption prediction methods described in the above method embodiments.
[0155] The embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be operated to cause a computer to execute part or all of the steps of any one of the electricity consumption prediction methods recorded in the above method embodiments.
[0156] It should be noted that, for the above-mentioned various method implementations, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the implementations described in the specification are all optional implementations, and the actions and modules involved are not necessarily required by this application.
[0157] In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0158] In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device implementation described above is only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0160] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0161] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of each implementation method of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0162] A person skilled in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0163] The above is a detailed introduction to the implementation methods of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above implementation methods is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for predicting power consumption, characterized in that: Applied to a power consumption prediction system, the power consumption prediction system includes a time series prediction model and a random forest model, and the method includes: Acquire multiple historical electricity consumption data corresponding to multiple historical year periods; each historical electricity consumption data corresponds to a historical year period; Performing outlier correction on the plurality of historical power consumption data to obtain a plurality of target historical power consumption data; Predicting the reference power consumption value corresponding to the target day in the target year segment based on the multiple target historical power consumption data by the time series prediction model; the target day in the target year segment is a day in the future; The target day power consumption forecast value corresponding to the target day is determined by the random forest model based on the multiple target historical power consumption data and the reference power consumption value.
2. The method according to claim 1, characterized in that Each target historical power consumption data includes a plurality of daily power consumption data; the abnormal value correction is performed on the plurality of historical power consumption data to obtain a plurality of target historical power consumption data, including: Determine a daily power consumption threshold range corresponding to the plurality of historical power consumption data; Determine k abnormal daily power consumption data that are outside the daily power consumption threshold range among the multiple historical power consumption data; the multiple historical power consumption data include m daily power consumption data, m is a positive integer, and k is a positive integer less than or equal to m; According to the determination method in the following steps S1-S3, the correction value corresponding to each abnormal daily power consumption data in the k abnormal daily power consumption data is determined to obtain k correction values, which is specifically the following steps: S1. Determine a first power consumption recording time period corresponding to first abnormal daily power consumption data; the first abnormal daily power consumption data is any one of the k abnormal daily power consumption data; S2, determine the second electricity consumption recording time period and the third electricity consumption recording time period with the shortest interval with the first electricity consumption recording time period, and determine the second day electricity consumption data corresponding to the second electricity consumption recording time period and the third day electricity consumption data corresponding to the third electricity consumption recording time period; the second electricity consumption recording time period is before the first electricity consumption recording time period, the third electricity consumption recording time period is after the first electricity consumption recording time period, and the second day electricity consumption data and the third day electricity consumption data are both within the daily electricity consumption threshold range; S3, determining an average value of the second day's electricity consumption data and the third day's electricity consumption data, and obtaining a correction value corresponding to the first abnormal day's electricity consumption data; The k abnormal daily electricity consumption data in the plurality of historical electricity consumption data are replaced based on the k correction values to obtain the plurality of target historical electricity consumption data.
3. The method according to claim 2, characterized in that The determining of the daily power consumption threshold range corresponding to the plurality of historical power consumption data includes: Determine an exponentially weighted average corresponding to the m daily electricity consumption data among the plurality of historical electricity consumption data; Determine the standard deviation corresponding to the m daily electricity consumption data based on the exponentially weighted average; The maximum power consumption threshold and the minimum power consumption threshold corresponding to the plurality of historical power consumption data are determined based on the exponential weighted average and the standard deviation, wherein the maximum power consumption threshold and the minimum power consumption threshold are specifically calculated according to the following formula: Wherein, max is the maximum power consumption threshold, min is the minimum power consumption threshold, and v i is the exponentially weighted average, σ i is the standard deviation; The daily power consumption threshold range is determined based on the maximum power consumption threshold and the minimum power consumption threshold.
4. The method according to claim 3, characterized in that The random forest model includes p random forest sub-models, where p is an integer. The method of determining the target day power consumption forecast value corresponding to the target day based on the multiple target historical power consumption data and the reference power consumption value by the random forest model includes: Perform p extractions from the plurality of target historical electricity consumption data to obtain p sample sets; each sample set corresponds to a random forest sub-model; Input the p sample sets into the p random forest sub-models respectively to obtain p first-day electricity consumption values; each sample set corresponds to a first-day electricity consumption value; Determine the second day's electricity consumption value based on the p first day's electricity consumption values; The second daily electricity consumption value is corrected based on the reference daily electricity consumption value to obtain the target daily electricity consumption forecast value corresponding to the target day.
5. The method according to claim 4, characterized in that The step of inputting the p sample sets into the p random forest sub-models to obtain p first-day electricity consumption values comprises: Determine, based on a first sample set, a plurality of reference days before the historical target day corresponding to the target day and a plurality of historical daily electricity consumption values corresponding to the plurality of reference days; the first sample set is any one of the p sample sets, and the historical target day is the same day as the target day in the historical year segment; Input the multiple reference days and the multiple historical daily electricity consumption values corresponding to the multiple reference days into the first random forest sub-model to obtain the third day electricity consumption value corresponding to the first sample set; the first random forest sub-model is the random forest sub-model corresponding to the first sample set; Acquire holiday data in the first sample set; Determine a target optimization factor corresponding to the holiday data; The third daily electricity consumption value is optimized based on the target optimization factor to obtain the first daily electricity consumption value corresponding to the first sample set.
6. The method according to claim 5, characterized in that The correcting the second daily power consumption value based on the reference daily power consumption value to obtain the target daily power consumption forecast value corresponding to the target day includes: Determining a daily power consumption difference between the reference daily power consumption value and the second daily power consumption value; Determining a target correction coefficient corresponding to the daily power consumption difference; The second daily electricity consumption value is corrected based on the target correction coefficient to obtain the target daily electricity consumption forecast value corresponding to the target day.
7. The method according to any one of claims 2 to 6, characterized in that: The method further comprises: Determine the target daily electricity consumption forecast value corresponding to each day in the target year period, and obtain n target daily electricity consumption forecast values; n is an integer; Selecting a target historical year segment that is closest to the target historical year segment from among the multiple historical year segments; Determine n target historical daily electricity consumption values corresponding to each day in the target historical year period; The power consumption prediction effect value of the random forest model is determined based on the n target daily power consumption prediction values and the n target historical daily power consumption values. The smaller the power consumption prediction effect value, the better the power consumption prediction effect of the random forest model. The calculation is specifically performed according to the following formula: Among them, MAPE is the power consumption prediction effect value of the random forest model, S i is the target daily electricity consumption forecast value corresponding to the i-th day, T i is the target historical daily electricity consumption value corresponding to the i-th day.
8. A power consumption prediction device, characterized in that: The power consumption prediction device is applied to a power consumption prediction system, the power consumption prediction system includes a time series prediction model and a random forest model, and the power consumption prediction device includes: an acquisition unit and a processing unit; The acquisition unit is used to acquire a plurality of historical electricity consumption data corresponding to a plurality of historical year periods; each piece of historical electricity consumption data corresponds to a historical year period; The processing unit is used to perform abnormal value correction on the plurality of historical power consumption data to obtain a plurality of target historical power consumption data; Predicting the reference power consumption value corresponding to the target day in the target year segment based on the multiple target historical power consumption data by the time series prediction model; the target day in the target year segment is a day in the future; The target day power consumption forecast value corresponding to the target day is determined by the random forest model based on the multiple target historical power consumption data and the reference power consumption value.
9. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the one or more programs include instructions for executing the steps in the method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.