Electric energy meter battery life prediction method for optimizing XGBoost through improved firefly algorithm

By improving the Firefly algorithm to optimize XGBoost, a battery life prediction model was trained, which solved the problem of frequent replacement of aging batteries in electricity meters, achieved accurate prediction of battery life and improved operation and maintenance efficiency.

CN120742149APending Publication Date: 2025-10-03ANSHAN POWER SUPPLY COMPANY OF STATE GRID LIAONING ELECTRIC POWER COMPANY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510294384.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

Electricity meter batteries age and fail frequently, causing the meters to be damaged and replaced frequently, which makes users dissatisfied. In addition, the readings are lost during power-off during replacement, affecting metering and operation and maintenance efficiency.

Method used

An improved Firefly algorithm is used to optimize XGBoost. By predicting the remaining battery life and utilizing temperature, voltage, and usage frequency data, an optimal battery life prediction model is trained. This avoids replacing batteries before they fail, reducing inspection frequency and labor costs.

Benefits of technology

It achieves accurate prediction of battery life, avoids loss of readings during power outages, increases the service life and operation and maintenance efficiency of electricity meters, and reduces labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120742149A_ABST
    Figure CN120742149A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of state prediction, in particular to an electric energy meter battery life prediction method for optimizing XGBoost through an improved firefly algorithm, and the method comprises the steps: collecting the temperature T, the voltage V and the use frequency F of an electric energy meter and the service life L of a battery, carrying out the normalization processing of collected data, dividing a data set into a training set and a test set, and carrying out the prediction of the service life of the electric energy meter. The method comprises the following steps: using a minimum square error (MSE) as a target function to evaluate the performance of a model, initializing firefly algorithm parameters, iteratively optimizing XGBoost, after executing all iterations, selecting the position xbest of a firefly with the optimal fitness as an optimal hyper-parameter combination, training a final XGBoost regression model by using the optimal hyper-parameter combination, and evaluating the performance of the model on a test set. Calculating MSE (mean square error); by predicting the remaining life of the battery, the battery can be replaced before failure, the situation of loss of a power-off reading is avoided, the labor cost is reduced, and the metering, operation and maintenance efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of state prediction, and in particular to a method for predicting the battery life of an electric energy meter by improving the firefly algorithm and optimizing XGBoost. Background Art

[0002] Currently, 09-compliant electricity meters have reached their replacement cycle. Frequent internal battery aging and failure result in frequent meter damage and replacement, which not only annoys users and reduces customer satisfaction, but also hinders the business environment. Furthermore, when replacing meters, the meter display becomes inconvenient after a power outage. For energy calculation and energy recovery, reading the meter reading requires specialized equipment at the metering center, resulting in low efficiency and high labor costs. To address these issues, extend the lifespan of electricity meters, and reduce replacement frequency, electricity meter battery prediction methods have become an important technical tool. Summary of the Invention

[0003] The present invention provides an electric energy meter battery life prediction method based on an improved firefly algorithm and optimized XGBoost. By predicting the remaining battery life, the battery can be replaced before it fails, avoiding the loss of power-off readings. At the same time, the inspection frequency is reduced, labor costs are reduced, and the efficiency of metering and operation and maintenance is improved.

[0004] In order to achieve the above object, the present invention adopts the following technical solutions:

[0005] A method for predicting the battery life of an electric energy meter by improving the firefly algorithm and optimizing XGBoost includes the following steps:

[0006] S1, collect the temperature T, voltage V and usage frequency F of the electricity meter and the battery life L;

[0007] S2, normalize the data collected in S1 to form vector data;

[0008] S3. Divide the dataset into training and test sets for model training and evaluation;

[0009] S4. Use the minimum squared error (MSE) as the objective function to evaluate model performance.

[0010] S5, initialize the firefly algorithm parameters;

[0011] S6. Iteratively optimize XGBoost;

[0012] S6.1. Update light intensity: β0(t) = β0(t-1) × forgetting factor (1)

[0013] Where β0 is the initial light intensity of each firefly, β0(t) is the initial light intensity at the tth iteration, t is the time step, and forgettingfactor is the forgetting factor;

[0014] S6.2, Fitness Assessment:

[0015] For each firefly i, use the hyperparameter combination,

