# State of Health Prediction for Lithium-Ion Batteries Using Transformer-LSTM Fusion Model
## 2 Extraction and Selection of Multidimensional Features
### Data Preprocessing  
Feature curves are often affected by noise and fluctuations, resulting in outliers and uneven curves. To solve this problem, we used the LOF algorithm [30] to detect outliers effectively and replace them with linear interpolation. Additionally, the Savitzky-Golay filter [31] is applied for data smoothing to enhance feature quality. Figure 4 shows the effect  
Figure 3: (**a**) Variation curves of voltage, current, energy, and temperature within the charging range; (**b**) charging voltage curves under different cycles; (**c**) charging current curves under different cycles; (**d**) charging energy curves under different cycles; (**e**) charging temperature curves under different cycles; (**f**) comparison of SOH (red curve) and multidimensional features generated by voltage, current, energy; and temperature curves (green curve).  
of feature data after processing. In the original yellow curve, the outliers are corrected by linear interpolation and then filtered to form a smooth curve. This process effectively removes noise and abnormal fluctuations in the data and improves the quality of the feature data.  
The LOF algorithm is a widely adopted technique for anomaly detection. It identifies outliers by comparing the relative density between a data point and its neighbors. If the density of a data point is significantly lower than its neighbors, the point is considered an outlier. The LOF value measures the degree of anomaly. Usually, when the LOF value of a data point is greater than 1, it indicates that the point is an outlier, and the larger the LOF value, the more likely it is to be an outlier. The calculation formula for the LOF value is as follows:  
\[LOF(P)=\frac{1}{k}\sum_{O\in N_{k}(P)}\frac{LRD(P)}{LRD(O)} \tag{2}\]  
where \(N_{k}(P)\) is the k neighbors of point \(P\) and \(LRD(P)\) is the local reachability density of point \(P\).  
The Savitzky-Golay filter is a weighted average algorithm based on a moving window. It effectively smooths the curve by fitting the data points with a \(k\)-order polynomial least square in a fixed-length window. This method is particularly effective in removing random Gaussian noise.  
In order to perform Gaussian filtering on the feature data, the width of the filter window is set to \(w=2m+1\). Within this window, the current point in the feature data and its neighboring point set \(x_{m}=(-m,-m+1,\cdots,0,1,\cdots,m-1,m)\) are selected. Then, a \(k-1\)-order polynomial fitting is performed using these data points, where \(a_{t}=(0,1,2,\cdots,k-1)\) represents the required polynomial parameters. Through the fitting process, the smoothed value \(y\) is generated. The calculation formula is shown below:  
\[\begin{pmatrix}y-m\\ y-m-1\\...\\ y\end{pmatrix}=\begin{pmatrix}1&-m&\cdots&(-m)^{k-1}\\ 1&-m+1&\cdots&(-m+1)^{k-1}\\ \vdots&\vdots&\vdots&\vdots\\ 1&m&\cdots&m^{k-1}\end{pmatrix}\begin{pmatrix}a_{0}\\ a_{1}\\ \vdots\\ a_{k-1}\end{pmatrix}+\begin{pmatrix}e_{-m}\\ e_{-m+1}\\ \vdots\\ e_{m}\end{pmatrix} \tag{3}\]  
The above matrix form is written in formula form:  
\[Y_{(2m+1)\times 1}=X_{(2m+1)\times k}\cdot A_{k\times 1}+E_{(2m+1)\times 1} \tag{4}\]  
Finally, find the least squares solution A of \(A\) and obtain the final filtered value Y.  
\[\begin{array}{c}\hat{Y}=X\cdot\hat{A}=X\cdot(XT\cdot X)-1\cdot X\cdot T\cdot Y \\ \hat{A}=(XT\cdot X)-1\cdot X\cdot T\cdot Y\end{array} \tag{5}\]  
Figure 4: Data smoothing using the LOF algorithm and Savitzky–Golay filter.