Abnormal point elimination method and device for fuel cell data, and storage medium
Through the improved KNN algorithm and ant colony algorithm, the outlier elimination and fitting of fuel cell data are optimized, which solves the problems of rough threshold setting and inaccurate model fitting in the existing technology, and improves the accuracy of fuel cell data processing. and depth of performance analysis.
Patent Information
- Application Number
- CN202410535050.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-04-30
AI Technical Summary
In fuel cell data preprocessing, the existing technology eliminates outliers based on fixed thresholds, which may ignore the potential information of the data, affecting the accuracy of polarization curve fitting and the reliability of the model, and the least squares algorithm is difficult to deal with complex nonlinearities. The data is faced with the problem of model overfitting or underfitting.
The improved KNN algorithm is used to calculate the z-score of the data points, combined with the ant colony algorithm to calculate the fitness function value, the hyperparameters K and σ are optimized through grid search, outliers are eliminated, and the ant colony algorithm is used in the least squares fitting to obtain The parameters are scaled to improve the fitting effect.
It achieves the accurate elimination of abnormal points in fuel cell data, improves the accuracy and reliability of polarization curve fitting, and enhances the accuracy and depth of fuel cell performance analysis.
Smart Images

Figure CN118535854A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fuel cell data processing, and in particular to a method, device and storage medium for removing abnormal points from fuel cell data. Background Art
[0002] At present, the raw data of fuel cell experiments need to be preprocessed to remove outliers caused by various factors. The current common practice is to set fixed thresholds and regard data points exceeding these thresholds as outliers, and remove them directly from the data set. This processing method is simple and direct, but it is crude and may ignore the potential information in the data, thus affecting the accuracy and reliability of subsequent polarization curve fitting and various data-based models.
[0003] In order to further understand the performance decay of fuel cell stacks over time, it is necessary to perform curve fitting on the original data based on the polarization curve fitting formula of the fuel cell, with time as the segmentation standard, and extract multiple polarization curves that can represent the performance of the fuel cell. Most existing methods directly use the least squares algorithm for fitting.
[0004] The preprocessing step of fuel cell data is dedicated to removing outliers in the original data set. These outliers are often caused by various unpredictable factors, such as equipment errors, environmental interference, etc. The current common practice is to set fixed thresholds, and treat data points that exceed these thresholds as outliers, and remove them directly from the data set. This processing method is simple and direct, but it is inevitably rough and may ignore the potential information in the data, thereby affecting the accuracy and reliability of subsequent polarization curve fitting and various data-based models.
[0005] The polarization curve of a fuel cell is an important tool for characterizing the performance of a fuel cell. At present, the least squares algorithm is commonly used to fit the polarization curve of a fuel cell. Although the least squares algorithm has advantages in fitting efficiency and universality, it still faces challenges such as model overfitting or underfitting when processing complex and nonlinear experimental data, which limits the accuracy and depth of fuel cell performance analysis.
[0006] Although current technologies provide certain solutions for data preprocessing, there is still room for improvement. How to process abnormal data more accurately and how to improve the accuracy and ease of use in the polarization curve fitting process, so as to further understand the durability of fuel cell stacks and promote convenient fuel cell fitting methods, is an important driving force for the further development of fuel cell technology. Summary of the invention
[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a method, device and storage medium for removing abnormal points of fuel cell data, so as to solve or partially solve the problem of unsatisfactory accuracy in removing abnormal data of fuel cell data.
[0008] The purpose of the present invention can be achieved by the following technical solutions:
[0009] One aspect of the present invention provides a method for removing abnormal points in fuel cell data, comprising the following steps:
[0010] Acquire fuel cell data including a plurality of samples, wherein each sample includes an actual voltage value and a current value of the fuel cell;
[0011] Mapping each sample in the fuel cell data to a data point in a multidimensional space, for each data point, calculating the average distance and variance between the current data point and K adjacent data points, obtaining a z score corresponding to each data point, and removing samples corresponding to data points whose z scores are greater than a threshold σ from the fuel cell data;
[0012] For each sample in the fuel cell data after elimination, based on at least one variable associated with the fuel cell voltage, a variable value is obtained by fitting, a fitness function value of the sample is calculated using an ant colony algorithm, and a fitting degree index value of the polarization curve corresponding to the sample with the highest fitness function value is calculated;
[0013] The values of hyperparameters K and σ corresponding to the maximum fit index value are obtained through grid search, and the fuel cell data after removing samples under the corresponding values are obtained to eliminate abnormal points.
[0014] As a preferred technical solution, the calculation of the z score is implemented using the following formula:
[0015]
[0016] Where Z is the z score, X, σ 1 are the average distance and variance between the current data point and K adjacent data points, respectively, and μ is the mean of the average distances of all data points.
[0017] As a preferred technical solution, the process of calculating the fitness function value of each sample using the ant colony algorithm includes:
[0018] For each sample in the fuel cell data after elimination, the voltage fitting value is calculated based on the current value and variable value of the fuel cell, the first error between the voltage fitting value and the actual voltage value is calculated, and the second error between the vector composed of the current value and the variable value and the preset standard value vector is calculated. Based on the first error and the second error, the fitness function value is weighted to obtain.
[0019] As a preferred technical solution, the second error is calculated using the following formula:
[0020] The L2 norm between the vector formed by the current value and the variable value and the standard value vector is calculated as the second error.
[0021] As a preferred technical solution, the fitting degree index value f Combine The calculation is done using the following formula:
[0022]
[0023] Among them, R 2 represents goodness of fit, and RMSE represents root mean square error.
[0024] As a preferred technical solution, the variables associated with the fuel cell voltage include open circuit voltage, Tafel slope, current density, loss current density, ohmic resistance and concentration loss parameter.
[0025] As a preferred technical solution, the polarization curve is fitted using the following formula:
[0026]
[0027] Among them, E cell 、E OCV are the output voltage and open circuit voltage respectively, b is the Tafel slope, i, i loss are current density and loss current density respectively, R is the ohmic resistance, and m and n are concentration loss parameters.
[0028] As a preferred technical solution, the process of fitting and obtaining a variable value based on at least one variable associated with the fuel cell voltage includes:
[0029] Based on the variables associated with the fuel cell voltage, preliminary fitting variable values are obtained;
[0030] The variable values obtained by the preliminary fitting are scaled and used as the upper and lower limits of the least squares method, and then fitted again to obtain the final variable values.
[0031] Another aspect of the present invention provides an electronic device, comprising: one or more processors and a memory, wherein the memory stores one or more programs, and the one or more programs include instructions for executing the above-mentioned method for eliminating abnormal points of fuel cell data.
[0032] Another aspect of the present invention provides a computer-readable storage medium comprising one or more programs for execution by one or more processors of an electronic device, wherein the one or more programs include instructions for executing the aforementioned method for removing abnormal points from fuel cell data.
[0033] Compared with the prior art, the present invention has at least one of the following beneficial effects:
[0034] (1) Effectively eliminating abnormal points in fuel cell data: Existing methods usually use a fixed threshold to eliminate abnormal points. Different from the existing methods, the present invention is based on an improved KNN algorithm, which uses the number of adjacent points K and the threshold σ as hyperparameters, and aims to maximize the fitting degree index value of the fitted polarization curve. The hyperparameters are optimized through a grid search method, thereby effectively eliminating abnormal points, thereby ensuring the accuracy and reliability of the abnormal point elimination.
[0035] (2) Taking into account the error of variable values: In order to address the possible deviation of variable values from the actual value of the variable during the fitting process, the present invention takes into account the second error between the vector composed of the current value and the variable value and the preset standard value vector when calculating the fitness function value of each sample, so that the final selection of hyperparameters is more accurate.
[0036] (3) Improve the algorithm for fitting the fuel cell polarization curve to improve the effect of outlier removal: Use the ant colony intelligent algorithm to fit the original data after the outliers are removed, and then obtain the preliminary semi-empirical model fitting parameters of the fuel cell polarization curve. In order to further give play to the fitting accuracy advantage of the least squares, the present invention scales the fitting parameters obtained by the ant colony algorithm to improve the upper and lower limits of the least squares algorithm. Then, the least squares fitting of the fuel cell polarization curve is performed to improve the fitting effect and ensure the accuracy of outlier removal. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a flow chart of a method for removing abnormal points from fuel cell data in an embodiment;
[0038] Figure 2 This is an example diagram of improving the KNN algorithm in the embodiment;
[0039] Figure 3 This is a schematic diagram of the effect of improving the KNN algorithm in the embodiment;
[0040] Figure 4 Schematic diagram of the fitting results in the examples. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0042] Example 1
[0043] In view of the problems existing in the above-mentioned prior art, this embodiment provides a method for removing abnormal points in fuel cell data, which is used to improve the quality and optimize the analysis of fuel cell data. It is mainly based on the application of two improved algorithms and a comprehensive optimization technology, aiming to accurately identify and remove abnormal points in the original data, and accurately fit the polarization curve of the fuel cell through intelligent fitting technology.
[0044] See also Figure 1 , this method mainly comprises the following steps:
[0045] Step S1, obtaining fuel cell data. The fuel cell data includes multiple pairs of actual voltage-current values of the fuel cell.
[0046] Step S2, clearing abnormal points of fuel cell raw data:
[0047] This embodiment provides an unsupervised outlier detection technology based on the KNN (K-nearest neighbor) algorithm. Select K neighboring points of each data point, and calculate the average distance between the point and the K points according to the two-point distance formula. After obtaining the average distance X of all points, calculate the mean μ and variance σ of the average distance of all points 1 , the Z-Score value (i.e., z score) is obtained according to the following formula. Then, the outliers in the original data are removed according to the set threshold σ.
[0048]
[0049] Where X, σ 1 is the average distance and standard deviation between a data point and K adjacent data points, and μ is the mean of the average distance X of all data points.
[0050] To demonstrate this step, a data set containing five points (A to E) is selected for anomaly detection. The coordinates of the points in the data set are: A: (0, 0), B: (1, 2), C: (2, 3), D (3, 2), E (5, 5). Calculate the distance between each point (A to E) and its three nearest neighbors, that is, select K = 3. Figure 2 As shown in (a), (b), and (c), the distance d 1 to d 9Respectively represent the distances between points A, B, E and their three nearest neighbors. By comparison, we can observe that point E (d 7 to d 9 The average distance of the point E is significantly different from the average distance of other points. Under appropriate threshold setting, point E can be identified as an outlier by the algorithm.
[0051] The Z-Score values of the five AE points are calculated and shown in Table 1:
[0052] Table 1 Z-Score values of each point
[0053] <![CDATA[A score ]]> <![CDATA[B score ]]> <![CDATA[C score ]]> <![CDATA[D score ]]> <![CDATA[E score ]]> 0.07 -0.74 -0.58 -0.45 1.70
[0054] According to the table above, the Z-Score value of point E is significantly greater than that of the other four points. By comparing it with the threshold σ, it can be judged as an abnormal point. The above improved KNN algorithm is applied to the fuel cell data set, and the effect diagram is as follows: Figure 3 As shown in the figure, (a) and (b), (c) and (d) are the original data from two different proton exchange membrane fuel cell vehicle durability tests. In (a) and (c), the asterisks are the outliers identified by the algorithm; (b) and (d) are the distribution of data points after removing these outliers. It can be seen that the algorithm has good universality. In addition, the principle of the algorithm is very clear, and it also includes two key optimizable hyperparameters, namely the nearest neighbor number K and the threshold σ. By properly adjusting these two hyperparameters, the most suitable algorithm results can be found according to the distribution of different data sets.
[0055] Step S3, fitting of the fuel cell polarization curve:
[0056] This step improves the traditional least squares fitting algorithm for fuel cell polarization curves. Using the ant colony algorithm, firstly based on multiple variables associated with the fuel cell voltage, the original data obtained in step S2 after removing the abnormal points are preliminarily fitted, and then the variable value Y of the preliminary fuel cell polarization curve is obtained. In order to further give play to the fitting accuracy advantage of the least squares and make up for the defect that the least squares algorithm needs to input the starting point, upper and lower limits of the fitting variable, this embodiment will scale the obtained preliminary fitting variable value Y, take Y as the starting point of the least squares, 0.8*Y as the lower limit of the least squares, and 1.2*Y as the lower limit of the least squares, and perform the least squares fitting again, thereby improving the original least squares algorithm.
[0057] In this embodiment, the variable value Y is obtained by fitting the following semi-empirical model, which can reflect the relationship between the stack voltage and the current density at the same time:
[0058]
[0059] In the formula, Ecell Represents voltage output, in volts (V); E OCV represents the open circuit voltage in volts (V); b represents the Tafel slope in V / decade; i represents the current density in amperes per square centimeter (A / cm 2 );i loss Represents the loss current density in amperes per square centimeter (A / cm 2 );R represents the ohmic resistance, the unit is Ω·cm 2 m and n are used to represent concentration loss. In this embodiment, six parameters, namely, open circuit voltage, Tafel slope, loss current density, ohmic resistance, and concentration loss parameter (m and n), are selected as variables affecting the output voltage.
[0060] The ant colony algorithm of this embodiment is used to calculate the adaptive function value of each sample, and the fitness function can find the optimal fitting variable value Y. The construction of the fitness function consists of two parts. First, construct a data error term to evaluate the individual attribute value of the ant colony. Substitute the six parameters of the ant colony algorithm into the calculation, input the current density term of the original data, and output the voltage fitting value. Then calculate the error between the fitting value and the actual voltage value.
[0061] Secondly, in order to prevent the fitted variable values from deviating from the actual meaning, this paper adds a physical meaning error term to the fitness function. The specific method is to give the recommended value of the data based on the work of previous scholars, form a recommended vector, and calculate the L2 norm of the recommended vector and the variable parameter value. Finally, this norm is weighted with the above error.
[0062] against Figure 3 The data given in the figure are fitted using the above algorithm and the variable values are as follows: Figure 4 The fitting accuracy is shown in Table 2.
[0063] Table 2 Fitting accuracy results
[0064] Group / Parameter <![CDATA[Goodness of fit R 2 > Root mean square error RMSE Fitting result diagram 1 0.9832 0.0139 Fitting result diagram 2 0.9943 0.0062
[0065] Step S4, fuel cell pretreatment comprehensive optimization technology:
[0066] Ideally, the result of the curve fitting is expected to have a high R 2 and low RMSE. For the polarization curve fitting of the fuel cell, this embodiment comprehensively considers these two indicators. The specific objective function of this embodiment is shown as follows:
[0067]
[0068] In this step, the fitting score of the fitting curve in step S3 is calculated by the above objective function. And the number of neighborhood points K and the threshold σ selected in step S2 are optimized by the grid search method to obtain the optimized raw data of outlier removal and achieve outlier removal.
[0069] In order to quantify the effect of removing outliers, this embodiment uses a modified least squares algorithm to further fit the polarization curves of the data set after removing outliers. 2 The two dimensions of K and RMSE are used to judge which group of parameters are more consistent with the law of fuel cell polarization curve after elimination, so as to further improve the accuracy of preprocessing. In order to facilitate data display, only the group results of K = 3, 5, 10; σ = 1, 3 are selected for display. The result values are shown in Table 3 below:
[0070] Table 3 Results of improved KNN algorithm with different parameters
[0071] Parameter / Group 1 2 3 4 5 6 K 3 3 5 5 10 10 σ 3 1 3 1 3 1 <![CDATA[R 2 ]]> 0.9832 0.9853 0.9825 0.9854 0.9857 0.9864 RMSE 0.0139 0.0130 0.0142 0.0130 0.0128 0.0125 <![CDATA[f Combine ]]> 0.9778 0.9798 0.9772 0.9798 0.9801 0.9808
[0072] The parameter K in the table represents the number of neighboring points used in the improved KNN algorithm, and σ represents the threshold in the anomaly detection algorithm. 2 and RMSE represent the goodness of fit and root mean square error of the fitting curve obtained by the polarization curve fitting method with the original data after using specific K and σ parameters. Combine is the calculated index, a larger value means a better R 2 and RMSE performance, thus reflecting a better fitting effect. Therefore, according to the results in Table 3, the sixth group of parameters should be selected as the final setting for model optimization, and the corresponding outlier removal results and polarization curve fitting results should be output.
[0073] On the one hand, this method improves the accuracy of outlier detection and data fitting. On the other hand, through a comprehensive optimization method, it effectively improves the overall performance of fuel cell data processing and analysis, and has extremely high application potential in the field of fuel cell data processing.
[0074] Example 2
[0075] This embodiment provides an electronic device, including: one or more processors and a memory, wherein the memory stores one or more programs, and the one or more programs include instructions for executing the method for eliminating abnormal points of fuel cell data as described in Example 1.
[0076] Example 3
[0077] This embodiment provides a computer-readable storage medium, including one or more programs for execution by one or more processors of an electronic device, wherein the one or more programs include instructions for executing the method for eliminating abnormal points in fuel cell data as described in Example 1.
[0078] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for eliminating abnormal points in fuel cell data, characterized in that: The steps include: Acquire fuel cell data including a plurality of samples, wherein each sample includes an actual voltage value and a current value of the fuel cell; Mapping each sample in the fuel cell data to a data point in a multidimensional space, for each data point, calculating the average distance and variance between the current data point and K adjacent data points, obtaining a z score corresponding to each data point, and removing samples corresponding to data points whose z scores are greater than a threshold σ from the fuel cell data; For each sample in the fuel cell data after elimination, based on at least one variable associated with the fuel cell voltage, a variable value is obtained by fitting, a fitness function value of the sample is calculated using an ant colony algorithm, and a fitting degree index value of the polarization curve corresponding to the sample with the highest fitness function value is calculated; The values of hyperparameters K and σ corresponding to the maximum fit index value are obtained through grid search, and the fuel cell data after removing samples under the corresponding values are obtained to eliminate abnormal points.
2. The method for eliminating abnormal points in fuel cell data according to claim 1, characterized in that: The z-score is calculated using the following formula: Among them, Z is the z score, X and σ1 are the average distance and variance between the current data point and K adjacent data points, and μ is the mean of the average distances of all data points.
3. The method for eliminating abnormal points in fuel cell data according to claim 1, characterized in that: The process of calculating the fitness function value of each sample using the ant colony algorithm includes: For each sample in the fuel cell data after elimination, the voltage fitting value is calculated based on the current value and variable value of the fuel cell, the first error between the voltage fitting value and the actual voltage value is calculated, and the second error between the vector composed of the current value and the variable value and the preset standard value vector is calculated. Based on the first error and the second error, the fitness function value is weighted to obtain.
4. The method for eliminating abnormal points in fuel cell data according to claim 3, characterized in that: The second error is calculated using the following formula: The L2 norm between the vector formed by the current value and the variable value and the standard value vector is calculated as the second error.
5. The method for eliminating abnormal points in fuel cell data according to claim 1, characterized in that: The fitting degree index value f Combine The calculation is done using the following formula: Among them, R 2 represents goodness of fit, and RMSE represents root mean square error.
6. The method for eliminating abnormal points in fuel cell data according to claim 1, characterized in that: The variables associated with the fuel cell voltage include open circuit voltage, Tafel slope, current density, loss current density, ohmic resistance and concentration loss parameter.
7. The method for eliminating abnormal points in fuel cell data according to claim 6, characterized in that: The polarization curve is fitted using the following formula: Among them, E cell 、E OCV are the output voltage and open circuit voltage respectively, b is the Tafel slope, i, i loss are current density and loss current density respectively, R is the ohmic resistance, and m and n are concentration loss parameters.
8. The method for eliminating abnormal points in fuel cell data according to claim 1, characterized in that: The process of fitting and obtaining a variable value based on at least one variable associated with the fuel cell voltage includes: Based on the variables associated with the fuel cell voltage, preliminary fitting variable values are obtained; The variable values obtained by the preliminary fitting are scaled and used as the upper and lower limits of the least squares method, and then fitted again to obtain the final variable values.
9. An electronic device, characterized in that: include: One or more processors and a memory, wherein the memory stores one or more programs, and the one or more programs include instructions for executing the method for eliminating abnormal points of fuel cell data as claimed in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that: The method comprises one or more programs executed by one or more processors of an electronic device, wherein the one or more programs comprise instructions for executing the method for removing abnormal points from fuel cell data as claimed in any one of claims 1 to 8.
Citation Information
Patent Citations
Outlier detection-based real-time anti-power-theft monitoring method for power utilization information acquisition system
CN106373025A
DBA-DTW-KNN-based mechanical ventilation man-machine desynchrony rapid identification method
CN111738305A
Battery anomaly detection method and system
CN116577657A
Cited By
Floating platform tide gauge method based on offshore GNSS data
CN119807956A
A method for tide measurement using a floating platform based on offshore GNSS data
CN119807956B
Lead-acid battery health assessment method and system based on simulated working condition
CN121324970A