[0016] (C i ,γ XGBoost ,i,α i ,λ i ,max_depth i ,n_estimators i ,learning_rate i ), evaluate the performance of the model on the test set, calculate the MSE and evaluate the fitness f(x i ); among them, C i is the regularization parameter of the i-th firefly in the XGBoost model, which is used to control the complexity of the model and prevent overfitting; XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; i is the index of the firefly, indicating the i-th firefly, and each firefly represents a different set of hyperparameter combinations; α i is the L1 regularization coefficient of the i-th firefly in the XGBoost model; i is the L2 regularization coefficient of the i-th firefly in the XGBoost model; max_depth i is the maximum depth of a single tree for the i-th firefly in the XGBoost model; n_estimators i is the number of firefly trees in the XGBoost model; learning_rate i is the learning rate of the i-th firefly in the XGBoost model;

[0017] S6.3. Calculate light intensity: For each pair of fireflies i and j,

[0018] r ij =||x i (t)-x j (t)|| (2)

[0019]

[0020] Among them, r ij is the position vector of the i-th and j-th firefly in the t-th iteration, x i(t) is the position of the i-th firefly in the t-th iteration, x j (t) is the position of the j-th firefly in the t-th iteration, I i (t) is the light intensity of the i-th firefly in the t-th iteration, γ is the light intensity attenuation coefficient;

[0021] S6.4, Position Update: For each firefly i, find all fireflies j that are brighter than i and update the position x i (t+1),

[0022]

[0023] Where β is the proportional attraction coefficient, I j (t) is the light intensity of the j-th firefly in the t-th iteration, Represents a random disturbance term with a mean of 0 and a variance of σ 2 A normally distributed random variable, σ is the random step parameter;

[0024] S6.5. Adjust hyperparameters: Based on the new position x i (t+1) Adjust the hyperparameters to ensure that they are within the set range;

[0025] S6.6. Keep the optimal position: If the new position x i The fitness of (t+1) is better than the old position x i (t), then the new position is retained;

[0026] S7. After all iterations are completed, the position x of the firefly with the best fitness is selected. best As the optimal hyperparameter combination;

[0027] S8. Use the optimal hyperparameter combination to train the final XGBoost regression model, evaluate the model's performance on the test set, calculate the Mean Sequential Estimation (MSE), input the current temperature T, voltage V, and usage frequency F of the electricity meter into the evaluation model, and output the battery life L.

[0028] Furthermore, the normalization process in step S2 adopts a minimum-maximum scaling normalization method, which is as follows:

[0029] Normalization of the temperature T of the energy meter:

[0030] Normalization processing of the electric energy meter voltage V:

[0031] Normalization processing of the energy meter usage frequency F:

[0032] Normalization of battery life L:

[0033] Among them, max(T) is the maximum value of the electricity meter temperature T, min(T) is the minimum value of the electricity meter temperature T, max(V) is the maximum value of the electricity meter voltage V, min(V) is the minimum value of the electricity meter voltage V, max(F) is the maximum value of the electricity meter operating frequency F, min(F) is the minimum value of the electricity meter operating frequency F, max(L) is the maximum value of the battery service life L, and min(L) is the minimum value of the battery service life L.

[0034] Furthermore, the minimum square error (MSE) is used as the objective function to evaluate the model performance:

[0035]

[0036] Among them, L' i is the true value of the i-th sample, i.e., the actual battery life; is the predicted value of the i-th sample, that is, the battery life predicted by the model; n is the total number of samples.

[0037] Furthermore, the initialization of the firefly algorithm parameters includes:

[0038] Set the number of fireflies N;

[0039] Initialize the position x of each firefly i represents the hyperparameter combination (C,γ XGBoost ,α,λ,max_depth,n_estimators,learning rate );

[0040] Where C is the regularization parameter in the XGBoost model; γ XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; α is the L1 regularization coefficient in the XGBoost model; λ is the L2 regularization coefficient in the XGBoost model; max_depth is the maximum depth of a single tree in the XGBoost model; n_estimators is the number of trees in the XGBoost model; learning rate is the learning rate in the XGBoost model;

[0041] Initialize the initial light intensity I of each firefly i =β0;

[0042] Set to proportional attraction coefficient β;

[0043] Set the light intensity attenuation coefficient γ;

[0044] Set the random step size parameter σ;

[0045] Set the forgetting factor.

[0046] Compared with the prior art, the present invention has the following beneficial effects:

[0047] Based on the traditional firefly algorithm, the forgetting factor is introduced to optimize XGBoost and train the optimal XGBoost-based electricity meter battery life prediction model. By inputting the current temperature T, voltage V, and usage frequency F of the electricity meter, the battery life L can be output. By predicting the remaining battery life, the battery can be replaced before it fails, avoiding the loss of power-off readings. At the same time, the inspection frequency is reduced, labor costs are reduced, and the efficiency of metering and operation and maintenance is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0049] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings:

[0050] See Figure 1 , is a flow chart of the method of the present invention. The present invention provides an electric energy meter battery life prediction method using an improved firefly algorithm and optimized XGBoost, comprising the following steps:

