Characteristic weighting and model fusion-based electricity purchase quantity prediction method and system
Patent Information
- Application Number
- CN202411798429.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-14
AI Technical Summary
Existing power purchase forecasting methods are difficult to maintain the accuracy and stability of prediction in complex environments, especially in the face of multiple influencing factors and diversity of user types.
The power purchase prediction method based on feature weighting and model fusion is adopted. By obtaining and preprocessing historical power data, weather data, user information and calendar information, historical power data characteristics, seasonal changes characteristics, market fluctuation characteristics and user behavior characteristics are extracted, and the feature weight adjustment mechanism and Stacking model fusion technology are used for dynamic weighting and model fusion training to form a power purchase prediction model.
It significantly improves the accuracy and stability of power purchase prediction, enhances the model's ability to identify important features, and can better adapt to complex market environments and changes in user behavior.
Smart Images

Figure CN119623755A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a purchased electricity forecasting technology, and in particular to a purchased electricity forecasting method, system, device and storage medium based on feature weighting and model fusion. Background Art
[0002] With the deepening reform of the power market, the business model of power grid proxy power purchase has gradually emerged. Its core advantage lies in helping users obtain better price chips through intensive procurement. In this context, accurate prediction of power demand for proxy power purchase is crucial for power grid companies to optimize resource allocation and effectively control costs. Accurate power forecasting can not only ensure the scientificity and rationality of power purchase plans, but also help power grid companies better respond to market fluctuations, improve operational efficiency, and ensure the healthy and efficient operation of the power market. Proxy power forecasting has become a key link for power grid companies to maintain their advantages and improve service levels in the competition in the power market.
[0003] The electricity purchase forecast is a forecasting method based on data analysis. It predicts future electricity demand by analyzing historical electricity data and related influencing factors. It faces many challenges and difficulties. First, electricity demand is affected by many factors, including economic development level, market electricity price fluctuations, climate conditions, user production and operation activities, etc. These factors often have complex nonlinear relationships, and the role of influencing factors may change significantly over time. Secondly, the types of users involved in power purchase by proxy are diverse. Different types of users (such as industrial users, commercial users, agricultural users, etc.) have different electricity consumption patterns and demand characteristics, which also increases the difficulty of electricity forecasting. In addition, the electricity market environment is becoming increasingly complex, and various policy changes and market mechanism adjustments will have a direct or indirect impact on electricity demand.
[0004] Although existing electricity forecasting methods, such as empirical methods, time series models, and machine learning models, can reflect the changing trend of electricity demand to a certain extent, it is difficult to maintain the accuracy and stability of the forecast in such a complex environment.
[0005] Therefore, there is an urgent need for a prediction method and system that can comprehensively consider multiple factors and has stronger generalization capabilities. Summary of the invention
[0006] Purpose of the invention: The purpose of the present invention is to provide a method, system, device and storage medium for predicting electricity purchase amount based on feature weighting and model fusion, which can comprehensively consider multiple factors, maintain the accuracy and stability of prediction in a complex environment, and has strong generalization ability.
[0007] Technical solution: A method for predicting power purchase volume based on feature weighting and model fusion of the present invention comprises:
[0008] Obtain historical daily electricity data, daily weather data, user information, and calendar information;
[0009] Preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding;
[0010] Extract key features from the preprocessed data, including historical electricity data features, seasonal change features, market fluctuation features, and user behavior features;
[0011] Adopt feature weight adjustment mechanism to dynamically weight all key features to form training data set;
[0012] The Stacking model fusion technology is used to integrate the Knn, random forest, Prophet and XGboost basic prediction models using the training data set to obtain the electricity purchase prediction model;
[0013] The electricity purchase amount forecasting model is used to forecast future electricity and the forecast results are evaluated.
[0014] Furthermore, key features are extracted from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features, including:
[0015] For the historical daily electricity data, the long-term trend components of the historical daily electricity data are extracted through the time series decomposition method, and the trend characteristics are constructed. The formula is as follows:
[0016]
[0017] Where, T(t) represents the trend component at time t; D(ti) represents the original electricity purchase data on day ti;
[0018] The fast Fourier transform method is used to convert the electricity time series data into the frequency domain, analyze the main frequencies and construct periodic characteristics. Through the above method, the characteristics of historical electricity data are extracted.
[0019] Furthermore, key features are extracted from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features, including:
[0020] Using daily weather data, we analyze the changes in electricity purchase volume caused by weather changes and construct seasonal indicator characteristics. The formula is as follows:
[0021] ΔE=α×ΔT
[0022] In the formula, ΔE represents the change in power demand; ΔT represents the change in temperature; α represents the coefficient of the effect of temperature on power demand;
[0023] The quarters and months in the calendar information are converted into categorical variables through one-hot encoding to construct seasonal classification coding features; through the above method, seasonal change characteristics are extracted.
[0024] Furthermore, a feature weight adjustment mechanism is used to dynamically weight all key features to form a training data set, including:
[0025] The feature weight adjustment mechanism is calculated using the following formula:
[0026]
[0027] In the formula, w i represents the weight of the i-th feature; represents the importance score of the i-th feature; n represents the total number of features;
[0028] Through the above formula, the weight of each key feature is calculated, so as to realize the dynamic weighting of key features and finally form a training data set.
[0029] Furthermore, the Stacking model fusion technology is used to integrate the Knn, random forest, Prophet and XGboost basic prediction models using the training data set to obtain the electricity purchase prediction model, including:
[0030] Divide the training data set into multiple subsets, each subset is used to train a different basic prediction model;
[0031] Use the corresponding subsets to train the Knn, random forest, and Prophet basic prediction models. After the training is completed, predict the entire training data to obtain the prediction results of the Knn, random forest, and Prophet basic prediction models;
[0032] The XGboost basic prediction model is used as a meta-model to combine the prediction results of all basic prediction models to form a new data set;
[0033] A new data set is input into the meta-model and the meta-model is trained to obtain the electricity purchase amount prediction model.
[0034] Furthermore, the expression of the Knn basic prediction model is as follows:
[0035]
[0036] In the formula, represents the predicted value; k represents the number of neighbors; yi represents the actual value of the i-th neighbor;
[0037] The expression of the random forest basic prediction model is as follows:
[0038]
[0039] In the formula, represents the predicted value; T represents the number of decision trees; y t Represents the predicted value of the tth decision tree;
[0040] The expression of the XGboost basic prediction model is as follows:
[0041]
[0042] In the formula, represents the objective function; N represents the number of samples; y i Indicates actual value; represents the predicted value; l(·) represents the loss function; K represents the number of trees; f k represents the kth tree; Δ(·) represents the regularization term.
[0043] Furthermore, the expression of the Prophet basic prediction model is as follows:
[0044]
[0045] In the formula, is the predicted value; g(t) is the trend term; s(t) is the cycle term; h(t) is the holiday term; ε t is the error term;
[0046] The trend term g(t) represents the non-periodic change trend of the electric quantity. The expression of the trend term g(t) is as follows:
[0047] g(t)=(k+a(t) T δ)t+(m+a(t) T γ)
[0048] Where k is the initial slope; δ is the change in slope at each change point; a(t) is the indicator function vector; m is the initial intercept, and γ is the change in intercept at each change point;
[0049] The periodic term s(t) represents the periodic change of the purchased electricity. The expression of the periodic term s(t) is as follows:
[0050]
[0051] Where P is the seasonal period; a n 、b nare the Fourier coefficients of the cosine and sine terms, respectively;
[0052] The holiday term h(t) represents the impact of non-fixed-cycle holidays on the amount of electricity purchased. The expression of the holiday term h(t) is as follows:
[0053]
[0054] In the formula, ρ j is the effect of holiday j; I(t∈holiday j ) is an indicator function, which takes the value 1 when time t belongs to holiday j and 0 otherwise.
[0055] Based on the same inventive concept, a power purchase amount prediction system based on feature weighting and model fusion of the present invention comprises:
[0056] Data collection module, used to obtain historical daily electricity data, daily weather data, user information, and calendar information;
[0057] The data preprocessing module is used to preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding;
[0058] The feature extraction module is used to extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features.
[0059] Dynamic weighting module, used to dynamically weight all key features using feature weight adjustment mechanism to form a training data set;
[0060] The model fusion training module is used to adopt the Stacking model fusion technology and use the training data set to perform fusion training on the Knn, random forest, Prophet and XGboost basic prediction models to obtain the electricity purchase prediction model;
[0061] The prediction and evaluation module is used to predict future electricity consumption using the electricity purchase amount prediction model and to evaluate the prediction results.
[0062] Based on the same inventive concept, a device for predicting the amount of electricity purchased based on feature weighting and model fusion of the present invention includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the above-mentioned method for predicting the amount of electricity purchased based on feature weighting and model fusion.
[0063] Based on the same inventive concept, a computer-readable storage medium of the present invention stores a computer program thereon, and when the program is executed by a processor, the steps of the above-mentioned method for predicting the amount of electricity purchased based on feature weighting and model fusion are implemented.
[0064] Beneficial effects: Compared with the prior art, the significant technical effects of the present invention are:
[0065] The present invention effectively enhances the recognition capability of key features by conducting in-depth analysis of multi-dimensional features and introducing a dynamic weighting mechanism, thus overcoming the shortcomings of the prior art in the recognition of important features.
[0066] The present invention adopts Stacking model fusion technology and solves the applicability problem of the existing single model in complex environments by integrating the advantages of multiple basic prediction models, thereby significantly improving the stability and accuracy of the prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a flowchart of a method for predicting power purchase quantity based on feature weighting and model fusion disclosed in an embodiment of the present invention;
[0068] Figure 2 It is a structural schematic diagram of a power purchase prediction system based on feature weighting and model fusion disclosed in an embodiment of the present invention;
[0069] Figure 3 It is a structural schematic diagram of a power purchase amount prediction device based on feature weighting and model fusion disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0070] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It will be understood by those skilled in the art that the purposes and advantages that can be achieved with the present invention are not limited to the specific description of the above beneficial effects, and the above and other purposes that can be achieved by the present invention will be more clearly understood based on the following detailed description.
[0071] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed in the present invention can be implemented in hardware, software or a combination of the two. Whether it is implemented in hardware or software depends on the specific application and design of the technical solution. Professional and technical personnel can use different methods to implement the functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0072] Reference to "embodiments" in the present invention means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places 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.
[0073] Example 1
[0074] See also Figure 1 , Figure 1 : is a flow chart of a method for predicting power purchase quantity based on feature weighting and model fusion disclosed in an embodiment of the present invention. Figure 1 The described method for predicting the amount of electricity purchased is applied to the power system, such as predicting the amount of electricity purchased by different types of users, etc., which is not limited in the embodiments of the present invention. Figure 1 As shown, the power purchase quantity prediction method based on feature weighting and model fusion may include the following operations:
[0075] S1. Obtain historical daily electricity data, daily weather data, user information, and calendar information.
[0076] S2. Preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding.
[0077] In this embodiment, the Z-score method is used to identify outliers, and the mean filling method is used for replacement; the Min-Max method is used for data normalization; and the OneHotEncoder is used to perform one-hot encoding on discrete features. .
[0078] S3. Extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features.
[0079] The impact of a single factor on the amount of electricity purchased by an agent cannot be ignored, so the impact of various factors on electricity consumption needs to be considered when predicting electricity consumption. The present invention analyzes the influencing factors and effectiveness of electricity consumption prediction by extracting historical electricity data, seasonal changes, market fluctuations, and user behavior. The details are as follows:
[0080] S3.1. Extracting historical electricity data features
[0081] Historical electricity data is an important basis for predicting future electricity. A systematic analysis of electricity data over a period of time was conducted, and the trend and periodic characteristics of electricity purchases were extracted through time series decomposition (STL) and fast Fourier transform (FFT).
[0082] In this embodiment, for the historical daily electricity data, the long-term trend component of the historical daily electricity data is extracted by the time series decomposition method, and the trend feature is constructed. The formula is as follows:
[0083]
[0084] Where, T(t) represents the trend component at time t; D(ti) represents the original electricity purchase data on day ti;
[0085] Using the fast Fourier transform method, the power time series data is converted into the frequency domain, the main frequencies are analyzed, and the periodic characteristics are constructed;
[0086] Through the above method, the characteristics of historical electricity data are extracted.
[0087] S3.2. Extracting seasonal variation characteristics
[0088] The seasonal variation of electricity consumption is a significant feature. In summer, due to the increase in temperature, the use of cooling equipment such as air conditioners increases, resulting in an increase in electricity demand; in winter, due to the use of heating equipment, electricity demand also increases accordingly. It is necessary to combine seasonal factors to ensure the accuracy of electricity demand forecasts. The seasonal variation characteristics are constructed by calculating seasonal indicators based on weather and seasonal classification coding.
[0089] In this embodiment, daily weather data is used to analyze the changes in electricity purchase caused by weather changes and to construct seasonal index characteristics. The formula is as follows:
[0090] ΔE=α×ΔT
[0091] In the formula, ΔE represents the change in power demand; ΔT represents the change in temperature; α represents the coefficient of the effect of temperature on power demand;
[0092] Using calendar information, we construct categorical variable encoding features and convert information such as quarters and months into categorical variables through one-hot encoding, so that the model can better capture the characteristics of seasonal fluctuations.
[0093] Through the above method, seasonal variation characteristics are extracted.
[0094] S3.3. Extracting market volatility characteristics
[0095] Market fluctuations will have an impact on electricity demand. Economic growth, industrial structure adjustment, energy price changes and other factors may lead to changes in electricity demand. The market fluctuation characteristics are constructed by calculating the first-order difference of GDP and electricity purchase. The formula is as follows:
[0096] ΔX t =(GDP t -GDP t-1)×(P t -P t-1 )
[0097] In the formula, GDP t is the GDP value at time t; P t is the electricity purchase amount at time t.
[0098] S3.4. Extracting User Behavior Features
[0099] User behavior is also an important factor affecting electricity demand. Changes in electricity consumption habits and production methods of large users may lead to changes in electricity demand. By quantitatively analyzing the load characteristics and number changes of large users, user behavior characteristics can be constructed.
[0100] S4. Use the feature weight adjustment mechanism to dynamically weight all the above key features to form a training data set.
[0101] In order to enhance the model's sensitivity to important features and improve prediction accuracy, the present invention adopts a feature weight adjustment mechanism. This mechanism selects key features through variance analysis and dynamically weights them, so that the model can pay more attention to features that have a greater impact on power prediction. The specific process is as follows:
[0102] First, the historical agent electricity purchase data are reasonably grouped according to key characteristics.
[0103] Then, variance analysis was carried out to determine whether the characteristics had a significant impact on the amount of electricity purchased by comparing the ratio of the variance between groups to the variance within groups (F value) and the corresponding p value.
[0104] Then, the key feature weights are determined based on the analysis results, and the F value can be normalized so that the sum of the weights is 1.
[0105] In this embodiment, the feature weight adjustment mechanism can be calculated using the following formula:
[0106]
[0107] In the formula, w i represents the weight of the i-th feature; represents the importance score of the i-th feature; n represents the total number of features;
[0108] Through the above formula, the weight of each key feature can be calculated, thereby realizing dynamic weighting of key features and finally forming a training data set.
[0109] As new data flows in, variance analysis is re-performed regularly to achieve dynamic adjustment of weights.
[0110] S5. Using the Stacking model fusion technology, the training data set is used to perform fusion training on the Knn, random forest, Prophet and XGboost basic prediction models to obtain the electricity purchase prediction model.
[0111] Stacking model fusion technology is a method of integrating multiple basic prediction models. By fusing the prediction results of different models, the advantages of each model can be fully utilized to improve the accuracy and stability of the prediction.
[0112] In the present invention, the following basic prediction models are adopted:
[0113] (1) Knn (K-Nearest Neighbors) basic prediction model
[0114] The KNN basic prediction model is an instance-based learning method that performs classification or regression prediction by calculating the distance between samples. In power forecasting, the KNN model can predict future power based on historical power data and other relevant features.
[0115] In this embodiment, the expression of the Knn basic prediction model is as follows:
[0116]
[0117] In the formula, represents the predicted value; k represents the number of neighbors; y i Represents the actual value of the i-th neighbor.
[0118] (2) Random Forest Basic Prediction Model
[0119] The random forest basic prediction model is an ensemble learning method based on decision trees. It makes predictions by building multiple decision trees. In power forecasting, the random forest model can effectively handle nonlinear relationships and high-dimensional data.
[0120] In this embodiment, the expression of the random forest basic prediction model is as follows:
[0121]
[0122] In the formula, represents the predicted value; T represents the number of decision trees; y t Represents the predicted value of the tth decision tree.
[0123] (3) Prophet basic forecasting model
[0124] The Prophet basic forecasting model is a time series forecasting model that can effectively handle factors such as trends, seasonality, and holidays in time series data. In power forecasting, the Prophet model can predict future power based on the time characteristics of historical power data.
[0125] In this embodiment, the expression of the Prophet basic prediction model is as follows:
[0126]
[0127] In the formula, is the predicted value; g(t) is the trend term; s(t) is the cycle term; h(t) is the holiday term; ε t is the error term;
[0128] The trend term g(t) in Prophet uses a piecewise linear function. It assumes that the trend of the time series can have different slopes at different time nodes, which is achieved by setting some change points. The trend term g(t) represents the non-periodic change trend of electricity. The expression of the trend term g(t) is as follows:
[0129] g(t)=(k+a(t) T δ)t+(m+a(t) T γ)
[0130] Where k is the initial slope; δ is the change in slope at each change point; a(t) is the indicator function vector; m is the initial intercept, and γ is the change in intercept at each change point.
[0131] The periodic term s(t) in Prophet allows the definition of multiple seasonal components (such as day, week, year). The periodic term s(t) represents the periodic change of the purchased electricity. The expression of the periodic term s(t) is as follows:
[0132]
[0133] Where P is the seasonal period; a n 、b n are the Fourier coefficients of the cosine and sine terms, respectively.
[0134] The holiday term h(t) represents the impact of non-fixed-cycle holidays on the amount of electricity purchased. The expression of the holiday term h(t) is as follows:
[0135]
[0136] In the formula, ρ j is the effect of holiday j; I(t∈holiday j) is an indicator function, which takes the value 1 when time t belongs to holiday j and 0 otherwise.
[0137] (4) XGboost (eXtreme Gradient Boosting) basic prediction model
[0138] The XGboost basic prediction model is a machine learning algorithm based on the gradient boosting tree, which is efficient, flexible and accurate. In power forecasting, the XGboost model can improve the prediction accuracy by learning from historical data and mining the complex relationship between power and other features.
[0139] In this embodiment, the expression of the XGboost basic prediction model is as follows:
[0140]
[0141] In the formula, represents the objective function; N represents the number of samples; y i Indicates actual value; represents the predicted value; l(·) represents the loss function; K represents the number of trees; f k represents the kth tree; Δ(·) represents the regularization term.
[0142] In the Stacking model fusion technology, first, the training data is input into each basic prediction model for training to obtain the prediction results of each model. Then, these prediction results are used as input features and input into the meta-model for training. The meta-model can perform a comprehensive analysis of the prediction results of these basic prediction models to obtain the final prediction results. The specific process of step S5 is as follows:
[0143] S5.1, dividing the training data set into multiple subsets, each subset is used to train a different basic prediction model;
[0144] S5.2. Use the corresponding subsets to train the Knn, random forest, and Prophet basic prediction models. After the training is completed, predict the entire training data to obtain the prediction results of the Knn, random forest, and Prophet basic prediction models;
[0145] S5.3, the XGboost basic prediction model is used as a meta-model to combine the prediction results of all basic prediction models to form a new data set;
[0146] S5.4. Input the new data set into the meta-model and train the meta-model to obtain the electricity purchase amount prediction model.
[0147] S6. Use the electricity purchase amount prediction model to predict future electricity consumption and evaluate the prediction results.
[0148] In this embodiment, the evaluation indicators include accuracy (ACC), mean square error (RMSE), and mean absolute percentage error (MAPE). The accuracy calculation formula is:
[0149]
[0150] Among them, y is the actual value, is the predicted value.
[0151] The present invention aims to solve the limitations of existing electricity purchase forecasting methods in terms of forecasting accuracy and adaptability, meet the urgent need for accurate forecasting of electricity purchases, and support power grid companies in making more scientific decisions in a complex market environment. In the technical solution of the present invention, firstly, through in-depth analysis of multi-dimensional features such as historical electricity data, seasonal changes, market fluctuations, and user behavior, the key features that have a greater impact on electricity forecasting are extracted. Subsequently, these key features are dynamically weighted using a feature weight adjustment mechanism to enhance the model's sensitivity to important features, thereby improving forecasting accuracy. On this basis, the Stacking model fusion technology is used to effectively integrate the advantages of multiple basic forecasting models (including Knn, random forest, Prophet, and XGboost basic forecasting models) to give full play to the forecasting capabilities of each model under different feature combinations, and finally output a comprehensive forecasting result.
[0152] The power purchase quantity prediction method based on feature weighting and model fusion of the present invention is verified by a specific embodiment below.
[0153] See also Figure 1 The method for predicting the amount of electricity purchased based on feature weighting and model fusion of the present invention is implemented according to the following steps:
[0154] S1. Data collection: Taking the forecast of power purchase by agents in City A of a northern province as an example, the historical daily power purchase data, daily weather data (including 40-day forecast), GDP data, energy price data and large user information (including power consumption of 1,000 households and new power connection plans) of City A of the province are collected.
[0155] S2. Data preprocessing: Preprocess all acquired data, including data cleaning, data normalization, discrete variable one-hot encoding and other operations.
[0156] S3. Feature extraction: extract features from the preprocessed data.
[0157] First, for the historical daily electricity data, the long-term trend components of the data are extracted through time series decomposition (such as STL decomposition) to construct trend characteristics. The formula is as follows:
[0158]
[0159] Where T(t) represents the trend component at time t; D(t) represents the original electricity purchase data at time t.
[0160] The fast Fourier transform (FFT) is used to convert the time series data of electricity into the frequency domain, analyze the main frequencies and construct the periodic characteristics.
[0161] Second, using daily weather data, we analyze the changes in electricity purchases caused by weather changes and construct seasonal indicator characteristics. The formula is as follows:
[0162] ΔE=α×ΔT
[0163] In the formula, ΔE is the change in power demand; ΔT is the change in temperature; α is the coefficient of the effect of temperature on power demand. This coefficient is determined by multiple linear regression.
[0164] Calendar information is used to construct encoding features for categorical variables, and information such as quarters and months is converted into categorical variables through one-hot encoding, so that the model can better capture the characteristics of seasonal fluctuations.
[0165] Third, use historical electricity data, GDP data and energy price data to perform differential operations and obtain their respective growth rates as market fluctuation characteristics.
[0166] Finally, by using large-scale user information, we calculated the average daily power load and maximum load of the first 1,000 households, and constructed the characteristics of power load changes. At the same time, we quantitatively analyzed the new planned power connections, and constructed user behavior characteristics in summary.
[0167] S4, dynamic weighting: for the key features extracted above that have a greater impact on power forecast, these key features are dynamically weighted using a feature weight adjustment mechanism. The specific steps are as follows:
[0168] First, the historical proxy power purchase data is reasonably grouped according to the key features; then, variance analysis is carried out to determine whether the characteristics have a significant impact on the power purchase by comparing the ratio of the variance between groups and the variance within groups (F value) and the corresponding p value. Then, the key feature weights are determined based on the analysis results, and the F value can be normalized so that the weight sum is 1. With the inflow of new data, variance analysis is performed regularly to achieve dynamic adjustment of weights.
[0169] The following is a table of weight coefficients of various features disclosed in the embodiments of the present invention:
[0170] Feature weight coefficient
[0171]
[0172] In the table, there is a strong correlation between the changes in purchased electricity and seasonal indicators, trend characteristics, and user behavior. Therefore, fully weighting the impact of seasons, trends, and user behavior when building an electricity forecasting model can effectively improve the model's prediction accuracy.
[0173] S5, model fusion training: Use Stacking model fusion technology to integrate the Knn, random forest, Prophet and XGboost basic prediction models to obtain the final prediction model. The specific process is as follows:
[0174] First, three optimal base classifiers are trained using the dynamically weighted features. The first layer uses KNN, random forest, and Prophet to perform 5-fold cross-validation on the training data. For the first base classifier, 4 folds are taken from the training set as training data, and the remaining 1 fold is used as validation data. The model trained with 4 folds of data is used to predict the other 1 fold of validation data, and the probability result is: At the same time, all test data will not be included in the 5-fold cross validation, so each time this model is used to predict the corresponding test data, Y 1_n (n=5), the final test data output T n The result is averaged according to the row as T 1_MEAN , splicing R 1_n With T 1_MEAN For the new feature data [R 1_1 ,R 1_2 ,R 1_3 ,R 1_4 ,R 1_5 ,T 1_MEAN Next, the same strategy is used for the other two base classifiers to generate new feature numbers [R 2_1 ,R 2_2 ,R 2_3 ,R 2_4 ,R 2_5 ,T 2_MEAN ] and [R 3_1 ,R 3_2 ,R 3_3 ,R 3_4 ,R 3_5 ,T 3_MEAN ]. In the second layer, the new feature data generated by the previous three base classifiers are input into the optimal XGboost classification model, and finally the electricity purchase prediction model is obtained.
[0175] S6. Prediction and evaluation
[0176] The trained electricity purchase prediction model is used to predict future electricity consumption and the prediction results are evaluated. The evaluation indicators include accuracy (ACC), mean square error (RMSE), and mean absolute percentage error (MAPE). The accuracy calculation formula is:
[0177]
[0178] Among them, y is the actual value, is the predicted value.
[0179] According to the evaluation results, the electricity purchase amount forecasting model is optimized and adjusted to improve the forecasting accuracy and stability of the model.
[0180] In order to verify the effectiveness of the electricity purchase prediction method based on feature weighting and model fusion proposed in this paper, a series of experiments were conducted. The experimental data used the electricity data of City B in a northern province in the past three years and related feature data.
[0181] In the experiment, the method proposed in the present invention was compared with several other commonly used electricity forecasting methods, including traditional time series forecasting methods, forecasting methods based on machine learning, etc. The experimental results show that the method proposed in the present invention has obvious advantages in forecasting accuracy and stability.
[0182] The following is a schematic diagram of the experimental results and evaluation disclosed in the embodiments of the present invention;
[0183] Experimental Results and Evaluation
[0184] Model Accuracy RMSE MAPE Stacking 0.915 1.909 1.923 LightGBM 0.865 2.875 2.894 LSTM 0.788 2.192 4.204 XGBoost 0.876 2.371 3.301
[0185] The table shows the performance of the Stacking, LightGBM, LSTM and XGBoost prediction methods in the embodiments. It can be seen from the data in the table that compared with the other three electricity purchase prediction models, the electricity purchase prediction method (Stacking) based on feature weighting and model fusion has higher accuracy and lower RMSE and MAPE values. Therefore, this method has a smaller prediction error.
[0186] Specifically, the method proposed in the present invention outperforms other methods in terms of mean square error and mean absolute percentage error, and can more accurately predict the trend of future electricity consumption. In addition, by adjusting the feature weights and optimizing the model fusion, the method proposed in the present invention can better adapt to different market environments and user behavior changes, and has stronger robustness.
[0187] Example 2
[0188] See also Figure 2 , Figure 2The structure diagram of a power purchase prediction system based on feature weighting and model fusion disclosed in an embodiment of the present invention can realize power purchase prediction for different types of users, specifically including:
[0189] Data collection module, used to obtain historical daily electricity data, daily weather data, user information, and holiday information;
[0190] The data preprocessing module is used to preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding;
[0191] The feature extraction module is used to extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features.
[0192] Dynamic weighting module, used to dynamically weight all key features using feature weight adjustment mechanism to form a training data set;
[0193] The model fusion training module is used to adopt the Stacking model fusion technology and use the training data set to perform fusion training on the Knn, random forest, Prophet and XGboost basic prediction models to obtain the electricity purchase prediction model;
[0194] The prediction and evaluation module is used to predict future electricity consumption using the electricity purchase amount prediction model and to evaluate the prediction results.
[0195] In an optional embodiment, the method for predicting the amount of electricity purchased based on feature weighting and model fusion includes: a) obtaining historical daily electricity data, daily weather data, user information, and holiday information; b) preprocessing all the acquired data; c) extracting key features from the preprocessed data; d) using a feature weight adjustment mechanism to dynamically weight all key features to form a training data set; e) using Stacking model fusion technology to use the training data set to perform fusion training on the Knn, random forest, Prophet and XGboost basic prediction models to obtain a purchased electricity prediction model; f) using the purchased electricity prediction model to predict future electricity and evaluate the prediction results.
[0196] Example 3
[0197] See also Figure 3 , Figure 3 : is a schematic diagram of a structure of a power purchase prediction device based on feature weighting and model fusion disclosed in an embodiment of the present invention. Figure 3 The described device can be applied to the power system, such as for predicting the power purchase amount of different types of users, etc., which is not limited in the embodiments of the present invention.
[0198] like Figure 3 As shown, the device may include a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the method described in the above embodiment and can achieve the technical effect consistent with the above method.
[0199] The memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the memory may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as a "hard drive"). A program / utility having a set (at least one) of program modules may be stored in, for example, the memory, such program modules including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment. The program modules typically perform the functions and / or methods in the embodiments described herein.
[0200] The processor executes various functional applications and data processing by running the program stored in the memory, such as implementing the method provided in the first embodiment of the present invention.
[0201] Example 4
[0202] Embodiment 4 of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the above embodiment are implemented and the technical effect consistent with the above method can be achieved.
[0203] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0204] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0205] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0206] Computer program code for performing the operation of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0207] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention, whose computer executable instructions are not limited to the above method operations, can also execute related operations in the method provided by any embodiment of the present invention.
[0208] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for predicting electricity purchase amount based on feature weighting and model fusion, characterized in that: include: Obtain historical daily electricity data, daily weather data, user information, and calendar information; Preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding; Extract key features from the preprocessed data, including historical electricity data features, seasonal change features, market fluctuation features, and user behavior features; Adopt feature weight adjustment mechanism to dynamically weight all key features to form training data set; The Stacking model fusion technology is used to integrate the Knn, random forest, Prophet and XGboost basic prediction models using the training data set to obtain the electricity purchase prediction model; The electricity purchase amount forecasting model is used to forecast future electricity and the forecast results are evaluated.
2. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: Extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features, including: For the historical daily electricity data, the long-term trend components of the historical daily electricity data are extracted through the time series decomposition method, and the trend characteristics are constructed. The formula is as follows: Where, T(t) represents the trend component at time t; D(ti) represents the original electricity purchase data on day ti; The fast Fourier transform method is used to convert the electricity time series data into the frequency domain, analyze the main frequencies and construct periodic characteristics. Through the above method, the characteristics of historical electricity data are extracted.
3. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: Extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features, including: Using daily weather data, we analyze the changes in electricity purchase volume caused by weather changes and construct seasonal indicator characteristics. The formula is as follows: ΔE=α×ΔT In the formula, ΔE represents the change in power demand; ΔT represents the change in temperature; α represents the coefficient of the effect of temperature on power demand; The quarters and months in the calendar information are converted into categorical variables through one-hot encoding to construct seasonal classification coding features; through the above method, seasonal change characteristics are extracted.
4. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: The feature weight adjustment mechanism is used to dynamically weight all key features to form a training data set, including: The feature weight adjustment mechanism is calculated using the following formula: In the formula, w i represents the weight of the i-th feature; represents the importance score of the i-th feature; n represents the total number of features; Through the above formula, the weight of each key feature is calculated, so as to realize the dynamic weighting of key features and finally form a training data set.
5. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: The Stacking model fusion technology is used to integrate the Knn, random forest, Prophet and XGboost basic prediction models using the training data set to obtain the electricity purchase prediction model, including: Divide the training data set into multiple subsets, each subset is used to train a different basic prediction model; Use the corresponding subsets to train the Knn, random forest, and Prophet basic prediction models. After the training is completed, predict the entire training data to obtain the prediction results of the Knn, random forest, and Prophet basic prediction models; The XGboost basic prediction model is used as a meta-model to combine the prediction results of all basic prediction models to form a new data set; A new data set is input into the meta-model and the meta-model is trained to obtain the electricity purchase amount prediction model.
6. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: The expression of the Knn basic prediction model is as follows: In the formula, represents the predicted value; k represents the number of neighbors; y i represents the actual value of the i-th neighbor; The expression of the random forest basic prediction model is as follows: In the formula, represents the predicted value; T represents the number of decision trees; y t Represents the predicted value of the tth decision tree; The expression of the XGboost basic prediction model is as follows: In the formula, represents the objective function; N represents the number of samples; y i Indicates actual value; represents the predicted value; l(·) represents the loss function; K represents the number of trees; f k represents the kth tree; Δ(·) represents the regularization term.
7. The method for predicting power purchase amount based on feature weighting and model fusion according to claim 1 is characterized in that: The expression of the Prophet basic prediction model is as follows: In the formula, is the predicted value; g(t) is the trend term; s(t) is the cycle term; h(t) is the holiday term; ε t is the error term; The trend term g(t) represents the non-periodic change trend of the electric quantity. The expression of the trend term g(t) is as follows: g(t)=(k+a(t) T δ)t+(m+a(t) T γ) Where k is the initial slope; δ is the change in slope at each change point; a(t) is the indicator function vector; m is the initial intercept, and γ is the change in intercept at each change point; The periodic term s(t) represents the periodic change of the purchased electricity. The expression of the periodic term s(t) is as follows: Where P is the seasonal period; a n 、b n are the Fourier coefficients of the cosine and sine terms, respectively; The holiday term h(t) represents the impact of non-fixed-cycle holidays on the amount of electricity purchased. The expression of the holiday term h(t) is as follows: In the formula, ρ j is the effect of holiday j; I(t∈holiday j ) is an indicator function, which takes the value 1 when time t belongs to holiday j and 0 otherwise.
8. A power purchase amount prediction system based on feature weighting and model fusion, characterized in that: include: Data collection module, used to obtain historical daily electricity data, daily weather data, user information, and holiday information; Data preprocessing module, used to preprocess all acquired data, including outlier processing, data normalization, and discrete value one-hot encoding; The feature extraction module is used to extract key features from the preprocessed data. The extracted key features include historical electricity data features, seasonal change features, market fluctuation features, and user behavior features. Dynamic weighting module, used to dynamically weight all key features using feature weight adjustment mechanism to form a training data set; The model fusion training module is used to adopt the Stacking model fusion technology and use the training data set to perform fusion training on the Knn, random forest, Prophet and XGboost basic prediction models to obtain the electricity purchase prediction model; The prediction and evaluation module is used to predict future electricity consumption using the electricity purchase amount prediction model and to evaluate the prediction results.
9. A device for predicting power purchase amount based on feature weighting and model fusion, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the method for predicting power purchase quantity based on feature weighting and model fusion as 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, which, when executed by a processor, implements the steps of the method for predicting power purchase quantity based on feature weighting and model fusion as claimed in any one of claims 1 to 7.