Monthly electricity sales prediction method and device based on fusion of dynamic feature screening and meta-learning
By constructing a dynamic feature selection closed-loop system and a meta-learning fusion framework, the problem of the disconnect between feature selection and model performance in electricity sales forecasting is solved, achieving high-precision and robust forecasting that adapts to complex electricity market environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-04
- Publication Date
- 2026-03-17
AI Technical Summary
Existing electricity sales forecasting methods suffer from a disconnect between feature selection and model performance, and their model fusion strategies are simplistic and lack adaptive optimization capabilities, resulting in insufficient forecast accuracy and robustness.
A collaborative optimization framework integrating a dynamic feature selection closed-loop system and meta-learning is constructed. Features are selected through multi-dimensional correlation analysis and temporal cross-validation. The optimal combination weights of the base learners are adaptively learned by the ridge regression meta-learner to form an end-to-end adaptive electricity sales prediction system.
It significantly improves the accuracy and robustness of electricity sales forecasting, reducing MAPE from 2.77% of the traditional method to 0.88%, an improvement of 68.2%, and effectively adapting to the complex and ever-changing electricity market environment.
Smart Images

Figure CN121685010A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and apparatus for predicting monthly electricity sales by fusing dynamic feature selection and meta-learning, belonging to the field of power system prediction technology. Background Technology
[0002] Electricity sales forecasting is a core component of power system operation, planning, and economic dispatch. Accurate forecasting is crucial for ensuring grid stability, optimizing electricity trading, and formulating generation plans. Existing electricity sales forecasting methods are mainly divided into traditional time series models, machine learning models, and simple combined models.
[0003] Traditional time series models, such as ARIMA and SARIMAX, excel at capturing linear trends and seasonal patterns, but they cannot effectively handle nonlinear relationships and the influence of complex external factors. Machine learning models, such as ensemble learning models like XGBoost and LightGBM, can learn nonlinear patterns, but they may be less stable than time series models when the data volume is small or the series has strong seasonality. Simple combined models, such as weighted averaging of the prediction results of different models, are simple but have fixed weights, cannot adapt to dynamic changes in data, and offer limited improvement in prediction accuracy.
[0004] The main shortcomings of current technology include: feature selection is disconnected from model performance, as traditional feature selection methods are static and fail to be linked to the prediction performance of the final model; model fusion strategies are simple and cannot accurately capture the advantages of different base learners in different time periods or data patterns; and there is insufficient automation and adaptability, lacking a closed-loop, adaptive optimization framework.
[0005] Therefore, there is an urgent need in this field for a high-precision electricity sales forecasting scheme that can automatically and dynamically optimize feature selection and integrate with intelligent models. Summary of the Invention
[0006] To address the aforementioned issues, this invention proposes a method and apparatus for predicting monthly electricity sales by fusing dynamic feature selection with meta-learning. By constructing a collaborative optimization system that integrates a closed-loop dynamic feature selection loop with meta-learning, the accuracy and robustness of electricity sales prediction can be significantly improved.
[0007] The technical solution adopted by this invention to solve its technical problem is as follows: In a first aspect, the present invention provides a method for predicting monthly electricity sales volume by fusing dynamic feature selection and meta-learning, comprising the following steps: Step 1: Construct a model performance-driven dynamic feature selection closed-loop system, and select features in parallel through multi-dimensional correlation analysis to generate a candidate feature subset pool. Step 2: The performance feedback mechanism of temporal cross-validation is used to evaluate the candidate feature subset, and the prediction performance of the fusion model is used as the criterion for feature subset selection. Step 3: Based on the optimal feature subset, construct a meta-learning-driven multi-model dynamic fusion framework, and adaptively learn the optimal combination weights of the base learners through the ridge regression meta-learner; Step 4: Use the trained fusion model to predict future monthly electricity sales. The dynamic feature selection closed-loop system works in conjunction with the meta-learning-driven multi-model dynamic fusion framework to form an end-to-end adaptive electricity sales forecasting system.
[0008] As one possible implementation of this embodiment, step 1 includes the following steps: Step 11: Obtain historical electricity sales time series data and multi-dimensional external feature data, wherein the external features include weather features, time features and basic attribute features; Step 12: Use multi-dimensional correlation analysis to screen features in parallel and generate a pool of candidate feature subsets; Step 13: Evaluate and optimize the candidate feature subset through the model performance feedback mechanism; Step 14: Determine the optimal feature subset based on the evaluation results to complete the dynamic feature selection closed loop.
[0009] As one possible implementation of this embodiment, the multi-dimensional correlation analysis method includes: Pearson correlation coefficient analysis is used to measure the linear correlation between a feature and the target variable, retaining features with |r|>0.3; Spearman rank correlation analysis is used to identify monotonically nonlinear relationships between features and target variables, retaining features with |ρ|>0.3; Random forest feature importance analysis assesses the overall utility of features in the model using Gini importance, retaining the top 50% of features by importance score; SHAP value analysis, based on game theory calculation of the marginal contribution of features to the prediction results, retains the top 50% of features that are the average of the absolute values of SHAP values.
[0010] As one possible implementation of this embodiment, the weather features in the external features include: monthly average temperature, monthly average humidity, cooling day CDD, heating day HDD, monthly average wind speed, and the interaction term between monthly average temperature and average humidity. The time features in the external features include: number of holidays, whether it is the Spring Festival, whether it is National Day, whether it is a hot month, whether it is a cold month, year, and month; The basic attribute features in the external features include: number of users, installation capacity, user density, installation capacity density, user month-on-month growth rate, and installation capacity month-on-month growth rate.
[0011] As one possible implementation of this embodiment, step 2 includes the following steps: Step 21: Using a rolling prediction origin temporal cross-validation strategy, multiple training-validation data folds are constructed. Step 22: For each feature subset in the candidate feature subset pool, perform model training and validation on each fold of temporal cross-validation; Step 23: Based on the prediction performance of the fusion model on the validation set, calculate the comprehensive score for each candidate feature subset; Step 24: Select the optimal feature subset based on the comprehensive score to complete the performance feedback evaluation.
[0012] As one possible implementation of this embodiment, step 3 includes the following steps: Step 31: Using the optimal feature subset, retrain the final base learner on all training data; Step 32: Based on the prediction results of the base learner, construct the meta-feature dataset; Step 33: Train the ridge regression meta-learner and dynamically learn the optimal combination weights of the base learners; Step 34: Construct a complete meta-learning-driven multi-model dynamic fusion framework.
[0013] As one possible implementation of this embodiment, step 4 includes the following steps: Step 41: Obtain the external feature data corresponding to future months to form the optimal feature subset; Step 42: Input the optimal feature subset into the trained base learner to obtain the prediction result of the base learner; Step 43: Use the prediction results of the base learner as meta-features and input them into the trained meta-learner to obtain the final predicted electricity sales volume. Step 44: Post-process and visualize the prediction results.
[0014] Secondly, an embodiment of the present invention provides a monthly electricity sales forecasting device that integrates dynamic feature filtering and meta-learning, comprising: The dynamic feature selection module is used to build a model performance-driven dynamic feature selection closed-loop system. It selects features in parallel through multi-dimensional correlation analysis methods to generate a pool of candidate feature subsets. The performance evaluation module is used to evaluate the candidate feature subset using the performance feedback mechanism of temporal cross-validation, and uses the prediction performance of the fusion model as the criterion for feature subset selection. The meta-learning fusion module is used to construct a meta-learning-driven multi-model dynamic fusion framework based on the optimal feature subset, and to adaptively learn the optimal combination weights of the base learners through the ridge regression meta-learner. The prediction execution module is used to predict future monthly electricity sales using a trained fusion model; The dynamic feature selection closed-loop system works in conjunction with the meta-learning-driven multi-model dynamic fusion framework to form an end-to-end adaptive electricity sales forecasting system.
[0015] Thirdly, an electronic device provided by an embodiment of the present invention includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the monthly electricity sales forecasting method fused with any dynamic feature selection and meta-learning as described above.
[0016] Fourthly, an embodiment of the present invention provides a storage medium storing a computer program, which, when run by a processor, executes the steps of the monthly electricity sales forecasting method that combines arbitrary dynamic feature selection and meta-learning as described above.
[0017] One of the above technical solutions has the following advantages or beneficial effects: 1. By constructing a model performance-driven dynamic feature selection closed-loop system, and utilizing multi-dimensional correlation analysis methods and time-series cross-validation performance feedback mechanisms, we have achieved synergistic optimization of feature selection and model prediction, thus solving the problem of disconnect between traditional feature selection and model performance. 2. A meta-learning-driven multi-model dynamic fusion framework is adopted, which significantly improves the adaptability and accuracy of model fusion by using a ridge regression meta-learner to adaptively learn the optimal combination weights of base learners. 3. The synergistic effect of dynamic feature selection and meta-learning has produced a technological synergy. Experimental data shows that MAPE has decreased from 2.77% of the traditional method to 0.88%, an improvement of 68.2%. 4. An end-to-end adaptive electricity sales forecasting system has been implemented, which can effectively adapt to the complex and ever-changing electricity market environment.
[0018] This invention solves the technical problems in traditional electricity sales forecasting methods, such as the disconnect between feature selection and model performance, the simplicity of model fusion strategies, and the lack of adaptive optimization capabilities, and significantly improves forecasting accuracy and robustness. Attached Figure Description
[0019] Figure 1This is a flowchart illustrating a method for predicting monthly electricity sales by fusing dynamic feature selection and meta-learning, according to an exemplary embodiment. Figure 2 This is a schematic diagram of a monthly electricity sales forecasting device that integrates dynamic feature filtering and meta-learning, according to an exemplary embodiment. Figure 3 This is a closed-loop flowchart of a dynamic feature screening closed-loop system according to an exemplary embodiment. Detailed Implementation
[0020] To more clearly illustrate the technical features of the present invention, the present invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings.
[0021] like Figure 1 As shown in the figure, the monthly electricity sales prediction method based on the fusion of dynamic feature selection and meta-learning provided by this embodiment of the invention includes the following steps: Step 1: Construct a model performance-driven dynamic feature selection closed-loop system, and select features in parallel through multi-dimensional correlation analysis to generate a candidate feature subset pool. Step 2: The performance feedback mechanism of temporal cross-validation is used to evaluate the candidate feature subset, and the prediction performance of the fusion model is used as the criterion for feature subset selection. Step 3: Based on the optimal feature subset, construct a meta-learning-driven multi-model dynamic fusion framework, and adaptively learn the optimal combination weights of the base learners through the ridge regression meta-learner; Step 4: Use the trained fusion model to predict future monthly electricity sales. The dynamic feature selection closed-loop system works in conjunction with the meta-learning-driven multi-model dynamic fusion framework to form an end-to-end adaptive electricity sales forecasting system.
[0022] As one possible implementation of this embodiment, step 1 includes the following steps: Step 11: Obtain historical electricity sales time series data and multi-dimensional external feature data. The external features include weather features, time features, and basic attribute features. The weather features include monthly average temperature, monthly average humidity, cooling degree day (CDD), heating degree day (HDD), monthly average wind speed, and the interaction term between monthly average temperature and average humidity. The time features include the number of holidays, whether it is the Spring Festival, whether it is National Day, whether it is a hot month, whether it is a cold month, year, and month. The basic attribute features include: number of users, installed capacity, user density, installed capacity density, user month-on-month growth rate, and installed capacity month-on-month growth rate. Step 12: Use multi-dimensional correlation analysis to screen features in parallel and generate a pool of candidate feature subsets; Step 13: Evaluate and optimize the candidate feature subset through the model performance feedback mechanism; Step 14: Determine the optimal feature subset based on the evaluation results to complete the dynamic feature selection closed loop.
[0023] As one possible implementation of this embodiment, the multi-dimensional correlation analysis method includes: 1) Pearson correlation coefficient analysis method: Used to measure the linear correlation between features and the target variable, retaining features with |r|>0.3; The formula for calculating the Pearson correlation coefficient is as follows: , in, Let i represent the i-th observation of two variables. , It represents the average of two variables.
[0024] 2) Spearman's rank correlation analysis method: Used to identify monotonically nonlinear relationships between features and target variables, retaining features where |ρ|>0.3; The formula for calculating the Spearman level correlation is as follows: , in, This represents the rank difference between two variables.
[0025] 3) Random Forest Feature Importance Analysis Method: The Gini importance assessment evaluates the overall utility of features in the model, retaining the top 50% of features by importance score; The importance of the random forest features is calculated by constructing a random forest model with 100 decision trees. The formula for calculating Gini importance is as follows: , in, Let T represent the number of trees, and T represent a single decision tree. Represents a node in a tree. Indicates at node The reduction in Gini impurity when splitting using feature j.
[0026] 4) SHAP value analysis method: Based on game theory calculations of the marginal contribution of features to the prediction results, the top 50% of features with the average absolute value of SHAP values are retained. The formula for calculating the SHAP value is as follows: , Where: F represents the set of all features, S represents the subset of features that does not contain feature f, and Pred(S) represents the model prediction when only the subset of features S is used.
[0027] As one possible implementation of this embodiment, the specific process of generating the candidate feature subset pool in step 12 includes: applying four screening ratios of 20%, 30%, 40%, and 50% to the four correlation analysis methods respectively; for each "method × ratio" combination, sorting its corresponding feature list in descending order of importance, and extracting the features with the first total number of features × ratio; summarizing the feature subsets generated by all methods under all ratios to form a candidate pool containing 16 candidate feature subsets.
[0028] As one possible implementation of this embodiment, the dynamic feature screening closed-loop system also includes a feedback optimization mechanism: as new data is continuously acquired, the dynamic feature screening process is periodically re-executed; the feature importance assessment is updated based on the latest data; and the optimal feature subset is dynamically adjusted to ensure that the system continuously adapts to changes in data distribution.
[0029] As one possible implementation of this embodiment, step 2 includes the following steps: Step 21: Using a rolling prediction origin temporal cross-validation strategy, multiple training-validation data folds are constructed. Step 22: For each feature subset in the candidate feature subset pool, perform model training and validation on each fold of temporal cross-validation; Step 23: Based on the prediction performance of the fusion model on the validation set, calculate the comprehensive score for each candidate feature subset; Step 24: Select the optimal feature subset based on the comprehensive score to complete the performance feedback evaluation.
[0030] As one possible implementation of this embodiment, the time-series cross-validation strategy for the rolling prediction origin specifically includes: organizing a total of 54 months of historical data in chronological order; setting the initial training window length to 36 months and the validation window length to 12 months; after validation, the training window and the validation window are synchronously rolled forward by 12 months as a step; keeping the fixed length of the training window unchanged, and repeating the above process until the end of the data.
[0031] As one possible implementation of this embodiment, the temporal cross-validation specifically forms the following two consecutive training-validation folds: First fold: The training set consists of data from month 1 to month 36, and the validation set consists of data from month 37 to month 48; The second fold: the training set consists of data from months 13 to 48, and the validation set consists of data from months 49 to 54.
[0032] As one possible implementation of this embodiment, step 22 includes model training and validation for each candidate feature subset, which includes: training a SARIMAX model and an XGBoost model as base learners using the candidate feature subsets respectively; using the predicted values of the two base learners on the validation set as meta-features to train a ridge regression meta-learner for fusion; and calculating the key performance indicators of the fused model on the validation set.
[0033] As one possible implementation of this embodiment, the training process of the SARIMAX model specifically includes: performing a unit root test on the electricity sales sequence of the training set to determine the non-seasonal differencing order d; performing a seasonal unit root test on the sequence that has been non-seasonally differencing to determine the seasonal differencing order D; plotting the autocorrelation function (ACF) and partial autocorrelation function (PACF) plots of the sequence to provide preliminary references for the values of p, q, P, and Q; and using a grid search strategy to find the optimal combination of (p, d, q, P, D, Q) with the goal of minimizing the Akaike information criterion (AIC).
[0034] As one possible implementation of this embodiment, the search range of the grid search includes: The values of p and q are in the range of [0, 1, 2]; The values of P and Q are in the range of [0,1]; d and D are determined by the unit root test and are fixed to 0 or 1.
[0035] As one possible implementation of this embodiment, the training process of the XGBoost model specifically includes: using the Optuna optimization framework for automatic hyperparameter optimization; setting the hyperparameter search space, including n estimators learning rate ,max depth ,subsample,colsample bytree reg alpha and reg lambda The optimization objective is to minimize the mean absolute percentage error (MAPE) on the validation set; the hyperparameter space is intelligently explored using the TPE sampler.
[0036] As one possible implementation of this embodiment, the hyperparameter search space is specifically as follows: n estimators [50, 300], Integer type; learning rat [0.01, 0.3], logarithmically uniform distribution; max depth h:[3,10], integer type; subsample: [0.7, 1.0], uniformly distributed; colsample bytree [0.7, 1.0], uniformly distributed; reg alpha [0,1], uniformly distributed; reg lambda a:[1,10], uniformly distributed.
[0037] As one possible implementation of this embodiment, the training process of the ridge regression learner includes: The predicted values of the SARIMAX model and the XGBoost model on the validation set are used as meta-features to generate a two-dimensional meta-feature vector. ; The ridge regression model is used, and the model form is as follows: ; The optimal regularization parameter α is determined by grid search, with a search range of [0.01, 0.1, 1.0, 10.0, 100.0]. The optimal value of α is determined with the goal of minimizing the mean squared error (MSE) of the meta-learner on the validation subset.
[0038] As one possible implementation of this embodiment, the specific process of calculating the comprehensive score in step 23 includes: constructing a multi-index decision matrix, with MAPE as the main index and RMSE and R² as the secondary indexes; standardizing the performance indexes of each candidate feature subset; and calculating the comprehensive score: comprehensive score = 0.5 × (1 - standardized MAPE) + 0.3 × standardized R² + 0.2 × (1 - standardized RMSE).
[0039] As one possible implementation of this embodiment, the weight coefficients in the multi-index decision matrix are set based on the following: The MAPE weight is 0.5 because it is a core business indicator for electricity sales forecasting in the power industry. The R² weight is 0.3, which is used to measure the extent to which the model explains the variance of the target variable; The RMSE weight is 0.2, which, as a supplement to MAPE, jointly constrains the prediction error.
[0040] As one possible implementation of this embodiment, the specific rule for selecting the optimal feature subset in step 24 is as follows: The candidate feature subset with the highest comprehensive score is selected as the optimal feature subset; when the difference in comprehensive scores among multiple feature subsets is less than 5%, the subset with fewer features is selected first; the selected optimal feature subset will be used for the subsequent construction of the meta-learning-driven multi-model dynamic fusion framework.
[0041] As one possible implementation of this embodiment, the performance feedback mechanism also includes a method for calculating performance metrics: The formula for calculating the Mean Absolute Percentage Error (MAPE) is: , The formula for calculating the root mean square error (RMSE) is: , The formula for calculating the coefficient of determination R² is: , in, Let i be the actual electricity sales value of the i-th sample. Let i be the actual electricity sales value of the i-th sample. The total number of predicted samples participating in the evaluation. It is the arithmetic mean of all actual observations.
[0042] As one possible implementation of this embodiment, the temporal cross-validation performance feedback mechanism also includes visualization analysis of the validation results: generating a performance comparison chart of each candidate feature subset on different validation folds; drawing a decision path diagram of the optimal feature subset selection process; and providing a correlation analysis between feature importance ranking and model performance.
[0043] As one possible implementation of this embodiment, step 3 includes the following steps: Step 31: Using the optimal feature subset, retrain the final base learner on all training data; Step 32: Based on the prediction results of the base learner, construct the meta-feature dataset; Step 33: Train the ridge regression meta-learner and dynamically learn the optimal combination weights of the base learners; Step 34: Construct a complete meta-learning-driven multi-model dynamic fusion framework.
[0044] As one possible implementation of this embodiment, retraining the final base learner in step 31 includes: using the same parameter optimization process as in the dynamic feature selection process, redetermining the optimal parameter combination of the SARIMAX model on all training data; using the same Optuna-based automatic hyperparameter optimization process as in the dynamic feature selection process, redetermining the optimal hyperparameter combination of the XGBoost model on all training data; and using the determined optimal parameters and hyperparameters, training the final SARIMAX model and XGBoost model on all training data respectively.
[0045] As one possible implementation of this embodiment, the final training process of the SARIMAX model includes: performing a unit root test on the electricity sales sequence of all training data to determine the final d and D values; providing reference values for p, q, P, and Q based on ACF and PACF plot analysis; using a grid search on all training data to minimize AIC and find the final (p, d, q, P, D, Q) combination; and using the finally determined optimal parameter combination to fit the final SARIMAX model on all training data.
[0046] As one possible implementation of this embodiment, the final training process of the XGBoost model includes: redefining the hyperparameter search space on all training data; using the Optuna optimization framework, with minimizing the MAPE on the validation set as the optimization objective, to perform automatic hyperparameter optimization; selecting the hyperparameter combination with the lowest MAPE on the validation set from all trials as the final optimal configuration; and using the finally determined optimal hyperparameter combination to fit the final XGBoost model on all training data.
[0047] As one possible implementation of this embodiment, the specific process of constructing the meta-feature dataset in step 32 includes: using two final base learners to predict all training data to obtain the meta-feature set on the full dataset. The meta-feature set is divided into training and validation sets; the meta-feature data is standardized to eliminate the influence of units.
[0048] As one possible implementation of this embodiment, the specific process of training the ridge regression meta-learner in step 33 includes: performing a grid search on the meta-feature dataset to find the optimal regularization parameter α. final The search range is [0.01, 0.1, 1.0, 10.0, 100.0], with the objective of minimizing the mean squared error (MSE) on the validation set; the determined optimal α is used. final Using all meta-feature data, train the final ridge regression meta-learner; the model form of the ridge regression meta-learner is as follows: .
[0049] As one possible implementation of this embodiment, step 34, which constructs a complete meta-learning-driven multi-model dynamic fusion framework, includes: integrating the trained final SARIMAX model, the final XGBoost model, and the final ridge regression meta-learner; establishing data flow pipelines between models to ensure smooth execution of the prediction process; and achieving automated operation of the framework to support batch prediction of new data.
[0050] As one possible implementation of this embodiment, the meta-learning-driven multi-model dynamic fusion framework also includes a weight visualization function: real-time display of changes in the weight coefficients of the base learners; provision of historical trend analysis of weight distribution; and generation of a correlation report between weights and prediction performance.
[0051] As one possible implementation of this embodiment, the framework also includes a model performance monitoring mechanism: real-time monitoring of the prediction bias of each base learner; detection of the stability of the weight allocation of the meta learner; and triggering the model retraining process when the performance drops below a threshold.
[0052] As one possible implementation of this embodiment, the framework supports incremental learning: when new data is available, the model parameters are updated without retraining the entire model; a sliding window mechanism is used to maintain the model's adaptability to the latest data patterns; and the model performance is evaluated periodically to determine whether a full retraining is needed.
[0053] As one possible implementation of this embodiment, the framework also includes an anomaly detection mechanism: monitoring the consistency of the prediction results of the base learner; triggering an anomaly warning when the difference in the predictions of the base learner is too large; and providing suggestions for handling anomalies and model adjustment schemes.
[0054] As one possible implementation of this embodiment, the performance evaluation metrics of the framework include: MAPE, RMSE, and R² of the fusion model on the test set; stability metrics of the base learner weight coefficients; confidence interval evaluation of the model predictions; and prediction consistency checks at different time scales.
[0055] The technical advantages of the meta-learning-driven multi-model dynamic fusion framework described in this invention are reflected in: dynamically adjusting the weights of base learners through meta-learners to adapt to changes in data distribution; using ridge regression to solve the collinearity problem of base learner prediction results; achieving complementarity of the advantages of different base learners to improve overall prediction performance; and providing an interpretable model fusion mechanism to enhance the credibility of prediction results.
[0056] As one possible implementation of this embodiment, step 4 includes the following steps: Step 41: Obtain the external feature data corresponding to future months to form the optimal feature subset; Step 42: Input the optimal feature subset into the trained base learner to obtain the prediction result of the base learner; Step 43: Use the prediction results of the base learner as meta-features and input them into the trained meta-learner to obtain the final predicted electricity sales volume. Step 44: Post-process and visualize the prediction results.
[0057] As one possible implementation of this embodiment, step 41, obtaining the external feature data corresponding to future months, includes: Obtain weather characteristic data for the coming months, including monthly average temperature, monthly average humidity, cooling degree day (CDD), and heating degree day (HDD). Obtain time characteristic data for future months, including the number of holidays, whether it is the Spring Festival, whether it is National Day, whether it is a hot month, and whether it is a cold month; Obtain basic attribute data for future months, including number of users, installation capacity, user density, and installation capacity density; The acquired external feature data undergoes the same preprocessing and standardization processes as in the training phase.
[0058] As one possible implementation of this embodiment, the prediction process of the base learner in step 42 includes: inputting the optimal feature subset into the trained final SARIMAX model to obtain the predicted value of the SARIMAX model. sarimax The optimal feature subset is input into the trained final XGBoost model to obtain the predicted values of the XGBoost model. xgboost Record the prediction results and prediction confidence of the two base learners.
[0059] As one possible implementation of this embodiment, the prediction process of the SARIMAX model specifically includes: using the optimal parameter combination (p,d,q,P,D,Q) determined during the training phase; inputting external features as exogenous variables into the model; performing multi-step prediction to obtain the predicted electricity sales value for future months; and simultaneously outputting the prediction confidence interval.
[0060] As one possible implementation of this embodiment, the prediction process of the XGBoost model specifically includes: using the optimal hyperparameter combination determined during the training phase; inputting the optimal feature subset into the trained XGBoost model; performing prediction to obtain the predicted electricity sales value for the future month; and using the model's internal mechanism to calculate the uncertainty estimate of the prediction.
[0061] As one possible implementation of this embodiment, the prediction process of the meta-learner in step 43 includes: The predictions of the two base learners As a meta-feature vector; Input the meta-feature vectors into the trained final ridge regression meta-learner; The meta-learner calculates the final fusion prediction value based on the learned weight coefficients: , Where b is the bias term, and w1 and w2 are weighting coefficients.
[0062] As one possible implementation of this embodiment, the post-processing of the prediction results in step 44 includes: performing de-standardization on the predicted value to convert it into actual electricity sales units; calculating the confidence interval of the predicted value to provide an assessment of prediction uncertainty; performing a reasonableness check to ensure that the predicted value is within the reasonable range for business operations; and marking and manually reviewing abnormal predicted values.
[0063] As one possible implementation of this embodiment, the method for calculating the confidence interval includes: based on the historical error distribution of the prediction results of the base learner; considering the stability of the weight coefficients of the meta-learner; combining uncertainty propagation analysis of external features; and using the Bootstrap method for interval estimation.
[0064] As one possible implementation of this embodiment, the visualization output includes: generating a predicted trend chart of future monthly electricity sales; displaying a comparison between the base learner prediction results and the fusion prediction; providing a visualization of the prediction confidence interval; and generating a statistical summary report of the prediction results.
[0065] As one possible implementation of this embodiment, the prediction accuracy index of the monthly electricity sales forecasting method is: The mean absolute percentage error (MAPE) on the test set is no higher than 0.88%. The root mean square error (RMSE) is no higher than 500,423,963 MWh; The coefficient of determination R² is not less than 0.9432; The prediction stability index is superior to traditional single-model methods.
[0066] like Figure 2 As shown in the figure, an embodiment of the present invention provides a monthly electricity sales forecasting device that integrates dynamic feature filtering and meta-learning, comprising: The dynamic feature selection module is used to build a model performance-driven dynamic feature selection closed-loop system. It selects features in parallel through multi-dimensional correlation analysis methods to generate a pool of candidate feature subsets. The performance evaluation module is used to evaluate the candidate feature subset using the performance feedback mechanism of temporal cross-validation, and uses the prediction performance of the fusion model as the criterion for feature subset selection. The meta-learning fusion module is used to construct a meta-learning-driven multi-model dynamic fusion framework based on the optimal feature subset, and to adaptively learn the optimal combination weights of the base learners through the ridge regression meta-learner. The prediction execution module is used to predict future monthly electricity sales using a trained fusion model; The dynamic feature selection closed-loop system works in conjunction with the meta-learning-driven multi-model dynamic fusion framework to form an end-to-end adaptive electricity sales forecasting system.
[0067] Based on the above technical solution, the specific implementation steps for monthly electricity sales forecasting based on the fusion of dynamic feature selection and meta-learning are as follows.
[0068] S1: Data Acquisition and Preprocessing Obtain historical electricity sales time series data, as well as related multidimensional external feature data.
[0069] Target variable: monthly electricity sales, unit: 10,000 kWh, time span: 4.5 years of historical data; External characteristics: Weather characteristics: monthly average temperature (°C), monthly average humidity (%), cooling degree day (CDD), heating degree day (HDD), monthly average wind speed (m / s), and interaction term between monthly average temperature and average humidity. Time characteristics: Number of holidays, whether it is Spring Festival (0 / 1), whether it is National Day (0 / 1), whether it is a hot month (0 / 1), whether it is a cold month (0 / 1), year, month; Basic attributes: Number of users (households), installed capacity (kW), user density, installed capacity density, month-on-month growth rate of users (%), month-on-month growth rate of installed capacity (%).
[0070] S1.1 Data Cleaning: Missing value handling: Temporal linear interpolation is used, formula: , Where t represents the current time; Outlier detection: Box plots are used to define outliers as data points that exceed the range of Q1 - 1.5IQR or Q3 + 1.5IQR. (Q1 represents the lower quartile, i.e., the value at the 25th percentile; IQR represents the interquartile range, i.e., the difference between Q3 (the upper quartile) and Q1 (IQR = Q3). Q1) Outlier correction: Replace with the moving average of the previous and next three months. (The moving average is the average of time series data calculated by moving the data over a specified period.)
[0071] S1.2 Feature Engineering: Cooling / Heating Degree Daily Calculation: , , Where D is the number of days in the month. The average daily temperature; Periodic coding: , ; Characteristics of holidays: Number of holiday days = Total number of statutory holidays in the current month Whether it includes the Spring Festival: 1 for months containing the Spring Festival, 0 for others. Adjustments need to be made based on the specific year. Whether it is National Day: 1 if the month is October, 0 otherwise. Is it a hot month? The value is 1 for July and August, and 0 for others. Is it a cold month? 1 for January and December, 0 for others.
[0072] S1.3 Data Standardization: Z-score standardization is applied to all numerical features: , in, The characteristic mean, The standard deviation is denoted as .
[0073] S2: Dynamic Feature Filtering Closed Loop One of the core features of this invention is the construction of a "model performance-driven" dynamic feature selection closed-loop system. The core idea of this closed-loop mechanism is that the ultimate criterion for feature selection is not its score on a certain statistical metric, but rather its ability to ultimately improve the prediction accuracy of the fusion model. Its specific implementation process constitutes a complete optimization loop, such as... Figure 3 As shown.
[0074] Initial feature set input: Input the preprocessed complete feature set into the closed-loop system; Parallel screening using multiple methods: Four correlation analysis methods based on different principles (Pearson, Spearman, random forest importance, SHAP) are used to generate preliminary feature rankings from multiple dimensions such as linear, nonlinear, intrinsic, and extrinsic models. Generate candidate feature subset pools: For the ranking results of each method, apply different screening ratios (20%, 30%, 40%, 50%) to systematically generate a series of candidate subset pools with different numbers and combinations of features; Model performance feedback – the core of the closed loop: For each candidate feature subset in the pool, an internal temporal cross-validation process is initiated; the base learner (SARIMAX and XGBoost) is trained using this subset, and a meta learner (ridge regression) is further trained for prediction fusion. Finally, the comprehensive performance (MAPE, R², RMSE) of the fusion model on the validation set is used as the sole criterion for evaluating the quality of the feature subset. Decision and Output: Based on model performance feedback, the feature subset with the highest comprehensive score is selected through a multi-index decision matrix as the optimal output for this round of closed-loop screening.
[0075] S2.1 Correlation Analysis and Threshold Setting: (1) Pearson correlation coefficient: , in, Let i represent the i-th observation of two variables. , This represents the average of two variables. Choosing the characteristic with the larger absolute value of r reflects a linear relationship. Threshold setting: Retain features where |r|>0.3; Basis for setting this threshold: This threshold is a commonly used empirical value in statistics. |r|>0.3 is generally considered to indicate at least moderate linear correlation. This standard can effectively filter out features with weak linear relationship to the target variable, while avoiding missing potentially useful features due to an excessively high threshold (e.g., |r|>0.5), providing a reasonable screening granularity in the initial feature screening stage.
[0076] (2) Spearman's rank correlation: , in, This represents the difference in grades between two variables. For example, temperature has values of [10, 15, 20] and grades of [1, 2, 3], while humidity has values of [68, 50, 48] and grades of [3, 2, 1]. The grade differences between temperature and humidity are -2, 0, and 2, respectively. Sort the features by absolute value in descending order and select the features with larger absolute values. Threshold setting: Retain features where |ρ|>0.3; Basis for setting: Spearman correlation coefficient is sensitive to nonlinear monotonic relationships. Setting the same threshold as Pearson (|ρ|>0.3) aims to maintain consistency in screening criteria, ensuring that features with a stable monotonic relationship with electricity sales can be captured from a nonlinear perspective, effectively complementing Pearson's linear analysis.
[0077] (3) Importance of features in random forests: Construct a random forest with 100 decision trees; Calculate the importance of the Gini: , in, Let T represent the number of trees, and T represent a single decision tree. Represents a node in a tree. Indicates at node The reduction in Gini impurity during splitting using feature j, for nodes The impurity of the gin is: , Where K represents the number of categories, Represents a node If the proportion of samples in class k is given, then: , in, Gini impurity of the node before splitting. , These represent the Gini impurities of the left and right nodes after the split, respectively. , Let be the number of samples in the left and right nodes. The number of samples in the parent node; Threshold setting: Retain the top 50% of features by importance score; Basis for setting: The Gini importance of random forest is a model-based feature evaluation method; selecting the top 50% as the threshold is a strategy that balances efficiency and effectiveness; it is based on the assumption that "the importance distribution usually follows the Pareto principle (most importance is contributed by a few features)," which can filter out a subset of features with high contribution, while ensuring the diversity of the candidate pool in subsequent steps and avoiding prematurely discarding features that may perform well in other models due to an overly strict threshold.
[0078] (4) Random Forest + SHAP Feature Ranking: Construct a random forest with 100 decision trees; SHAP analysis was performed on the random forest model. SHAP, based on the Shapley value in cooperative game theory, assigns a contribution value to the prediction result for each feature. The formula for calculating the Shapley value is: , Where: F represents the set of all features, S represents the subset of features that does not include feature f, and Pred(S) represents the model prediction using only the subset of features S. This represents the Shapley value of feature f; Global feature importance based on SHAP values is defined as the average of the absolute values of the SHAP values for each feature: : Where Y is the sample size. Let f be the SHAP value of feature f in the i-th sample; Threshold setting: Retain the top 50% of features based on the average absolute value of the SHAP values; Rationale: SHAP values provide a consistent and theoretically robust measure of feature contribution, capturing the interaction effects between features. Using the same proportion (top 50%) as the previous method ensures comparability in selection criteria when introducing this more accurate but computationally expensive approach. This guarantees that the features selected from the SHAP perspective are the core feature set most relevant to the model's predicted output.
[0079] S2.2: Generate a pool of candidate feature subsets: This step aims to generate a diverse pool of candidate feature subsets by combining different screening methods and ratios, providing a foundation for subsequent fine-grained screening based on model performance.
[0080] Generation rules: Method-Proportion Combination: For the four correlation analysis methods mentioned above, for the feature importance ranking produced by each method, multiple different feature selection proportions are applied, including: retaining the top 20%, 30%, 40%, and 50% of features; Subset generation: For each "method × proportion" combination, sort its corresponding feature list in descending order of importance, and extract the top features equal to the total number of features × proportion to form a candidate feature subset; Pool construction: Aggregate the feature subsets generated by all methods at all proportions to form a unified candidate feature subset pool.
[0081] Quantity control: Under the above rules, the theoretical maximum capacity of the candidate pool is 4 methods × 4 ratios = 16 candidate feature subsets; this quantity control is carefully designed. Avoid combinatorial explosion: By limiting the number of methods and proportions, the size of the candidate pool is effectively controlled, ensuring that subsequent model-based evaluation is computationally feasible; Ensuring diversity: 16 subsets are sufficient to cover the search space defined by different evaluation criteria (linear, nonlinear, model intrinsic, model extrinsic) and different feature quantity granularities (from a concise 20% to a relatively rich 50%), which greatly reduces the risk of missing the optimal feature combination due to a single screening strategy.
[0082] Reasons for choosing the feature selection ratio: The selection of 20%, 30%, 40%, and 50% is based on the following considerations: Covering different model complexities: 20% and 30% tend to produce more concise subsets, which helps to build simple models with strong generalization ability; while 40% and 50% retain more features, providing more information for the model to capture complex patterns, and are suitable for more complex models; Balanced exploration and utilization: This setup allows the scheme to explore both "few but precise" feature combinations and "many but comprehensive" feature combinations simultaneously, and determines which level of complexity is most suitable for the prediction task based on subsequent model performance feedback. Practical experience: These ratios are commonly used selection intervals in feature engineering, which can systematically examine the impact of the number of features on model performance and avoid the bias caused by arbitrarily choosing ratios.
[0083] S2.3: Feature evaluation based on model feedback: For each subset of candidate features in the pool, perform the following operations: A temporal cross-validation design is employed: To ensure the robustness of model evaluation and strictly adhere to the temporal dependencies of time series data, thus avoiding future information leakage, this invention adopts a temporal cross-validation strategy called "rolling prediction origin." This scheme simulates the scenario where the model iteratively predicts and updates over time in the real world.
[0084] The specific implementation plan is as follows: Data partitioning rules: Historical data spanning a total of 54 months (4.5 years) is organized chronologically. The initial training window length is set to 36 months (3 years), and the validation window length is set to 12 months (1 year). After validation, the training window and validation window are synchronously scrolled forward by 12 months (1 year) as a step, while maintaining the fixed length of the training window. This scrolling process is repeated until the end of the data. Validation Folding and Number of Folds: Based on the above rules, the entire dataset is divided into two consecutive training-validation folds, resulting in a total of two complete model training and evaluation cycles: First fold: The training set consists of data from months 1 to 36, and the validation set consists of data from months 37 to 48. The second fold: the training set consists of data from months 13 to 48, and the validation set consists of data from months 49 to 54. These two validations effectively covered different time periods of the dataset, enabling the model to be tested for its adaptability to seasonal patterns, long-term trends, and potential economic cycle changes. Performance Metrics Summary: For each candidate feature subset, calculate its performance metrics (MAPE, RMSE, R²) across all two validation folds. The final performance of this feature subset is the average of its performance metrics across two folds. This summary method provides a robust and reliable performance evaluation, preventing the model from being mistakenly selected due to occasional good performance in a specific time period.
[0085] Base learner training: Using this feature subset, train the SARIMAX model and the XGBoost model respectively.
[0086] b1. The parameter determination and training process of the SARIMAX model is as follows: The SARIMAX model is represented as ,in: p: Order of the autoregressive (AR) term d: Difference order, used to make the sequence stationary. q: The order of the moving average (MA) term. P, D, Q: Order of seasonal autoregressive, differencing, and moving average terms. s: seasonal cycle; for monthly data, s=12. b1.1 Parameter optimization process: b1.1.1: Stationarity handling: First, perform a unit root test (ADF test) on the electricity sales series of the training set to determine the non-seasonal differencing order d; if the p-value of the test is greater than 0.05, the series is considered non-stationary, and differencing (d=d+1) is performed and the test is repeated until the series is stationary; usually, the value of d is 0 or 1. b1.1.2: Seasonal stationarity treatment: Perform a seasonal unit root test (such as the CH test) on the series that has already undergone non-seasonal differencing to determine the order of seasonal differencing, D. Typically, D takes the value of 0 or 1. b1.1.3: Preliminary order determination: After the sequence is stationary through differencing, plot the autocorrelation function (ACF) and partial autocorrelation function (PACF) of the sequence, observe the truncation and tailing phenomena, and provide preliminary reference for the values of p, q, P, and Q. b1.1.4: Automated Grid Search: Based on the above analysis, a compact and efficient parameter search space is defined. A grid search strategy is adopted on the training set to minimize the Akaike Information Criterion (AIC) and find the optimal combination of (p, d, q, P, D, Q); Example of search range: The range of values for p and q is [0, 1, 2]. The range of values for P and Q is [0,1]. d and D are determined by steps b1.1 and b1.2, and are usually fixed to 0 or 1; Optimization objective: AIC = 2k - 2ln(L), where k is the total number of model parameters and L is the likelihood function value. AIC balances the goodness of fit and complexity of the model, helping to prevent overfitting; The optimal parameters determined on all training data through the automatic optimization process are (1,1,1)×(1,1,0,12). b1.1.5 Model Diagnosis: Perform residual analysis on the model fitted with the optimal parameter combination to ensure that the residual sequence is approximately white noise; b1.2 Model Training: The optimal parameters (p,d,q,P,D,Q) obtained through optimization are used, and the selected external feature variables (as exogenous variables) are incorporated to fit the final SARIMAX model on the training set.
[0087] The hyperparameter configuration and training process of the b2.XGBoost model are as follows: XGBoost Hyperparameter Definition and Optimization Strategy: XGBoost (eXtreme Gradient Boosting) is a gradient boosting tree algorithm that minimizes the loss function by iteratively training a series of decision trees; its key hyperparameter configurations and selection criteria are as follows: b2.1 Core hyperparameters and their functions: n estimators (Number of trees): Controls the number of boosting rounds. Too few trees may lead to underfitting, while too many increase computational overhead and may cause overfitting; learning rate (Learning rate, or eta): Shrinks the weight of each tree to prevent a single tree from having too much influence; a smaller learning rate usually requires more trees, but the model is more robust; max depth (Maximum tree depth): Controls the complexity of the tree. A greater depth allows the model to capture non-linear interactions more effectively, but it is also more prone to overfitting. subsample (subsampling ratio): The proportion of random samples used to train each tree; a value less than 1.0 can introduce randomness to prevent overfitting. colsample bytree (Column sampling ratio): The proportion of features randomly sampled when training each tree; also used to prevent overfitting and improve computation speed; reg alpha (L1 regularization term): Controls the strength of L1 regularization in the model, increasing the likelihood of feature selection and making the model more sparse; reg lambda (L2 regularization term): Controls the strength of L2 regularization in the model, which helps to prevent overfitting; b2.2 Hyperparameter optimization process: To obtain a high-performance and highly generalizable XGBoost model and minimize manual parameter tuning, this invention employs the Optuna optimization framework for automatic hyperparameter optimization. b2.2.1 Define the hyperparameter search space: The optimization process is performed within the following predefined search space: n estimators(50, 300), an integer type. learning rate (0.01, 0.3), logarithmically uniform distribution. max depth (3,10), an integer type. subsample: (0.7, 1.0), uniformly distributed. colsample bytree (0.7, 1.0), uniformly distributed. reg alpha (L1 regularization): (0,1), uniform distribution. reg lambda (L2 regularization): (1,10), uniform distribution; b2.2.2 Setting optimization goals and conducting experiments: Objective function: Define an objective function whose input is a combination of hyperparameters. Inside this function, the XGBoost model is built on the training fold of temporal cross-validation using the input hyperparameters, and the performance metrics are calculated on the validation fold. Optimization direction: Minimize the mean absolute percentage error (MAPE) on the validation fold as the optimization objective; Sampling Algorithm: Optuna uses the TPE (Tree-structured Parzen Estimator) sampler, which can intelligently explore and utilize potential hyperparameter regions based on historical experimental results, thereby efficiently approximating the global optimum. b2.2.3 Perform optimization and determine the optimal configuration: Set the total number of trials (e.g., n) trials =100), start the optimization process; Optuna automatically performs multiple rounds of trials. In each round, it samples a set of hyperparameters from the search space, performs an evaluation by executing the objective function, and guides the next round of sampling based on the results. After optimization, the hyperparameter combination with the lowest MAPE on the validation set is selected from all experiments and taken as the optimal configuration under the current candidate feature subset. b2.2.4 Model Training: Using the optimal hyperparameter combination obtained through Optuna optimization, the final XGBoost model is fitted on the complete current training set.
[0088] c. Meta-learner training and evaluation: This step aims to dynamically learn and fuse the predictions from two base learners (SARIMAX and XGBoost) rather than using fixed weights.
[0089] The predictions of the two base learners on the validation set are used as meta-features to train a ridge regression meta-learner, which is then fused. Key performance metrics of the fused model on the validation set are calculated: Mean Absolute Percentage Error (MAPE), Root Mean Square Error (RMSE), and Coefficient of Determination. The specific process is as follows: c1. Constructing the Meta-feature Set: The predictions of the SARIMAX and XGBoost models on the validation set are used as meta-features. Therefore, for each sample i in each validation set, a two-dimensional meta-feature vector is generated. This meta-feature vector captures the prediction perspectives of different base models for the same target.
[0090] c2. Define the meta-learner and optimization objective: Ridge Regression is used as the meta-learner. Its model form is as follows: Where w1 and w2 are weight coefficients, and b is the bias term. The learning objective of the meta-learner (ridge regression) is to find an optimal combination of weights [w1, w2] and bias b, such that the final fusion prediction... It is closest to the true value. Ridge regression addresses the potential collinearity problem between meta-features by introducing an L2 regularization term into the loss function and prevents overfitting, thus obtaining more robust fusion weights.
[0091] c3. Optimization of the regularization parameter (α): Selection criteria: The regularization parameter α controls the balance between model complexity and fit. Too large an α may lead to underfitting, failing to effectively learn the advantages of the base learner; too small an α may lead to overfitting the validation set, reducing the generalization ability of the fusion model. Optimization method: Within the training layer of temporal cross-validation, further optimization is performed using grid search; Parameter value range: Set a predefined search range on the logarithmic scale, for example, α∈[0.01,0.1,1.0,10.0,100.0]; this range covers typical scenarios from weak regularization to strong regularization; Optimization objective: The grid search aims to determine the optimal α value by minimizing the mean squared error (MSE) of the meta-learner on the validation subset within the training fold.
[0092] c4. Training and Evaluation: Using the determined optimal α, train the ridge regression meta-learner on the full training fold meta-features. Then, apply the trained fusion model to the validation fold meta-features to obtain the final fusion prediction result. final .
[0093] c5. Performance metric calculation: based on the final fusion prediction results final Based on the actual electricity sales figures on the validation set, key performance indicators (KPIs) are calculated: Mean Absolute Percentage Error (MAPE), Root Mean Square Error (RMSE), and Coefficient of Determination (R²). These KPIs will serve as direct criteria for evaluating the quality of the current candidate feature subset.
[0094] S2.4: Optimal Feature Subset Determination Strategy Constructing a multi-indicator decision matrix: (1) Obtain the model evaluation metrics for each subset. The primary metric is MAPE, and the secondary metrics are RMSE and [missing metric]. ; (2) Standardize the performance of subsets: Standardized MAPE = Normalized(Subset Performance.MAPE) # A smaller value is better. Standardized R² = Normalized(Subset Performance.R²) # A higher value is better. Normalized RMSE = Normalized(SubsetPerformance.RMSE) # A smaller value is better. Overall score = (0.5 × (1 - Standardized MAPE) + 0.3 × Standardized R² + 0.2 × (1 - Standardized RMSE)); (3) Based on the comprehensive score, select the subset list corresponding to the result with the highest score to determine the optimal feature list; Following the principle of simplicity, when the difference in the overall score of multiple feature subsets is less than 5%, the subset with fewer features is selected first to improve the model's generalization ability.
[0095] Methods for determining weight coefficients in a multi-indicator decision matrix: The overall score formula is: Overall Score = (0.5 × (1 - Standardized MAPE) + 0.3 × Standardized R² + 0.2 × (1 - Standardized RMSE)). The weighting coefficients (0.5, 0.3, 0.2) are set based on the objective priority and indicator characteristics of the prediction task. The MAPE weight is the highest (0.5): because in electricity sales forecasting in the power industry, the Mean Absolute Percentage Error (MAPE) is a core business indicator for measuring forecast accuracy. Its results have intuitive business interpretability (percentage error) and directly affect decisions regarding power trading and economic dispatch. Giving it the highest weight ensures that the selected scheme prioritizes feature subsets that minimize relative error. The R² weight is second (0.3): The coefficient of determination (R²) measures the extent to which the model explains the variance of the target variable. Giving it a moderate weight is to ensure both prediction accuracy (MAPE) and overall model fit. RMSE has the lowest weight (0.2): Root Mean Square Error (RMSE) is more sensitive to large prediction errors. Its relatively low weight is to prevent the model from over-adjusting to penalize individual extreme errors, thus affecting overall stability. It serves as a complement to MAPE, jointly constraining the prediction error. Basis for determination: This weighting allocation combines the expertise of power forecasting specialists with an understanding of business needs, and has been verified through preliminary experiments, proving that it can stably select a feature subset that performs well and stands out across multiple key indicators.
[0096] S3: Final Model Training and Prediction: Using the optimal feature subset determined in step S2.4, retrain the final base learners (SARIMAX and XGBoost models) and meta-learners (ridge regression) on all training data.
[0097] Training the final SARIMAX model: Using the same automated parameter optimization process described in step S2.3, b1.1, the optimal (p, d, q, P, D, Q) parameter combination is re-determined on all training data, and the final SARIMAX model is trained using this combination. This step ensures that the model parameters can be optimized based on complete available information, thereby achieving the best performance.
[0098] The final XGBoost model training follows the same Optuna-based automatic hyperparameter optimization process described in step S2.3 (b2.2). The search space is redefined, the objective is set, and optimization is performed on all training data to determine the optimal hyperparameter combination, which is then used to train the final XGBoost model. This ensures that the XGBoost model utilizes all available data and finds the best-matching hyperparameter settings through an automated process, guaranteeing optimal performance on the final prediction task.
[0099] Final meta-learner training: Using the two final base learners described above to predict all training data, we obtain the meta-feature set across the entire dataset. ; On this entire dataset, the same grid search process described in step S2.3 c.3 is executed again to find the optimal regularization parameter α. final ; Using α final Using all meta-feature data, train the final ridge regression meta-learner.
[0100] When it is necessary to predict future electricity sales, the external features of the future are first obtained (forming the optimal feature subset), and then input into the trained final SARIMAX model and the final XGBoost model respectively to obtain their predicted values; then these two predicted values are used as meta-features and input into the trained final ridge regression meta-learner to obtain the final fused and accurate electricity sales prediction result.
[0101] This invention does not simply combine dynamic feature selection with meta-learning, but rather through careful design, it achieves a significant synergistic effect, resulting in a "1+1>2" outcome. Positive reinforcement loop: Dynamic feature selection ensures that the features input to the base learners are optimized subsets most relevant to the prediction target. This directly improves the prediction performance and stability of both SARIMAX and XGBoost base learners. Furthermore, the superior and more stable base learners provide the meta-learners with higher-quality and more complementary meta-features, enabling the meta-learners to learn the optimal fusion weights more accurately, thus producing more precise final predictions. Closed-loop optimization system: The "closed-loop" mechanism of dynamic feature selection uses the performance of the fusion model as a feedback signal. This means that the standard for feature selection itself serves the purpose of "fusion," actively seeking feature combinations that optimize subsequent fusion results. Together, they constitute an end-to-end, automated, high-performance prediction system from features to model.
[0102] This invention employs four methods for preliminary feature ranking: Pearson correlation coefficient, Spearman correlation coefficient, random forest importance, and SHAP value, achieving complementary evaluation dimensions: Pearson correlation coefficient focuses on capturing linear relationships; Spearman correlation coefficient can effectively identify monotonic nonlinear relationships; random forest feature importance is based on the internal structure of the model and evaluates the comprehensive utility of features in splitting data; SHAP value is based on game theory, providing a consistent and fair measure of feature marginal contribution and capturing the interaction between features.
[0103] Generating a diverse candidate pool: Since each method operates on a different principle, the ranking of feature importance they provide will inevitably differ. This difference is precisely where the advantage lies. By combining these methods, we can generate a pool of candidate subsets whose features constitute a diverse set. This greatly expands the search space, avoids local optima that might arise from relying on a single evaluation criterion, and thus significantly increases the probability of discovering globally superior feature subsets.
[0104] To verify the effectiveness, generalization ability, and engineering practical value of the method proposed in this invention, the inventors designed a complete experimental scheme and conducted a comprehensive comparative analysis with existing mainstream prediction methods.
[0105] 1. Data sources and experimental setup: Data source: The experimental data comes from the actual operation data of a provincial power grid company in China from January 2021 to June 2025, totaling 54 monthly samples; Feature Dimensions: After preprocessing and feature engineering as described in step S1, the raw data is used to construct a dataset containing the original target variable (monthly electricity sales) and 23 external features. The external features cover weather (6 dimensions), time (7 dimensions), basic attributes (6 dimensions), and their derived variables (such as density, growth rate, interaction terms, etc.). Comparison Methods: To ensure a fair comparison, the following representative methods were selected as baselines: SARIMAX model: a representative of traditional time series models. XGBoost model: a representative of single machine learning models; The method of this invention is a complete process based on the fusion of dynamic feature selection and meta-learning. Experimental configuration: All experiments were conducted on the same configured server, with Python 3.9 as the software environment.
[0106] 2. Complete implementation process demonstration: Taking the monthly electricity sales forecast of the entire province as an example, the complete workflow of this invention is demonstrated: Data input: Import 54 months of electricity sales data and 23-dimensional external feature data from the database; Preprocessing and feature engineering (S1): Perform data cleaning, calculate CDD / HDD, perform periodic encoding, etc., to generate a standardized modeling dataset; Dynamic feature selection closed loop (S2); Sixteen candidate feature subsets were generated using four methods (Pearson, Spearman, Random Forest Importance, and SHAP) at four different proportions (20%, 30%, 40%, and 50%). Temporal cross-validation (2-fold) is performed on each subset to evaluate the performance of the base model + meta-learning fusion model driven by it.
[0107] The optimal subset is determined by calculating the comprehensive score using a multi-indicator decision matrix (MAPE weight 0.5, R² weight 0.3, RMSE weight 0.2). Final model training and prediction (S3): Using all historical data and the optimal feature set, retrain the final SARIMAX(1,1,1)x(1,1,0,12) and XGBoost models (Optuna optimizes hyperparameters: learning). rate =0.18,max depth =7, etc.); The final ridge regressor learner is trained using historical predictions (optimal α=0.1). Predicted output: Input the external features corresponding to the future month, make predictions through two base learners, and then output the final electricity sales prediction value (unit: 10,000 kWh) by the meta learner.
[0108] 3. Comparative analysis of prediction accuracy: The prediction accuracy comparison on the test set of this province (January 2025 - June 2025) is as follows:
[0109] Note: Base learners: refer to basic prediction models, such as SARIMAX and XGBoost, which are used to generate preliminary prediction results; Meta-learner: refers to a model used to fuse the prediction results of base learners, such as ridge regression, whose input is the prediction value of the base learners and the output is the final prediction; Fusion model: refers to the overall prediction system that combines base learners and meta-learners; Dynamic feature selection closed loop: refers to a mechanism that automatically adjusts feature selection based on model performance feedback, forming an optimization loop.
[0110] This invention uses a closed-loop feedback mechanism to automatically select the most effective feature subset for the prediction task, and uses a meta-learner to dynamically learn the optimal combination weights of different base learners (SARIMAX and XGBoost), thereby significantly improving the accuracy and robustness of electricity sales prediction.
[0111] An electronic device provided by an embodiment of the present invention includes a processor, a memory, and a bus. The memory stores machine-readable instructions that can be executed by the processor. When the electronic device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to perform the steps of the monthly electricity sales forecasting method that combines arbitrary dynamic feature screening and meta-learning as described above.
[0112] Specifically, the aforementioned memory and processor can be general-purpose memory and processor, without any specific limitations. When the processor runs the computer program stored in the memory, it can execute the aforementioned method for predicting monthly electricity sales by fusing dynamic feature selection and meta-learning.
[0113] Corresponding to the above application startup method, this embodiment of the invention also provides a storage medium storing a computer program, which, when run by a processor, executes the steps of the monthly electricity sales forecasting method that combines arbitrary dynamic feature selection and meta-learning as described above.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the protection scope of the claims of the present invention.
Claims
1. A monthly electricity sales volume prediction method combining dynamic feature screening and meta-learning, characterized in that, The method comprises the following steps: Step 1, constructing a model performance driven dynamic feature screening closed loop system, screening features in parallel through a multi-dimensional correlation analysis method, and generating a candidate feature subset pool; Step 2, evaluating the candidate feature subset by adopting a time series cross-validation performance feedback mechanism, and taking the prediction performance of the fusion model as the standard for selecting the feature subset; Step 3, based on the optimal feature subset, constructing a meta-learning driven multi-model dynamic fusion framework, and adaptively learning the optimal combination weight of the base learner through a ridge regression meta-learner; Step 4, predicting the future monthly electricity sales by using the trained fusion model; The dynamic feature screening closed loop system and the meta-learning driven multi-model dynamic fusion framework work together to form an end-to-end adaptive electricity sales prediction system.
2. The method of claim 1, wherein the dynamic feature screening and meta-learning fused monthly sales volume prediction method is characterized by, The step 1 comprises the following steps: Step 11, obtaining historical electricity sales time series data and multi-dimensional external feature data, wherein the external features include weather features, time features and basic attribute features; Step 12, screening features in parallel by adopting a multi-dimensional correlation analysis method, and generating a candidate feature subset pool; Step 13, evaluating and optimizing the candidate feature subset by adopting a model performance feedback mechanism; Step 14, determining the optimal feature subset based on the evaluation result, and completing the dynamic feature screening closed loop.
3. The method of claim 2, wherein the dynamic feature screening and meta-learning fused monthly sales volume prediction method is characterized by, The multi-dimensional correlation analysis method comprises: Pearson correlation coefficient analysis for measuring the linear correlation between the features and the target variable, and retaining the features with |r|>0.3; Spearman rank correlation analysis for identifying the monotonic nonlinear relationship between the features and the target variable, and retaining the features with |ρ|>0.3; Random forest feature importance analysis for evaluating the comprehensive utility of the features in the model through Gini importance, and retaining the features with importance scores in the top 50%; SHAP value analysis for calculating the marginal contribution of the features to the prediction result based on game theory, and retaining the features with SHAP value absolute value in the top 50%.
4. The method of claim 2, wherein the dynamic feature screening and meta-learning combined monthly sales volume prediction method is characterized in that, The weather features in the external features include: monthly average temperature, monthly average humidity, cooling degree days CDD, heating degree days HDD, monthly average wind speed, and the interaction term of monthly average temperature and average humidity; The time features in the external features include: number of holidays, whether it is the Spring Festival, whether it is the National Day, whether it is a hot month, whether it is a cold month, year, month; The basic attribute features in the external features include: number of users, installed capacity, user density, installed capacity density, user growth rate, installed capacity growth rate.
5. The method of claim 1, wherein the dynamic feature screening and meta-learning integrated monthly sales volume prediction method is characterized by, The step 2 comprises the following steps: Step 21, adopting a time series cross-validation strategy with a rolling prediction origin, and constructing multiple training-validation data folds; Step 22, for each feature subset in the candidate feature subset pool, performing model training and validation on each fold of the time series cross-validation; Step 23, based on the prediction performance of the fusion model on the validation set, calculating the comprehensive score of each candidate feature subset; Step 24, selecting the optimal feature subset according to the comprehensive score, and completing the performance feedback evaluation.
6. The method of claim 1, wherein the dynamic feature screening and meta-learning integrated monthly sales volume prediction method is characterized by, The step 3 comprises the following steps: Step 31, using the optimal feature subset to retrain the final base learner on all training data; Step 32, based on the prediction result of the base learner, constructing the meta-feature dataset; Step 33, training the ridge regression meta-learner to dynamically learn the optimal combination weight of the base learner; Step 34, constructing the complete meta-learning driven multi-model dynamic fusion framework.
7. The method of claim 1-6, wherein, The step 4 comprises the following steps: Step 41, acquiring the external feature data corresponding to the future month to constitute the optimal feature subset; Step 42, inputting the optimal feature subset into the trained base learner to obtain the prediction result of the base learner; Step 43, inputting the prediction result of the base learner as the meta-feature into the trained meta-learner to obtain the final power sales prediction value; Step 44, post-processing and visualizing the prediction result.
8. A dynamic feature screening and meta-learning combined monthly electricity sales prediction device, characterized in that, Comprise: A dynamic feature screening module for constructing a model performance driven dynamic feature screening closed loop system, which screens features in parallel through multi-dimensional correlation analysis method to generate a candidate feature subset pool; A performance evaluation module for evaluating the candidate feature subset by using a time series cross-validation performance feedback mechanism, taking the prediction performance of the fusion model as the standard for feature subset selection; A meta-learning fusion module for constructing a meta-learning driven multi-model dynamic fusion framework based on the optimal feature subset, and adaptively learning the optimal combination weight of the base learner through the ridge regression meta-learner; A prediction execution module for predicting the future monthly power sales by using the trained fusion model; Wherein, the dynamic feature screening closed loop system and the meta-learning driven multi-model dynamic fusion framework work together to form an end-to-end adaptive power sales prediction system.
9. An electronic device, comprising: Comprise a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, the processor executes the machine readable instructions to execute the steps of the dynamic feature screening and meta-learning fusion monthly power sales prediction method as claimed in any one of claims 1-7.
10. A storage medium, characterized by The storage medium stores a computer program, which is executed by the processor to perform the steps of the dynamic feature screening and meta-learning fusion monthly power sales prediction method as claimed in any one of claims 1-7.