[0051] S1. Data preparation: Collect the temperature T, voltage V, usage frequency F of the electricity meter and the battery life L.

[0052] S2. Data preprocessing: Normalize the collected data. After normalization, the data is converted into vector form. Different features usually have different units and ranges. For example, the value of one feature may be between 0 and 100, while the value of another feature may be between 0 and 1. If these features are not normalized, the influence of some features may be amplified, while the influence of other features may be ignored. Through normalization, these dimensional differences can be eliminated to ensure that each feature has similar importance. Normalization can speed up the convergence of the model. Because the value ranges of different features are similar, the model is more likely to find the global minimum when updating the weights. The present invention uses Min-Max Scaling to normalize the data:

[0053] Normalization of the temperature T of the energy meter:

[0054] Normalization processing of the electric energy meter voltage V:

[0055] Normalization processing of the energy meter usage frequency F:

[0056] Normalization of battery life L:

[0057] S3. Data splitting: Divide the dataset into training and test sets for model training and evaluation.

[0058] S4. Define the objective function: Use the minimum square error (MSE) as the objective function to evaluate the model performance.

[0059]

[0060] Among them, L' i is the true value of the i-th sample, i.e., the actual battery life; is the predicted value of the i-th sample, that is, the battery life predicted by the model; n is the total number of samples.

[0061] S5. Initialize the firefly algorithm parameters:

[0062] Set the number of fireflies N;

[0063] Initialize the position x of each firefly i represents the hyperparameter combination (C,γ XGBoost ,α,λ,max_depth,n_estimators,learning rate ), where C is the regularization parameter in the XGBoost model, which is used to control the complexity of the model and prevent overfitting; γ XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; α is the L1 regularization coefficient in the XGBoost model; λ is the L2 regularization coefficient in the XGBoost model; max_depth is the maximum depth of a single tree in the XGBoost model; n_estimators is the number of trees in the XGBoost model; learning rate is the learning rate in the XGBoost model;

[0064] Initialize the initial light intensity I of each firefly i =β0;

[0065] Set to proportional attraction coefficient β;

[0066] Set the light intensity attenuation coefficient γ;

[0067] Set the random step size parameter σ;

[0068] Set the forgetting factor.

[0069] S6. Iterative optimization process:

[0070] The Firefly Algorithm is a heuristic optimization algorithm that simulates the luminescence behavior of fireflies. It is mainly used to solve complex optimization problems. The Firefly Algorithm with Forgetting Factor (FA-FF) introduces a forgetting factor on the basis of the traditional Firefly Algorithm to improve the algorithm's search efficiency and avoid falling into local optimal solutions.

[0071] (1) Main formula:

[0072]

[0073] Among them, I i is the light intensity of the i-th firefly, γ is the light intensity attenuation coefficient, and β0 is the initial light intensity for each firefly;

[0074] (2) Forgetting factor update formula:

[0075] β0(t)=β0(y-1)×forgetting factor (16)

[0076] Where: β0(y) is the initial light intensity at iteration t;

[0077] (3) Distance calculation formula:

[0078] r ij =||x i (y)-x j (t)|| (17)

[0079] Where: ||x i (t)-x j (y)|| is the position vector of the i-th and j-th fireflies in the t-th iteration;

[0080] (4) Position update formula:

[0081]

[0082] Where: x i (t) is the position of the i-th firefly in the t-th iteration, β is the proportional attraction coefficient, I j (t) is the light intensity of the jth firefly in the tth iteration;

[0083] (5) Fitness evaluation:

[0084] The fitness is usually the mean square error MSE, which is inversely proportional to the light intensity;

[0085] XGBoost regression algorithm: XGBoost is an efficient gradient boosting algorithm that is particularly suitable for large-scale machine learning problems. It improves the accuracy and efficiency of predictions by building multiple decision trees and integrating them.

[0086] (1) Loss function:

[0087]

[0088] Where: y i is the true value of the i-th sample; Ω(T k ) is a tree (T k ), including the number of leaf nodes and the weight of each leaf node;

[0089] (2) Complexity penalty:

[0090] Ω(T k )=γT k (20)

[0091]

[0092] Where: T k It is a tree (T k ) is the number of leaf nodes, α is the L2 regularization coefficient; w is the tree (T k )’s weight vector of all leaf nodes;

[0093] The iteration of optimizing XGBoost using FA-FF in the present invention includes the following steps:

[0094] S6.1. Update light intensity: β0(t) = β0(t-1) × forgettingfactor (22)

