Paper · 2026-05-25 · cs.LG
Electricity Consumption Forecasting: An Approach Using Cooperative Ensemble Learning with SHapley Additive exPlanations
Forecasts 12 months of monthly electricity use at two Brazilian university campuses with LSTM, random forest, SVR and XGBoost, tuned by a genetic algorithm and pruned with SHAP. Its Weaker Separator Booster pushes the LSTM forecast away from the mean of the other three. Author-reported sMAPE: 13.90% (Palmas), 18.72% (Coronel Vivida).
Time series forecastingEnsemble learningFeature attributionHyperparameter optimizationtime-seriesforecastingenergyensemble-learningshaphyperparameter-optimization
arXivPDFCodeMarkdown14 min read
AI-compiled by claude-haiku-5-5 on 2026-10-31, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
A university pays for the electricity its campuses use, and the monthly bill moves with the academic calendar, the number of people on site, and the weather. This paper tries to predict the next twelve months of consumption at two campuses of a Brazilian federal institute. It compares several standard forecasting tools: a neural network with memory (LSTM), a random forest, a support vector machine, a gradient-boosted tree model, and older statistical smoothing methods.
Two ideas set the work apart. First, it uses Shapley values (SHAP), a way of measuring how much each input pushes a prediction up or down, to drop inputs that add little. Second, it proposes the Weaker Separator Booster. The best single model, the LSTM, is nudged away from the average of three weaker models. The weaker models tend to predict an almost flat line, so the nudge is meant to make the strong forecast less flat.
The authors report that this combination gives the lowest error at both campuses. Treat the numbers as the authors' claims. Each campus was tested on one year only, and all models were inaccurate around a sustained consumption peak in that year.
TL;DR
- Compares LSTM, random forest, SVR and XGBoost, tuned by a genetic algorithm (GA) and pruned by SHAP, with classical forecasters for 12-month-ahead monthly electricity use at two IFPR campuses §1 §3.1.
- Proposes the Weaker Separator Booster (WSB): the GA-LSTM forecast plus a booster term built from the mean of GA-RF, GA-SVR and GA-XGBoost, with a weight that peaks mid-horizon §3.2.3 eq. 1-3.
- Author-reported: WSB has the lowest MAE and sMAPE at both campuses. Palmas: sMAPE 13.90%, MAE 1990.87 kWh. Coronel Vivida: sMAPE 18.72%, MAE 464.93 kWh tab. 14 tab. 15.
- One test window per campus, and the released code differs from the paper in several places (see Paper vs code and Pitfalls).
Problem
University electricity use is hard to plan. It depends on equipment, grid stability, holidays, occupancy and events, and accurate forecasts are needed to allocate resources §1. The authors also argue that few studies use cooperative ensembles for educational institutions §2.
The series is non-stationary and irregular. In Table 3, KPSS does not indicate stationarity at either campus, Kruskal-Wallis finds no seasonality at either, and Mann-Kendall finds no trend at dataset 1 but reports a trend at dataset 2 tab. 3 §3.1. The autocorrelation of dataset 1 is strong at the first lags, and dataset 2 has weaker lagged dependence fig. 3 fig. 4.
The method assumes a monthly series, twelve lagged consumption values as candidate inputs, and recursive forecasting over a 12-month horizon, in which each forecast is fed back as an input for the next step §3.2.1 §3.2.3.
Method
The pipeline has five parts: data and exogenous variables, preprocessing and SHAP pruning, model tuning, evaluation, and the WSB booster. The paper gives no code-level detail for the booster beyond the equations §3.2.
-
Data. Monthly electricity consumption (kWh) from IFPR invoices for two campuses: Palmas (dataset 1) and Coronel Vivida (dataset 2). The series run from September 2017 to March 2024, 79 months §3.1 fig. 1. Summary statistics are in tab. 2.
Series Observations Min Max Median Mean SD Dataset 1 (Palmas) 79 7252 25339 15342 15995.58 4693.60 Dataset 2 (Coronel Vivida) 79 1087 4579 2182 2262.53 636.45 Candidate exogenous variables are listed in tab. 4: 14 climate variables from IDR and SIMEPAR (temperature, rain, humidity, solar radiation and wind, in several aggregations), a COVID-19 pandemic period identifier from IFPR, and year and month. The pandemic period is marked as March 2020 to April 2022, when in-person activity was suspended §3.1.
-
Preprocessing §3.2.1. Missing values occur only in the January 2021 climate data for Palmas. Each missing value is replaced by the arithmetic mean of the same month in other years. Twelve lags of consumption are added. Month and year are one-hot dummies. Rows with any missing value are dropped. The result is 47 predictors §3.2.1.
-
SHAP pruning §3.2.1 fig. 6 fig. 7. Mean absolute SHAP values from RF and XGBoost, fitted on the Palmas data, are averaged to rank the predictors. The least important predictors are removed one at a time in ranked order. After each removal, RF and XGBoost are refitted and their MAE is recorded. The average of the two curves is lowest after 36 removals (MAE 3537.50), leaving 11 predictors fig. 7 tab. 5.
Pseudocode# Backward elimination ranked by SHAP [§3.2.1] [fig. 7] # Input: predictors sorted by mean |SHAP|, least important first # Output: predictor set with the lowest average MAE def select_predictors(ranked, max_removed): best_set = ranked best_mae = float("inf") # Try removing the k least important predictors [§3.2.1] for k in range(max_removed + 1): kept = ranked[k:] # Refit RF and XGBoost on the kept set and average their MAE # [fig. 7] mae = mean([fit_and_score(rf, kept), fit_and_score(xgb, kept)]) if mae < best_mae: best_set = kept best_mae = mae return best_setThe 11 predictors kept tab. 5:
- consumption lags 1, 2, 3, 6 and 12;
- maximum temperature (average absolute), minimum temperature (absolute) and maximum wind speed (absolute);
- a March dummy and a 2019 dummy;
- the COVID-19 period identifier.
Figures 12 and 13 show that the lags push predictions in opposite directions at the two campuses fig. 12 fig. 13.
-
Models §3.2.2. The paper uses LSTM, RF, SVR and XGBoost as the optimised models. For comparison it adds CNN and ESN (both optimised the same way) and the statistical methods exponential smoothing, double exponential smoothing, Holt-Winters additive and multiplicative, and ARIMA §3.2.2 tab. 14 tab. 15. The paper does not state the LSTM or CNN layer structure; the released code uses one LSTM layer with a Dense(1) output, and a Conv1D with kernel 2, max pooling 2, a Dense layer and a Dense(1) output Results - Palmas 12m.ipynb Results - Palmas 12m.ipynb.
-
Hyperparameter search §3.2.2 tab. 12. Two metaheuristics are compared: a custom genetic algorithm (GA) and particle swarm optimisation (PSO). The objective is the mean MAE over 5-fold time-series cross-validation on the training data §3.2.2 Optimization.ipynb. Each search is run with three seeds, and the best configuration across GA, PSO and seeds is kept for each model Results - Palmas 12m.ipynb. The paper reports that GA found the best configuration for every model §3.2.2.
-
Evaluation split §3.2.3 fig. 9. The final 12 periods form the test set. The rest is used for 5-fold cross-validation, with each fold training on earlier months and testing on the next single month Results - Palmas 12m.ipynb. The paper describes the cross-validation as 6-fold in §3.2 and 5-fold in §3.2.3 (see Paper vs code).
-
Weaker Separator Booster §3.2.3 eq. 1-3. The GA-LSTM model is the strong predictor, and GA-RF, GA-SVR and GA-XGBoost are the n = 3 weaker predictors. The authors note that the weaker models tend to produce near-straight horizontal forecasts, and that the booster is meant to widen the gap to the strong forecast §1 §3.2.3. The booster averages the weaker forecasts and subtracts that average from the strong forecast, then scales the difference by a time weight:
- F_WSB(t) = F_s(t) + b(t) eq. 1;
- b(t) = [F_s(t) - (1/n) Σ F_i(t)] · w(t) eq. 2;
- w(t) = |1 - |t_i - h/2| / (h/2)| · w, with h = 12 and w the global weight eq. 3.
The time weight is a triangle: it starts low, peaks at the midpoint of the horizon, and falls again §3.2.3. The global weight is w = 0.0833, chosen by random search over 0.0 to 1.0 §3.2.3.
Pseudocode# Weaker Separator Booster, recursive 12-step test [§3.2.3] [eq. 1-3] # Input: strong (GA-LSTM); weak (GA-RF, GA-SVR, GA-XGBoost) # Input: x_test (one row per future month), H = 12, w = 0.0833 # Output: H boosted forecasts def wsb_forecast(strong, weak, x_test, H, w): history = recent_observed_consumption forecasts = [] for step in range(H): # Lags 1..12 come from history, including earlier WSB forecasts # [code: Results - Palmas 12m.ipynb#L1808-L1816] features = build_features(x_test[step], history) # Predictions stay unrounded floats # [code: Results - Palmas 12m.ipynb#L1819-L1824] f_strong = strong.predict(features) f_weak = [m.predict(features) for m in weak] # Mean of the weaker forecasts [eq. 2] weak_mean = sum(f_weak) / len(f_weak) # Triangular time weight: zero at step 0, peak at step H/2 # [eq. 3] [code: Results - Palmas 12m.ipynb#L1808] w_t = abs(1 - abs(step - H / 2) / (H / 2)) * w # Push the strong forecast away from the weak mean [eq. 2] booster = (f_strong - weak_mean) * w_t # Boosted forecast [eq. 1] forecast = f_strong + booster forecasts.append(forecast) history.append(forecast) return forecasts -
Metrics eq. 4 eq. 5. MAE = mean |y - ŷ|. sMAPE = mean |y - ŷ| / ((|y| + |ŷ|) / 2). The paper uses sMAPE because MAPE is biased towards lower forecasts §3.2.3.
Hyperparameters
Selected values are the paper's. The released code uses the same search spaces except where noted in Paper vs code.
| Name | Value | Where | Notes |
|---|---|---|---|
| LSTM units | 115 | tab. 6 | search 1-300 |
| LSTM epochs | 98 | tab. 6 | search 1-100 |
| LSTM batch size | 117 | tab. 6 | search 1-300 |
| LSTM activation | tanh | tab. 6 | search: linear, mish, sigmoid, softmax, softplus, softsign, tanh |
| LSTM bias | True | tab. 6 | search: True, False |
| RF n_estimators | 13 | tab. 7 | search 10-300 |
| RF max_depth | 281 | tab. 7 | search 10-300 |
| RF min_samples_split | 13 | tab. 7 | search 2-50 |
| RF min_samples_leaf | 2 | tab. 7 | search 1-50 |
| SVR C | 1465.0 | tab. 8 | search 0.00001-20,000 |
| SVR epsilon | 1.0 | tab. 8 | search 0.001-1.0 |
| SVR kernel | sigmoid | tab. 8 | search: poly, rbf, sigmoid |
| XGBoost n_estimators | 25 | tab. 9 | search 1-300 |
| XGBoost max_depth | 82 | tab. 9 | search 1-300 |
| XGBoost booster | gbtree | tab. 9 | search: gbtree, gblinear, dart |
| XGBoost lambda (L2) | 0.151538 | tab. 9 | search 0-100 |
| XGBoost alpha (L1) | 97.963749 | tab. 9 | search 0-100 |
| CNN filters | 298 | tab. 10 | search 1-300 |
| CNN dense units | 276 | tab. 10 | search 1-500 (code: 1-300) |
| CNN epochs | 96 | tab. 10 | search 1-100 |
| CNN activation | softplus | tab. 10 | search: linear, mish, sigmoid, softmax, softplus, softsign, tanh |
| ESN reservoir size | 386 | tab. 11 | search 2-1000 |
| ESN sparsity | 0.30 | tab. 11 | search 0.1-0.5 |
| ESN spectral radius | 0.54 | tab. 11 | search 0.1-0.9 (code: 0.1-1.9) |
| ESN noise | 0.60 | tab. 11 | search 0.0001-0.8 |
| GA mutation rate | 0.5 | tab. 12 | custom GA |
| GA offspring per generation | 30 | tab. 12 | 25 generations, 750 evaluations |
| PSO cognitive / social / inertia | 0.5 / 0.3 / 0.9 | tab. 12 | 30 particles, 25 iterations, 750 evaluations |
| Objective | mean MAE, 5-fold CV | §3.2.2 | each evaluation is one 5-fold fit |
| WSB global weight w | 0.0833 | §3.2.3 | random search over 0.0-1.0 |
| WSB horizon h | 12 | eq. 3 | 12 months |
| WSB weaker models n | 3 | eq. 2 | GA-RF, GA-SVR, GA-XGBoost |
| Runs | 3 seeds | §3.2.2 | each optimiser |
Results
Author-reported. Setup: Palmas (dataset 1) and Coronel Vivida (dataset 2); the test is the 12 months of 2023 (January to December), forecast recursively §4.1 fig. 10 fig. 11. Baselines are the statistical methods and GA-CNN and GA-ESN tab. 14 tab. 15. Experiments ran in Python 3.11.9 on an Acer Nitro 5 laptop with an Intel Core i5-9300H (2.40 GHz), 16 GB RAM and an NVIDIA GeForce GTX 1650. The libraries are pandas, numpy, statsmodels, pmdarima, pyESN, scikit-learn, TensorFlow, Keras, XGBoost, cuML, shap and pyswarms. Run time is not reported §4.
Cross-validation on the training data tab. 13, MAE in kWh:
| Model | Dataset 1 MAE | Dataset 1 median | Dataset 1 SD | Dataset 2 MAE | Dataset 2 median | Dataset 2 SD |
|---|---|---|---|---|---|---|
| GA-LSTM | 3930.20 | 2691.00 | 2329.94 | 492.60 | 451.00 | 380.82 |
| GA-RF | 1052.60 | 634.00 | 971.01 | 464.00 | 640.00 | 304.82 |
| GA-SVR | 758.80 | 941.00 | 242.42 | 1458.80 | 1528.00 | 400.53 |
| GA-XGBoost | 1879.20 | 2027.00 | 870.95 | 441.20 | 507.00 | 224.71 |
The test results, with the WSB row as the proposed model tab. 14 tab. 15:
| Model | Palmas MAE (kWh) | Palmas sMAPE (%) | Coronel MAE (kWh) | Coronel sMAPE (%) |
|---|---|---|---|---|
| WSB (GA-LSTM + booster) | 1990.87 | 13.90 | 464.93 | 18.72 |
| GA-LSTM | 2264.50 | 15.35 | 466.92 | 18.80 |
| GA-RF | 3211.33 | 21.83 | 529.00 | 21.57 |
| GA-SVR | 3247.42 | 22.12 | 752.50 | 32.68 |
| GA-XGBoost | 3760.75 | 24.45 | 567.83 | 23.36 |
| Exponential smoothing | 3207.78 | 21.82 | 771.36 | 30.42 |
| Double exponential smoothing | 4190.56 | 30.10 | 1158.58 | 41.59 |
| Holt-Winters additive | 5415.74 | 43.31 | 867.29 | 33.26 |
| Holt-Winters multiplicative | 4534.49 | 33.84 | 668.62 | 26.77 |
| ARIMA | 3322.17 | 22.65 | 774.48 | 30.47 |
| GA-CNN | 5083.75 | 39.03 | 633.16 | 25.68 |
| GA-ESN | 3951.25 | 26.30 | 681.58 | 28.62 |
The GA-ESN row for Palmas and the ESN row for Coronel disagree with the released code output. See Paper vs code.
The paper reports that all models were inaccurate around the June to September 2023 peak at Palmas, and around the January to July 2023 peak at Coronel Vivida §4.1 fig. 10 fig. 11. The SHAP analysis of GA-RF finds that the lags have the largest effects: positive at Palmas and negative at Coronel Vivida. The year-2019 dummy is negative at Palmas and positive at Coronel Vivida fig. 12 fig. 13 §4.2.
Paper vs code
The code is the authors' repository, linked from the data section of the paper §3.1. Its owner name matches the first author, whose correspondence address is in the paper's front matter. It was cloned at commit 508c4ea0ba0cea17ef202fa04bc60aa3b35f4b90 and contains notebooks, configuration CSVs and result files. It has no LICENSE file. The code was not quoted.
- Data window. Paper: the data span September 2017 to March 2024 §3.1. Code: the Palmas and Coronel notebooks keep only 2019-01-01 to 2023-12-31 before training and testing, which is 60 months, 48 of them for training Results - Palmas 12m.ipynb Results - Coronel 12m.ipynb.
- Cross-validation folds. Paper: 6-fold in §3.2, 5-fold in §3.2.3 §3.2 §3.2.3. Code: TimeSeriesSplit with 5 folds, for the evaluation and for the search objective Results - Palmas 12m.ipynb Optimization.ipynb.
- Final refits. Paper: during training each model is exposed to the full training dataset §3.2.3. Code: the cross-validation fits only produce scores; the models used for the test are refitted on the full training window with the selected hyperparameters Results - Palmas 12m.ipynb.
- CNN epochs. Paper: CNN epochs 96 tab. 10. Code: the final CNN refit hard-codes 198 epochs Results - Palmas 12m.ipynb. CNN is a baseline, not part of WSB.
- CNN dense range. Paper: 1-500 tab. 10. Code: randint(1, 300) Optimization.ipynb.
- ESN spectral radius range. Paper: 0.1-0.9 tab. 11. Code: uniform(0.1, 1.9) Optimization.ipynb. The selected 0.54 lies in both ranges.
- Baseline rounding. Single-model forecasts are truncated to integers in the test loop Results - Palmas 12m.ipynb. The WSB inputs (the GA-LSTM, RF, SVR and XGBoost forecasts) are not truncated Results - Palmas 12m.ipynb. The paper does not mention this difference, so the baselines and WSB are not rounded alike.
- Booster. Equations 1 to 3 match the code, with H = 12 Results - Palmas 12m.ipynb and W = 0.0833 Results - Palmas 12m.ipynb. The step counter starts at 0 Results - Palmas 12m.ipynb. The paper does not state the index base.
- Palmas GA-ESN. Paper: MAE 3951.25, sMAPE 26.30 tab. 14. The saved output in the repository: MAE 3829.25, sMAPE 25.57 Measures.csv. The other Palmas rows match to two decimals.
- Coronel WSB. Paper: MAE 464.93 in Table 15, and 465.02 in the abstract. The saved output: MAE 465.019 Measures.csv. The abstract figure matches the saved output.
- Coronel ESN. Paper: MAE 681.58, sMAPE 28.62 tab. 15. The saved output: MAE 529.5, sMAPE 21.92 Measures.csv. The other Coronel rows match to two decimals.
- Text errors. §4.1 gives GA-RF's Palmas cross-validation MAE as 758.80, but Table 13 gives 1052.60; 758.80 is GA-SVR's value §4.1 tab. 13. §5 gives GA-LSTM's Coronel MAE as 771.36, which is the exponential smoothing value in Table 15 §5 tab. 15.
- Booster weight. Paper: random search gave w = 0.0833 §3.2.3. Code: the value is hard-coded, and no random-search code was found in the repository Results - Palmas 12m.ipynb.
- PSO settings. Paper: c1 0.5, c2 0.3, w 0.9 tab. 12. Code: the same values Optimization.ipynb. The report log also records earlier runs with c2 0.5 and w 0.5 report.log. The paper does not say which run produced Table 12.
- Feature pruning data. Paper: pruning ranks predictors by SHAP on Palmas §3.2.1. Code: the RF and XGBoost models used for SHAP are fitted on the full preprocessed Palmas frame, with no date filter before that cell DataPreparation - Palmas.ipynb.
Pitfalls
- One test year per campus. Each campus has a single 12-month test window, 2023. The paper itself says an unforeseen event may explain the missed peak §4.1. The results are not shown to hold in other years.
- Recursive error growth. Errors accumulate over the horizon, and the forecast is fed back into the lags §4.1. WSB feeds its own boosted forecasts back as lags Results - Palmas 12m.ipynb. The paper proposes shorter horizons as future work §5.
- The booster is zero at the first step. With the 0-based step index used in the code, w(t) is 0 at step 0 and peaks at step 6 (the seventh month) Results - Palmas 12m.ipynb eq. 3. An implementation with a 1-based index would give a different booster profile.
- Shared lag history. In the WSB loop, the strong and weak models all use lags built from the WSB history, not from their own forecasts Results - Palmas 12m.ipynb. The GA baselines use their own history Results - Palmas 12m.ipynb. The paper does not describe this, so the comparison is between two different recursive setups.
- Metric scale. Eq. 5 has no factor of 100, but the reported sMAPE is in percent. The code multiplies by 100 and rounds to two decimals Results - Palmas 12m.ipynb.
- Feature pruning leakage. The SHAP and pruning step is fitted on the whole Palmas frame, including the 2023 test year DataPreparation - Palmas.ipynb. The paper does not say which rows were used to score the pruning curve §3.2.1.
- Ambiguous pruning cap. The text says the elimination was "capped at 40 features" §3.2.1. It is not clear whether 40 is the number removed or the number kept. The curve runs from 0 to 40 features removed fig. 7.
- Mann-Kendall table. Table 3 reports statistics of 0.0024 (dataset 1) and 0.4067 (dataset 2) against a critical value of 0.05, and the text concludes "no trend" and "trend". If those statistics are p-values, the conclusions are reversed at the 0.05 level tab. 3 §3.1.
- Abstract timespan. The abstract says "the last seven years" of data, while §3.1 gives 79 months [abstract] §3.1.
- Cost of the search. Each objective evaluation is a 5-fold fit, so the 750 evaluations per optimiser per model are 3750 model fits per seed (derived from tab. 12 and §3.2.2). Run time is not reported.
- Weight search not released. The random search over w that picked 0.0833 is not in the repository. The paper says larger values overshoot and smaller values have little effect §3.2.3.
Lineage
- Builds on: the authors' earlier cooperative ensemble work, cited in §1 as references 8 to 10 §1. Those references are not identified by arXiv id on this card.
- Compared against: exponential smoothing, double exponential smoothing, Holt-Winters (additive and multiplicative), ARIMA, GA-CNN and GA-ESN tab. 14 tab. 15. Table 1 reviews related electricity-forecasting studies without comparing their numbers tab. 1.
- Superseded by: not known from this wiki.
Source and license
Adapted from “Electricity Consumption Forecasting: An Approach Using Cooperative Ensemble Learning with SHapley Additive exPlanations” by Eduardo Luiz Alba, Gilson Adamczuk Oliveira, Matheus Henrique Dal Molin Ribeiro, Érick Oliveira Rodrigues (arXiv:2605.25305), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/eduardoalba0/ifpr_electricity_ml at commit 508c4ea0ba0c (not stated (no LICENSE file in repository)). Any quoted code is shown under that license.