An abnormal point elimination method, device and storage medium for fuel cell data
By optimizing the outlier removal method for fuel cell data using improved KNN and ant colony algorithms, the problem of inaccurate outlier removal in existing technologies is solved, thereby improving the accuracy of polarization curve fitting and the depth of fuel cell performance analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TONGJI UNIV
- Filing Date
- 2024-04-30
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies for fuel cell data processing are not precise enough in removing outliers, which affects the accuracy and reliability of polarization curve fitting. Furthermore, the least squares algorithm suffers from overfitting or underfitting when processing complex nonlinear data.
An improved KNN algorithm combined with an ant colony algorithm is adopted. By calculating the z-score and fitness function value of data points, the hyperparameters K and σ are optimized, outliers are removed, and the fuel cell polarization curve is improved by least squares fitting. The fitting parameters are optimized by ant colony algorithm.
This improved the accuracy of outlier removal and the precision of polarization curve fitting, ensuring the reliability and accuracy of fuel cell data processing and enhancing the depth of fuel cell performance analysis.
Smart Images

Figure CN118535854B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fuel cell data processing technology, and in particular to a method, device, and storage medium for removing outliers from fuel cell data. Background Technology
[0002] Currently, raw data from fuel cell experiments requires preprocessing to remove outliers caused by various factors. The common practice is to use fixed thresholds, treating data points exceeding these thresholds as outliers and removing them directly from the dataset. While simple and direct, this approach is somewhat crude and may overlook potential information within the data, thus affecting the accuracy and reliability of subsequent polarization curve fitting and various data-based models.
[0003] To further understand the performance degradation of fuel cell stacks over time, it is necessary to perform curve fitting on the original data using the polarization curve fitting formula of the fuel cell, with time as the dividing standard, to extract multiple polarization curves that can represent the performance of the fuel cell. Existing methods mostly use the least squares algorithm directly for fitting.
[0004] The preprocessing steps for fuel cell data aim to remove outliers from the raw dataset. These outliers are often caused by various unpredictable factors, such as equipment errors and environmental interference. Currently, the common practice is to use fixed threshold settings, treating data points exceeding these thresholds as outliers and removing them directly from the dataset. This approach is simple and direct, but inevitably crude, potentially overlooking potential information within the data and thus 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 its performance. Currently, 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 overfitting or underfitting when dealing with complex and nonlinear experimental data, which limits the accuracy and depth of fuel cell performance analysis.
[0006] While current technologies offer some solutions for data preprocessing, there is still room for improvement. How to more accurately handle outlier data, and how to improve the accuracy and ease of use in polarization curve fitting processes, thereby gaining a deeper understanding of fuel cell stack durability and promoting convenient fuel cell fitting methods, are important driving forces for the further development of fuel cell technology. Summary of the Invention
[0007] The purpose of this invention is to overcome the defects of the prior art by providing a method, device, and storage medium for removing outliers from fuel cell data, so as to solve or partially solve the problem of unsatisfactory accuracy in removing outlier data from fuel cells.
[0008] The objective of this invention can be achieved through the following technical solutions:
[0009] One aspect of the present invention provides a method for removing outliers from fuel cell data, comprising the following steps:
[0010] Acquire fuel cell data including multiple samples, where each sample includes the actual voltage and current values of the fuel cell;
[0011] Each sample in the fuel cell data is mapped to a data point in a multi-dimensional space. For each data point, the average distance and variance between the current data point and its K neighboring data points are calculated to obtain the z-score corresponding to each data point. Samples corresponding to data points with z-scores greater than the threshold σ are removed from the fuel cell data.
[0012] For each sample in the removed fuel cell data, the variable value is fitted based on at least one variable related to the fuel cell voltage. The fitness function value of the sample is calculated using the ant colony algorithm. The fitting 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. The fuel cell data after removing samples under the corresponding values are obtained, thus realizing the removal of outliers.
[0014] As a preferred technical solution, the z-score is calculated using the following formula:
[0015]
[0016] Where Z is the z-score, X and σ1 are the average distance and variance between the current data point and its K neighboring data points, respectively, and μ is the mean of the average distances between 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 removed fuel cell data, a voltage fitting value is calculated based on the current value and variable values of the fuel cell. The first error between the voltage fitting value and the actual voltage value is calculated. The second error between the vector formed by the current value and variable values and the preset standard value vector is calculated. Based on the first error and the second error, a fitness function value is obtained by weighting.
[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 and used as the second error.
[0021] As a preferred technical solution, the fitting degree index value f Combine Calculate using the following formula:
[0022]
[0023] Among them, R 2 represents the goodness of fit, and RMSE represents the 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 parameters.
[0025] As a preferred technical solution, the polarization curve is fitted using the following formula:
[0026]
[0027] Among them, E cell E OCV These are the output voltage and open-circuit voltage, respectively; b is the Tafel slope; i, i loss Here, R represents the current density and the 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 the variable values 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 fitted variable values are obtained;
[0030] The initially fitted variable values are scaled down to serve as the upper and lower limits of the least squares method, and then fitted again to obtain the final variable values.
[0031] In another aspect, an electronic device is provided, comprising: one or more processors and a memory, wherein the memory stores one or more programs, the one or more programs including instructions for performing the aforementioned method for removing outliers from fuel cell data.
[0032] In another aspect, the present invention provides a computer-readable storage medium including one or more programs executable by one or more processors of an electronic device, the one or more programs including instructions for performing the aforementioned method for removing outliers from fuel cell data.
[0033] Compared with the prior art, the present invention has at least one of the following beneficial effects:
[0034] (1) Effective removal of outliers in fuel cell data: Existing methods usually use a fixed threshold to remove outliers. Unlike existing methods, this invention is based on an improved KNN algorithm, using the number of neighboring points K and the threshold σ as hyperparameters. The goal is to maximize the fitting degree index of the fitted polarization curve. The hyperparameters are optimized by grid search, thereby achieving effective removal of outliers and ensuring the accuracy and reliability of outlier removal.
[0035] (2) Taking into account the error of variable values: In view of the error that may exist in the variable values during the fitting process, the present invention takes into account the second error between the vector formed by 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) Improving the algorithm for fitting fuel cell polarization curves to enhance outlier removal: An ant colony algorithm is used to fit the original data after outlier removal, thereby obtaining preliminary semi-empirical model fitting parameters for the fuel cell polarization curve. To further leverage the fitting accuracy advantage of least squares, this invention scales the fitting parameters obtained from the ant colony algorithm, thus improving the upper and lower limits of the least squares algorithm's fitting. Then, least squares fitting of the fuel cell polarization curve is performed to improve the fitting effect and ensure the accuracy of outlier removal. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating the outlier removal method for fuel cell data in this embodiment.
[0038] Figure 2 This is an example diagram of the improved KNN algorithm in the embodiment;
[0039] Figure 3 This is a schematic diagram illustrating the effect of the improved KNN algorithm in the embodiment;
[0040] Figure 4 This is a schematic diagram of the fitting results in the example. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0042] Example 1
[0043] To address the aforementioned problems with existing technologies, this embodiment provides a method for outlier removal in fuel cell data, used for improving the quality and optimizing the analysis of fuel cell data. It primarily relies on the application of two improved algorithms and a comprehensive optimization technique, aiming to accurately identify and remove outliers from the original data, and precisely fit the polarization curve of the fuel cell using intelligent fitting technology.
[0044] See Figure 1 This method mainly includes the following steps:
[0045] Step S1: Acquire fuel cell data. The fuel cell data includes the actual voltage-current values of multiple fuel cells.
[0046] Step S2, clearing outliers from the raw fuel cell data:
[0047] This embodiment provides an unsupervised outlier detection technique based on the KNN (K-Nearest Neighbors) algorithm. K neighboring points are selected for each data point, and the average distance between the point and these K points is calculated using the two-point distance formula. After obtaining the average distance X of all points, the mean μ and variance σ1 of the average distances of all points are calculated, and the Z-Score (i.e., z-score) is obtained according to the following formula. Then, outliers in the original data are removed based on a set threshold σ.
[0048]
[0049] Where X and σ1 are the average distance and standard deviation between a data point and its K neighboring data points, respectively, and μ is the mean of the average distance X between all data points.
[0050] To demonstrate this step, we'll use a dataset containing five points (A to E) for an outlier detection example. The coordinates of the points in the dataset are: A:(0,0), B:(1,2), C:(2,3), D(3,2), E(5,5). We'll calculate the distance between each point (A to E) and its three nearest neighbors, i.e., we choose K=3. Figure 2 As shown in (a), (b), and (c), distances d1 to d9 represent the distances between points A, B, and E and their three nearest neighbors, respectively. By comparison, it can be observed that the average distance between point E (d7 to d9) and the average distances of other points is significantly different. With an appropriate threshold setting, point E can be identified as an outlier by the algorithm.
[0051] The calculated Z-Score values for the five points AE are shown in Table 1 below:
[0052] Table 1. Z-Scores for 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] As shown in the table above, the Z-Score of point E is significantly higher than that of the other four points. It can be identified as an outlier by comparing it with the threshold σ. The improved KNN algorithm is then applied to the fuel cell dataset, and the resulting graph is shown below. Figure 3 As shown, (a) and (b), (c) and (d) are raw data from two different proton exchange membrane fuel cell vehicle operating condition durability experiments. In (a) and (c), asterisks indicate outliers identified by the algorithm; (b) and (d) show the data point distribution after removing these outliers. This demonstrates the algorithm's good universality. Furthermore, the algorithm's principle is very clear, including two key optimizable hyperparameters: the nearest neighbor number K and the threshold σ. By appropriately adjusting these two hyperparameters, the most suitable algorithm result can be found based on the distribution of different datasets.
[0055] Step S3, Fitting the polarization curve of the fuel cell:
[0056] This step improves upon the traditional least-squares algorithm for fitting fuel cell polarization curves. Using an ant colony algorithm, it first performs a preliminary fitting of the original data obtained in step S2 after outlier removal, based on multiple variables related to the fuel cell voltage, thus obtaining the initial variable value Y of the fuel cell polarization curve. To further leverage the fitting accuracy advantage of least squares and address the limitation of requiring input of the starting point and upper / lower limits of the fitting variables, this embodiment scales the obtained preliminary fitting variable value Y, using Y as the starting point of the least squares fitting, 0.8*Y as the lower limit, and 1.2*Y as the lower limit, performing least-squares fitting again, thus improving upon 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 current density at the same time:
[0058]
[0059] In the formula, E cell Represents voltage output, measured in volts (V); E OCV 'b' represents open-circuit voltage, measured in volts (V); 'b' represents the Tafel slope, measured in V / decade; 'i' represents current density, measured in amperes per square centimeter (A / cm²). 2 );i loss This represents the current density of the loss, measured in amperes per square centimeter (A / cm²). 2 R represents ohmic resistance, with units of Ω·cm. 2m and n are used to represent concentration loss. In this embodiment, six parameters are selected as variables affecting the output voltage: open-circuit voltage, Tafel slope, loss current density, ohmic resistance, and concentration loss parameters (m and n).
[0060] The ant colony algorithm in this embodiment is used to calculate the adaptive function value of each sample. The fitness function can find the optimal fitted variable value Y. The construction of the fitness function consists of two parts. First, a data error term is constructed to evaluate the individual attribute values of the ant colony. The six parameters of the ant colony algorithm are substituted into the calculation, with the current density term of the original data as input, and the voltage fitted value as output. Then, the error between the fitted value and the actual voltage value is calculated.
[0061] Secondly, to prevent the fitted variable values from deviating from their actual meaning, this paper adds a physical meaning error term to the fitness function. Specifically, this is done by generating a recommendation vector based on recommended values for the data from previous work, and then calculating the L2 norm of the recommendation vector relative to the variable parameter values. Finally, this norm is weighted and summed with the aforementioned error.
[0062] against Figure 3 The data given in the figure, the results obtained by fitting using the aforementioned algorithm, and the variable values are as follows: Figure 4 As shown in (a) and (b), the fitting accuracy is shown in Table 2.
[0063] Table 2 Fitting accuracy results
[0064] Group / Parameters <![CDATA[Goodness of fit R 2 > Root Mean Square Error (RMSE) Figure 1 shows the fitting results. 0.9832 0.0139 Figure 2 shows the fitting results. 0.9943 0.0062
[0065] Step S4, Integrated optimization technology for fuel cell pretreatment:
[0066] Ideally, the fitted curve should have a high R-value. 2 And low RMSE. For the polarization curve fitting of fuel cells, this embodiment considers both indicators comprehensively. The specific objective function of this embodiment is shown in the following equation:
[0067]
[0068] In this step, the fitting score of the fitted curve in step S3 is calculated using the objective function in the above formula. Then, the number of neighborhood points K and the threshold σ selected in step S2 are optimized using a grid search method to obtain the final optimized original data for outlier removal, thus achieving outlier removal.
[0069] To quantify the effectiveness of outlier removal, this embodiment employs a modified least squares algorithm for further polarization curve fitting on the dataset after outlier removal. From R... 2The preprocessing accuracy is further improved by evaluating which set of parameters, along with RMSE, best reflects the polarization curve of the fuel cell after data removal. For ease of data presentation, only the results for groups with K = 3, 5, 10 and σ = 1, 3 are shown here. The obtained results are shown in Table 3 below:
[0070] Table 3 Results of the improved KNN algorithm under different parameters
[0071] Parameters / Groups 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] In the table, parameter K represents the number of neighboring points used in the improved KNN algorithm, and σ represents the threshold in the anomaly detection algorithm. R 2 RMSE represents the goodness of fit and root mean square error of the fitted curve obtained by polarization curve fitting method with specific K and σ parameters to the original data. Combine For the calculated index, a larger value means a better R-value. 2 The RMSE performance reflects a better fit. Therefore, based on the results in Table 3, the sixth set 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] This method improves the accuracy of outlier detection and data fitting, and through comprehensive optimization, effectively enhances the overall performance of fuel cell data processing and analysis, demonstrating great 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, the one or more programs including instructions for executing the outlier removal method for fuel cell data as described in Embodiment 1.
[0076] Example 3
[0077] This embodiment provides a computer-readable storage medium including one or more programs executable by one or more processors of an electronic device, the one or more programs including instructions for performing an anomaly removal method for fuel cell data as described in Embodiment 1.
[0078] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for removing outliers from fuel cell data, characterized in that, Includes the following steps: Acquire fuel cell data including multiple samples, where each sample includes the actual voltage and current values of the fuel cell; Each sample in the fuel cell data is mapped to a data point in a multi-dimensional space. For each data point, the average distance and variance between the current data point and its K neighboring data points are calculated to obtain the z-score corresponding to each data point. Data points with z-scores greater than a threshold are removed from the fuel cell data. The samples corresponding to the data points; For each sample in the removed fuel cell data, the variable value is fitted based on at least one variable related to the fuel cell voltage. The fitness function value of the sample is calculated using the ant colony algorithm. The fitting index value of the polarization curve corresponding to the sample with the highest fitness function value is calculated. The hyperparameters K and K corresponding to the maximum goodness-of-fit index value are obtained through grid search. The values are used to obtain the fuel cell data after removing samples under the corresponding values, thus realizing outlier removal. The variables associated with the fuel cell voltage include open-circuit voltage, Tafel slope, current density, loss current density, ohmic resistance, and concentration loss parameters. The polarization curve is fitted using the following formula: in, , These are the output voltage and the open-circuit voltage, respectively. Let the Tafel slope be... , These are current density and loss current density, respectively. The resistance value is ohms. , This is the concentration loss parameter.
2. The method for removing outliers from fuel cell data according to claim 1, characterized in that, The z-score is calculated using the following formula: in, For z-scores, , These are the average distance and variance between the current data point and its K neighboring data points, respectively. This is the mean of the average distances between all data points.
3. The method for removing outliers from 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 removed fuel cell data, a voltage fitting value is calculated based on the current value and variable values of the fuel cell. The first error between the voltage fitting value and the actual voltage value is calculated. The second error between the vector formed by the current value and variable values and the preset standard value vector is calculated. Based on the first error and the second error, a fitness function value is obtained by weighting.
4. The method for removing outliers from 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 and used as the second error.
5. The method for removing outliers from fuel cell data according to claim 1, characterized in that, The fit index value Calculate using the following formula: in, Indicates the goodness of fit. This represents the root mean square error.
6. The method for removing outliers from fuel cell data according to claim 1, characterized in that, The process of fitting variable values based on at least one variable associated with fuel cell voltage includes: Based on the variables associated with the fuel cell voltage, preliminary fitted variable values are obtained; The initially fitted variable values are scaled down to serve as the upper and lower limits of the least squares method, and then fitted again to obtain the final variable values.
7. An electronic device, characterized in that, include: One or more processors and a memory, wherein the memory stores one or more programs, the one or more programs including instructions for executing the outlier removal method for fuel cell data as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, It includes one or more programs that are executed by one or more processors of an electronic device, the one or more programs including instructions for performing an anomaly removal method for fuel cell data as described in any one of claims 1-6.