[0095] Where β0 is the initial light intensity of each firefly, β0(t) is the initial light intensity at the tth iteration, t is the time step, and forgettingfactor is the forgetting factor;

[0096] S6.2, Fitness Assessment:

[0097] For each firefly i, use the hyperparameter combination,

[0098] (C i ,γ XGBoost ,i,α i ,λ i ,max_depth i ,n_estimators i ,learning_rate i), evaluate the performance of the model on the test set, calculate the MSE and evaluate the fitness f(x i ); among them, C i is the regularization parameter of the i-th firefly in the XGBoost model, which is used to control the complexity of the model and prevent overfitting; XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; i is the index of the firefly, indicating the i-th firefly, and each firefly represents a different set of hyperparameter combinations; α i is the L1 regularization coefficient of the i-th firefly in the XGBoost model; i is the L2 regularization coefficient of the i-th firefly in the XGBoost model; msx_depth i is the maximum depth of a single tree for the i-th firefly in the XGBoost model; n_rstimators i is the number of firefly trees in the XGBoost model; learning_rate i is the learning rate of the i-th firefly in the XGBoost model;

[0099] S6.3. Calculate light intensity: For each pair of fireflies i and j,

[0100] r ij =||x i (t)-x j (t)|| (23)

[0101]

[0102] Among them, r ij is the position vector of the i-th and j-th firefly in the t-th iteration, x i (t) is the position of the i-th firefly in the t-th iteration, x j (t) is the position of the j-th firefly in the t-th iteration, I i (t) is the light intensity of the i-th firefly in the t-th iteration, γ is the light intensity attenuation coefficient;

[0103] S6.4, Position Update: For each firefly i, find all fireflies j that are brighter than i and update the position x i (t+1),

[0104]

[0105] Where β is the proportional attraction coefficient, I j (t) is the light intensity of the j-th firefly in the t-th iteration, Represents a random perturbation term, which helps the algorithm to escape from the local optimal solution and increase the global search capability. Specifically, it is a term with a mean of 0 and a variance of σ 2 A normally distributed (Gaussian distributed) random variable, σ is the random step parameter;

[0106] S6.5. Adjust hyperparameters: Based on the new position x i (t+1) Adjust the hyperparameters to ensure that they are within the set range;

[0107] S6.6. Keep the optimal position: If the new position x i The fitness of (t+1) is better than the old position x i (t), the new position is retained.

[0108] S7. After all iterations are completed, the position x of the firefly with the best fitness is selected. best As the optimal hyperparameter combination (C best ,γ XGBoost ,i,α best ,λ best ,max_depth best ,n_estimators best ,learning_rate best ), C best is the regularization parameter of the firefly with the best fitness in the XGBoost model, which is used to control the complexity of the model and prevent overfitting; best is the L1 regularization coefficient of the firefly with the best fitness in the XGBoost model; best is the L2 regularization coefficient of the firefly with the best fitness in the XGBoost model; max_depth best is the maximum depth of a single Firefly tree with the best fitness in the XGBoost model; n_estimators best is the number of firefly trees with the best fitness in the XGBoost model; learning_rate best is the learning rate of the firefly with the best fitness in the XGBoost model; these parameters together constitute the optimal hyperparameter combination of the XGBoost model, which is used to train the final battery life prediction model.

[0109] S8. Use the optimal hyperparameter combination,

[0110] That is (C best ,γ XGBoost ,i,α best ,λ best ,max_depth best ,n_estimators best,learning_rate bes ) Train the final XGBoost regression model and evaluate the performance of the model on the test set, calculating the MSE.

[0111] Through the above steps, the optimal XGBoost-based electricity meter battery life prediction model is trained. By inputting the current temperature T, voltage V, and usage frequency F of the electricity meter, the battery life L can be output.

[0112] The above embodiments are implemented under the premise of the technical solution of the present invention, and detailed implementation methods and specific operation processes are given, but the protection scope of the present invention is not limited to the above embodiments. The methods used in the above embodiments are conventional methods unless otherwise specified.

Claims

1. A method for predicting the battery life of an electric energy meter by improving the firefly algorithm and optimizing XGBoost, characterized in that: The steps include: S1, collect the temperature T, voltage V and usage frequency F of the electricity meter and the battery life L; S2, normalize the data collected in S1 to form vector data; S3. Divide the dataset into training and test sets for model training and evaluation; S4. Use the minimum squared error (MSE) as the objective function to evaluate model performance. S5, initialize the firefly algorithm parameters; S6. Iteratively optimize XGBoost; S6.

1. Update light intensity: β0(t) = β0(t-1) × forgetting factor (1) Where β0 is the initial light intensity of each firefly, β0(t) is the initial light intensity at the tth iteration, t is the time step, and forgetting factor is the forgetting factor; S6.2, Fitness Assessment: For each firefly i, use the hyperparameter combination, (C i ,γ XGBoost ,i,α i ,λ i ,max_depth i ,n_estimators i ,learning_rate i ), evaluate the performance of the model on the test set, calculate the MSE and evaluate the fitness f(x i ); among them, C i is the regularization parameter of the i-th firefly in the XGBoost model, which is used to control the complexity of the model and prevent overfitting; XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; i is the index of the firefly, indicating the i-th firefly, and each firefly represents a different set of hyperparameter combinations; α i is the L1 regularization coefficient of the i-th firefly in the XGBoost model; i is the L2 regularization coefficient of the i-th firefly in the XGBoost model; max_depth i is the maximum depth of a single tree for the i-th firefly in the XGBoost model; n_estimators i is the number of firefly trees in the XGBoost model; learning_rate i is the learning rate of the i-th firefly in the XGBoost model; S6.

3. Calculate light intensity: For each pair of fireflies i and j, r ij =||x i (t)-x j (t)|| (2) Among them, r ij is the position vector of the i-th and j-th firefly in the t-th iteration, x i (t) is the position of the i-th firefly in the t-th iteration, x j (t) is the position of the j-th firefly in the t-th iteration, I i (t) is the light intensity of the i-th firefly in the t-th iteration, γ is the light intensity attenuation coefficient; S6.4, Position Update: For each firefly i, find all fireflies j that are brighter than i and update the position x i (t+1), Where β is the proportional attraction coefficient; I j (t) is the light intensity of the jth firefly in the tth iteration; Represents a random disturbance term with a mean of 0 and a variance of σ 2 A normally distributed random variable; σ is the random step parameter; S6.

5. Adjust hyperparameters: Based on the new position x i (t+1) Adjust the hyperparameters to ensure that they are within the set range; S6.

6. Keep the optimal position: If the new position x i The fitness of (t+1) is better than the old position x i (t), then the new position is retained; S7. After all iterations are completed, the position x of the firefly with the best fitness is selected. best As the optimal hyperparameter combination; S8. Use the optimal hyperparameter combination to train the final XGBoost regression model, evaluate the model's performance on the test set, calculate the Mean Sequential Estimation (MSE), input the current temperature T, voltage V, and usage frequency F of the electricity meter into the evaluation model, and output the battery life L.

2. The method for predicting the battery life of an electric energy meter using an improved firefly algorithm and optimized XGBoost according to claim 1 is characterized in that: The normalization process in step S2 adopts the minimum-maximum scaling normalization method, which is as follows: Normalization of the temperature T of the energy meter: Normalization processing of the electric energy meter voltage V: Normalization processing of the energy meter usage frequency F: Normalization of battery life L: Among them, max(T) is the maximum value of the electricity meter temperature T, min(T) is the minimum value of the electricity meter temperature T, max(V) is the maximum value of the electricity meter voltage V, min(V) is the minimum value of the electricity meter voltage V, max(F) is the maximum value of the electricity meter operating frequency F, min(F) is the minimum value of the electricity meter operating frequency F, max(L) is the maximum value of the battery service life L, and min(L) is the minimum value of the battery service life L.

3. The method for predicting the battery life of an electric energy meter using an improved firefly algorithm and optimized XGBoost according to claim 1, characterized in that: The minimum square error (MSE) is used as the objective function to evaluate the model performance: Among them, L' i is the true value of the i-th sample, i.e., the actual battery life; is the predicted value of the i-th sample, that is, the battery life predicted by the model; n is the total number of samples.

4. The method for predicting the battery life of an electric energy meter using an improved firefly algorithm and optimized XGBoost according to claim 1, characterized in that: The initialization of the firefly algorithm parameters includes: Set the number of fireflies N; Initialize the position x of each firefly i represents the hyperparameter combination (C,γ XGBoost ,α,λ,max_depth,n_estimators,learning rate ); Where C is the regularization parameter in the XGBoost model; γ XGBoost is the minimum split loss reduction value in the model, which controls the splitting of the tree. The split will only be performed when the loss reduction value after the split is greater than γ; α is the L1 regularization coefficient in the XGBoost model; λ is the L2 regularization coefficient in the XGBoost model; max_depth is the maximum depth of a single tree in the XGBoost model; n_estimators is the number of trees in the XGBoost model; learning rate is the learning rate in the XGBoost model; Initialize the initial light intensity I of each firefly i =β0; Set to proportional attraction coefficient β; Set the light intensity attenuation coefficient γ; Set the random step size parameter σ; Set the forgetting factor.