Electrocardiosignal classification method mixing differential evolution and improved grey wolf optimization algorithm
Through the mixed differential evolution and improved electrocardiogram classification method of gray wolf optimization algorithm, combined with wavelet transformation and LSTM network, the problem of low accuracy in electrocardiogram classification is solved, and the efficient classification and diagnosis of electrocardiogram signals is realized, which is suitable for heart health monitoring and disease management.
Patent Information
- Application Number
- CN202510418318.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-08
AI Technical Summary
The existing gray wolf optimization algorithm has problems of low classification accuracy and slow convergence speed in the classification of ECG signals.
The electrocardiogram signal classification method of mixed differential evolution and improved gray wolf optimization algorithm is adopted, and the LSTM network model is optimized by wavelet transformation, and the time dependence of the electrocardiogram signal is used to process the ECG signal through long and short-term memory network to improve the classification accuracy.
It improves the accuracy and diagnostic efficiency of electrocardiogram signal classification, is suitable for large-scale heart health monitoring and preventive management of heart disease, and promotes technological progress in the fields of electrocardiogram physiology and medical imaging analysis.
Smart Images

Figure CN120277470A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electrocardiogram classification, and relates to an electrocardiogram signal classification method combining differential evolution and improved grey wolf optimization algorithm. Background Art
[0002] Heart diseases are important health problems worldwide, including arrhythmia, myocardial ischemia, myocardial infarction, etc. Electrocardiogram is a non-invasive examination method for recording the electrical activity of the heart. By observing the waveforms, intervals and segments of electrocardiogram signals, the heart function can be evaluated, arrhythmia can be detected and heart diseases can be diagnosed. Electrocardiogram has become a non-invasive and effective medical tool for observing the heart state. With the continuous increase of cardiovascular diseases, electrocardiogram signal classification plays a crucial role in the diagnosis, prevention and monitoring of heart diseases. At the same time, automated Electro Cardio Gram (ECG) signal analysis has also become an important topic.
[0003] Traditional electrocardiogram signal classification relies on the analysis and identification of professional doctors, which is not only time-consuming but also error-prone.
[0004] With the progress of artificial intelligence and deep learning technologies, especially the introduction of the Grey Wolf Optimizer (GWO) and the Long Short-Term Memory (LSTM) model, automated electrocardiogram signal classification methods provide new technical means for electrocardiogram analysis. However, the existing grey wolf optimization algorithm is prone to local optimum and relatively slow convergence speed, resulting in a decrease in the classification accuracy of ECG signals. Summary of the Invention
[0005] The purpose of the present invention is to provide an electrocardiogram signal classification method combining differential evolution and improved grey wolf optimization algorithm, which solves the problem of low classification accuracy of the existing grey wolf algorithm in ECG signal classification.
[0006] The technical solution adopted by the present invention is an electrocardiogram signal classification method combining differential evolution and improved grey wolf optimization algorithm, which specifically includes the following steps:
[0007] Step 1, establish an electrocardiogram hybrid dataset;
[0008] Step 2, preprocess the dataset established in Step 1 to obtain a one-dimensional flattened array;
[0009] Step 3, use wavelet transform on the one-dimensional flattened array obtained in Step 2 for decomposition;
[0010] Step 4, perform denoising processing on the wavelet decomposition result obtained in Step 3 by calculating the threshold;
[0011] Step 5: Perform label data partitioning and format processing on the denoised ECG feature dataset obtained in Step 4;
[0012] Step 6: Optimize the Grey Wolf Algorithm;
[0013] Step 7: Construct an LSTM network model based on the optimization result of Step 6;
[0014] Step 8: Train and evaluate the LSTM network model constructed in Step 7.
[0015] The features of the present invention also lie in:
[0016] The specific process of Step 1 is as follows:
[0017] Step 1.1: Take the self-collected ECG signals as the self-collected dataset and name the self-collected dataset A;
[0018] Step 1.2: Download the MIT-BIH Arrhythmia Dataset from the publicly available database and name this dataset B;
[0019] Step 1.3: Downsample the self-collected data A to make the data sampling frequency consistent with that of the MIT-BIH Arrhythmia Dataset, and unify the digital format of dataset A and dataset B through unit conversion and data alignment;
[0020] Step 1.4: Integrate the annotation systems in dataset A and dataset B to ensure the annotation consistency of all data;
[0021] Step 1.5: Extract the key feature-annotated ECG activity point data from the unified data A and dataset B in Step 1.4 respectively, and fuse the feature point information and label information in the two obtained datasets A and B to construct a new hybrid dataset C.
[0022] The specific process of Step 2 is as follows:
[0023] Read the dataset C obtained in Step 1.5 through the wfdb library of the WaveformDatabase toolkit, and use the flatten method in the numpy library to flatten the signals of each lead in the record into a one-dimensional array, that is, the one-dimensional dataset C.
[0024] The specific process of Step 3 is as follows:
[0025] Decompose dataset C into the approximation coefficient cA1 and the detail coefficient cD1; then further decompose the approximation coefficient cA1 to obtain the new approximation coefficient cA2 and the detail coefficient cD2; subsequently, each subsequent filtering recursively decomposes the approximation coefficient of the current layer to generate the approximation coefficient cA n+1 of the next layer and the detail coefficient cDn+1 , decompose successively in this way until the detail coefficients of each layer from cD1 to cD9 and cA1 to cA9 are finally obtained; the decomposition formula is as follows:
[0026]
[0027] Among them, r represents the index of the sampling point at the current time point or in the signal, k represents the index of the filter coefficient, n represents the number of layers or the number of iterations of wavelet decomposition, g[k] and h[k] are the filtering coefficients of the low-pass and high-pass filters respectively, and cA n is the approximation coefficient of the nth layer, and cD n is the detail coefficient of the nth layer.
[0028] The specific process of Step 4 is as follows:
[0029] Step 4.1, for the detail coefficients obtained by wavelet decomposition in Step 3, calculate the threshold for each layer of detail coefficients, and the calculation formula is as follows:
[0030]
[0031] Among them, m is the length of the signal, usually the number of sampling points in the electrocardiogram signal, median(|cD1|) is the median of the absolute value of the first-layer detail coefficient cD1, and threshold is the final threshold obtained through calculation;
[0032] Step 4.2, use the threshold threshold calculated in Step 4.1 to perform soft threshold processing on the detail coefficients cD1 to cD9 generated by each layer of wavelet decomposition obtained in Step 3 in turn, and the specific formula is as follows:
[0033]
[0034] Among them, threshold is the threshold calculated in Step 4.1, and w is the coefficient set containing cA1 to cA n and the approximation coefficient cD of the last layer n ;
[0035] Step 4.3, perform wavelet inverse transform reconstruction on the detail coefficients of each layer of cD1 to cD9 after denoising in Step 4.2, overlap and accumulate the signal parts reconstructed from the coefficients of different frequency bands according to the following formula (5), and combine the approximation coefficients cA of different layers through inverse wavelet transform n and the detail coefficient cD n to obtain the approximation coefficient cA of the previous layer through the inverse transform formula n-1 , and the specific formula is as follows
[0036]
[0037] Among them, cA n and cD n are the approximation coefficients of the nth layer, and h[k] are the coefficients of the reconstruction filter;
[0038] Step 4.4: Let n = 9. Starting from the 9th layer, combine the approximation coefficient cA9 and the detail coefficient cD9 of the 9th layer, and generate the signal of the 8th layer through the above formula (5); then continue to reconstruct the generated signal of the 8th layer with the detail coefficient cD8 of the 8th layer to obtain the signal of the 7th layer, and proceed layer by layer forward until the detail coefficient cD n and the approximation coefficient cA n are combined layer by layer, and finally the denoised electrocardiogram feature dataset D is obtained.
[0039] The specific process of Step 5 is as follows:
[0040] Step 5.1: Obtain the waveform positions with the feature label R in the denoised electrocardiogram feature dataset D obtained in Step 4. Based on the R-wave position information, sample the 100 electrocardiogram records before the R wave and the 200 electrocardiogram records after the R wave to form an electrocardiogram signal group with 300 electrocardiogram signal points as a data group.
[0041] Step 5.2: Create a dataSet data array and a labelSet label array.
[0042] Step 5.3: Through iteration, extract the electrocardiogram signal group data and the corresponding feature labels of each different subject from the denoised electrocardiogram feature dataset D according to Step 5.1, and store the electrocardiogram record signal group in the dataSet data array in Step 5.2, and the corresponding feature labels in the labelSet label array.
[0043] Step 5.4: Use the np.array method to convert the dataSet and labelSet arrays created in Step 5.3 into NumPy arrays, and then reshape the dataSet array and the labelSet array respectively through the reshape method. Each sample of the dataSet array is reshaped into a one-dimensional array with 300 features, and labelSet is a one-dimensional array of single labels.
[0044] Step 5.5: Horizontally merge the one-dimensional dataSet data array and the one-dimensional labelSet label array obtained in Step 5.4. After merging, each row represents a sample, and each row contains two columns, which are the electrocardiogram feature data and the feature label respectively, thus forming a two-dimensional array containing complete sample information.
[0045] Step 5.6: Divide the two-dimensional array y obtained in Step 5.5 into a training set, a test set, and a validation set in a ratio of 6:2:2. At the same time, divide the two-dimensional array y into small batches of a unified fixed size, where each batch is a two-dimensional array data containing 128 data features among them.
[0046] The specific process of Step 6 is as follows:
[0047] Step 6.1: Introduce a combination of the hybrid differential evolution algorithm and the grey wolf optimization algorithm, and introduce an attraction factor with ρ(t) and the adaptive parameter p rw Dynamically optimize the position update method of grey wolf optimization. According to the hierarchical relationship among the α, β, and δ wolves, update the α, β, and δ wolves respectively;
[0048] Step 6.2: According to the update results of Step 6.1, introduce the differential evolution strategy and the cross-adjustment strategy, the number of iterations U, and the number of hidden layers L.
[0049] The specific process of Step 6.1 is as follows:
[0050] Step 6.1.1: Set three leading wolves in the wolf pack: α wolf, β wolf, and δ wolf;
[0051] Step 6.1.2: Initialize the convergence curve with np.zeros;
[0052] Step 6.1.3: Initialize the positions of the α, β, and δ grey wolves as [0, 0];
[0053] Step 6.1.4: Update the positions of the α wolf, β wolf, and δ wolf.
[0054] The specific process of Step 6.1.4 is as follows:
[0055] The position update criterion for the δ wolf is as follows:
[0056] During the movement of the δ wolf, the δ wolf updates its position according to the leadership of the α wolf and the β wolf, and dynamically adjusts its position through the non-linear adjustment factor ρ(t). The update formula is as follows:
[0057]
[0058] where ρ(t) represents the generated smooth transition value, is the parameter controlling the growth rate, t0 is the parameter determining the center position of the function, t is the current iteration number, is the current position of different reference individuals in the population, is the obtained position update value;
[0059] The position update criterion for the β wolf is as follows:
[0060] Update using the following formula:
[0061]
[0062] where a0 is the initial weight, λ is the decay factor, t is the current iteration number, ∈·N(0,1) is a random perturbation generated by the normal distribution, represents the position of β wolf in the next iteration, represents the positions of α and β individuals in the t-th generation, is the set of positions of the population, mean and std represent the standard deviation and the mean respectively;
[0063] The position update criterion for the α wolf is as follows: Calculate the random walk probability, calculate the random walk probability according to the fitness of the α wolf, and use the following update formula:
[0064]
[0065] where, represents the position offset of the current optimal individual α, is the adjustment factor, represents the absolute difference between the optimal individual position and the population average position; p rw represents the random walk probability, ρ min and p max represent the minimum probability and the maximum probability of the random walk respectively, f min and f max represent the minimum value and the maximum value of the fitness among all wolves respectively; represents the position of the optimal individual in the current t-th generation, represents the position of the optimal individual in the next generation (t + 1).
[0066] The specific process of Step 6.2 is as follows:
[0067] Step 6.2.1, Calculate N through the following formula (14). N is the average of the squares of the position deviations of all individuals from the average value in each dimension, and is used to represent the dispersion degree of the population in the solution space:
[0068]
[0069] where a is the number of gray wolves in the population, d is the characteristic dimension of each individual, X i,j is the position of the i-th individual in the j-th dimension, is the average position of all individuals in the j-th dimension;
[0070] Step 6.2.2, Selection operation: Assume that the parent gray wolves x1 and x2 are randomly selected, and their positions are x1 = (x1,1,1 ; x 1,1,2 ), and x2 = (x 2,1,1 ; x 2,1,2 ); where x 1,1,1 represents the first component of the first dimension of the first parent gray wolf, and x 1,1,2 represents the second component of the first dimension of the first parent;
[0071] Step 6.2.3, Crossover update operation: Select a crossover probability CR to determine whether to perform a crossover operation. Assume the total dimension of the gray wolf individuals is D, and j is a certain dimension in the D dimensions. Generate a random number rand() ∈ [0, 1], and perform the following crossover on dimension j:
[0072]
[0073] where rand is a random number, CR is the crossover probability, and U i,j is the j-th dimension value of the offspring individual generated after crossover, X 1,j is the value of the first parent on the j-th dimension, and X 2,j is the value of the second parent on the j-th dimension;
[0074] Step 6.2.4, Compare the new individual generated by the crossover operation in Step 6.2.3 with the original individual, and select a new individual according to the step result;
[0075] Step 6.2.5, Adjust the crossover probability CR: The crossover probability depends on the comparison between the diversity and a certain set target value N target , and dynamically adjust the crossover probability CR in Step 6.2.3. The specific formula is as follows:
[0076] CR(t + 1) = CR(t) + y(tanh(N - N target )) (15)
[0077] where CR(t) is the crossover probability of the current iteration, and y is the adjustment rate;
[0078] Step 6.2.6, Check whether the current population update round b has reached the set maximum value. If it is satisfied, terminate the update. Otherwise, return to Step 6.1.4 for looping, select the individual with the best performance evaluation finally, and use the corresponding iteration number U and the number of hidden layers L as the final parameters of the LSTM in Step 7.
[0079] The beneficial effects of the present invention are as follows. The present invention optimizes feature selection and network parameters using the Grey Wolf algorithm, enhancing the learning ability and adaptability of the classification model. The Long Short-Term Memory (LSTM) model, on the other hand, utilizes its excellent sequential data processing ability to accurately capture the time-dependence of electrocardiogram (ECG) signals, improving the detection accuracy of ECG abnormalities. These methods not only accelerate the doctor's diagnosis process, improve the quality and efficiency of medical services, but also are applicable to large-scale cardiac health monitoring and research, providing strong support for the prevention and management of heart diseases and promoting technological progress in the fields of electrocardiophysiology and medical image analysis. Brief Description of the Drawings
[0080] Figure 1 is the flowchart of the ECG signal classification method combining differential evolution and improved Grey Wolf optimization algorithm of the present invention;
[0081] Figure 2 is the illustration of the specific positions of ECG leads;
[0082] Figure 3 is the flowchart of the operation of the differential Grey Wolf algorithm in the ECG signal classification method combining differential evolution and improved Grey Wolf optimization algorithm of the present invention;
[0083] Figure 4 is the schematic diagram of the individual crossover update step of the differential evolution improved Grey Wolf algorithm of the present invention;
[0084] Figure 5 The overall structure diagram of the final network model used in the ECG signal classification method combining differential evolution and improved Grey Wolf optimization algorithm of the present invention;
[0085] Figures 6(a) to 6(b) The model training convergence effect diagram in the ECG signal classification method combining differential evolution and improved Grey Wolf optimization algorithm of the present invention. Detailed Description of the Preferred Embodiments
[0086] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0087] Embodiment 1
[0088] The ECG signal classification method combining differential evolution and improved Grey Wolf optimization algorithm of the present invention has a process as Figure 1 shown. It is specifically implemented according to the following steps:
[0089] Step 1: Establish an ECG hybrid dataset;
[0090] Step 2: Data processing;
[0091] Step 3: Decompose the data processing result of Step 2 using wavelet transform;
[0092] Step 4, process the wavelet decomposition result of Step 3 through calculating a threshold value, so as to achieve the purpose of removing noise, and the principle of soft threshold denoising is adopted.
[0093] Step 5, perform label data partitioning and format processing on the dataset obtained after denoising in Step 4;
[0094] Step 6, optimize the grey wolf algorithm;
[0095] Step 7, construct an LSTM model;
[0096] Step 8, model training and result evaluation.
[0097] Embodiment 2
[0098] Step 1 specifically includes the following steps:
[0099] Step 1.1, take the self-collected electrocardiogram signals as the self-collected dataset, and this dataset is named A. The present invention mainly collects limb lead II (i.e., the potential difference formed by the electrode positions between the right arm and the left leg) and lead V1 (electrode at the fourth intercostal space on the right edge of the sternum). The specific lead description is as Figure 2 shown. The collected electrocardiogram signals will first be subjected to preliminary amplification and filtering through a collection instrument.
[0100] Step 1.2, download the MIT-BIH Arrhythmia Database from a public database. This dataset is named B. This database contains more than 4,000 long-term dynamic electrocardiogram device records. The recorded samples come from inpatients between 1975 and 1979, and contain 23 (lead II) and 25 (lead V1) records, with a recording time of about 30 minutes.
[0101] Step 1.3, downsample the self-collected data A to make the data sampling frequency consistent with the sampling frequency of 360 Hz of the MIT-BIH Arrhythmia Database. And unify the digital format of the self-collected electrocardiogram data A and the data in the MIT-BIH database B through unit conversion and data alignment.
[0102] Step 1.4, integrate the annotation systems in dataset A and dataset B to ensure the annotation consistency of all data. The specific steps are as follows:
[0103] Step 1.4.1, compare the annotation systems of the two datasets in dataset A and the MIT-BIH dataset B. In the self-collected dataset, feature annotations are usually made in numbers, while in the MIT-BIH dataset B, feature annotations are made in letters. Here, some are selected for illustration as shown in Table 1 below:
[0104] Table 1
[0105] Label Name Self - Collected Data A Label Number Description Normal Heartbeat 0 Corresponds to "Normal Heartbeat (N)" in Dataset B Atrial Premature Contraction 1 Corresponds to "Atrial Premature Contraction (A)" in Dataset B Ventricular Premature Contraction 2 Corresponds to "Ventricular Premature Contraction (V)" in Dataset B Atrial Flutter 3 Corresponds to "Atrial Flutter (F)" in Dataset B
[0106] Step 1.4.2. Establish a label mapping table. Regarding the problem of different label names in the MIT-BIH dataset B, a mapping table needs to be established to correspond different labels. Some corresponding relationships are selected for illustration here, as shown in Table 2 below:
[0107] Table 2
[0108]
[0109] Step 1.4.3. Unify the label format to ensure that the labels of the MIT-BIH dataset B and the self-collected dataset A have a consistent encoding method, and each label corresponds to an integer number. For example, 0 represents a normal heartbeat, and 1 represents a premature atrial contraction.
[0110] Step 1.4.4. Verify the annotation. After completion of the integration, check and verify whether the data is correctly annotated, and ensure that the electrocardiogram features of both dataset A and dataset B are represented by digital labels.
[0111] Step 1.5. Based on the unified datasets A and B in Step 1.4, extract the electrocardiogram activity point data with key feature annotations (including the starting points and amplitude information of these waveforms). By fusing the feature point information and label information extracted from datasets A and B, a new mixed dataset C is constructed. Dataset C contains the feature point data of electrocardiogram activities and their corresponding feature labels in a unified format, ensuring the consistency and usability of data from different sources. In the present invention, 50 two-channel dynamic electrocardiogram signal records are selected from the mixed dataset C as experimental data. The signal data is calculated from the unified sampling frequency and recording time length, and a total of 700,000 time point data is included, which serves as the basis for subsequent experiments. The specific formula is as follows:
[0112] Total time (seconds) = Total number of time points / Sampling frequency (1)
[0113] The specific process of Step 2 is as follows:
[0114] Read the feature dataset C obtained in Step 1.5 through the wfdb library of the Waveform Database toolkit, and use the flatten method in the numpy library to flatten the signals of each lead in the record into a one-dimensional array [70000 (sampling points), 2 (number of channels)], making it suitable for subsequent machine learning model training and signal processing operations.
[0115] Example 3
[0116] The specific process of Step 3 is as follows:
[0117] The present invention includes 9-layer wavelet decomposition, and the specific decomposition formula is as follows:
[0118]
[0119] Wherein, r represents the index of the sampling point at the current time point or in the signal, k represents the index of the filter coefficients (i.e., the number of the weights or values of the filter), n represents the number of layers of wavelet decomposition or the number of iterations (in the present invention, n = 9), g[k] and h[k] are the filter coefficients of the low-pass and high-pass filters respectively, and cA n is the approximation coefficient of the nth layer. cD n is the detail coefficient of the nth layer.
[0120] In step 3, the data of each layer is decomposed into two parts: the approximation coefficient (representing the low-frequency component, below 0.5 Hz is low frequency) and the detail coefficient (representing the high-frequency component, above 0.5 Hz is high frequency). The preliminary decomposition mainly decomposes the mixed data set C into the approximation coefficient cA and the detail coefficient cD, retaining the low-frequency and high-frequency parts. The approximation coefficient cA1 of the first layer is decomposed to obtain the approximation coefficient cA2 and the detail coefficient cD2 of the second layer, and so on. Subsequently, each time the approximation coefficient of the current nth layer is decomposed to generate the approximation coefficient cA n+1 , and the detail coefficient cD of the next layer n+1 (in the present invention, n = 9), finally obtaining the detail coefficients of each layer from cD1 to cD9 and the approximation coefficients of each layer from cA1 to cA9 for subsequent processing.
[0121] Example 4
[0122] The specific process of step 4 is as follows:
[0123] Step 4.1, through wavelet decomposition, 9 layers of detail coefficients are obtained. In order to remove noise, it is necessary to calculate the threshold for each layer of detail coefficients. The threshold calculation formula is as follows:
[0124]
[0125] Wherein, m is the length of the signal, usually the number of sampling points in the electrocardiogram signal. median(|cD1|) is the median of the absolute value of the first layer of detail coefficient cD1. A large amount of high-frequency components (including noise) are included in the detail coefficients. The median is used to estimate the intensity of the noise. 0.6745 is a constant used to convert the median into an estimate of the standard deviation. threshold is the final threshold obtained through calculation.
[0126] Step 4.2, using the threshold threshold calculated in step 4.1, apply the soft threshold formula to the detail coefficients cD1 to cD9 generated by the wavelet decomposition of each layer obtained in step 3 for soft threshold processing. The specific formula is as follows:
[0127]
[0128] Among them, threshold is the threshold calculated in step 4.1, and w is the coefficient set containing cA1 to cA obtained after wavelet decomposition in step 3 n and the approximation coefficient cD of the last layer n .
[0129] Step 4.3: Perform inverse wavelet transform reconstruction on the detail coefficients of each layer of cD1 to cD9 denoised in step 4.2, overlap and accumulate the signal parts reconstructed from the coefficients of different frequency bands according to the following formula, and combine the approximation coefficients cA of different layers through inverse wavelet transform n and the detail coefficient cA n . The specific formula is as follows
[0130]
[0131] Among them, cA n and cD n are the approximation coefficients of the nth layer. h[k] is the coefficient of the reconstruction filter, and the approximation coefficient cA of the previous layer is obtained through the inverse transform formula n-1 . Starting from the 9th layer of the present invention, combining the approximation coefficient cA9 and the detail coefficient cD9 of the 9th layer, through the above formula (6), the signal of the 8th layer is generated. Then, the generated signal of the 8th layer and the detail coefficient cD8 of the 8th layer are also reconstructed in the same way to obtain the signal of the 7th layer. This process will proceed layer by layer forward, successively obtaining the signals of the 6th layer, 5th layer, 4th layer, 3rd layer, 2nd layer, and 1st layer until the detail coefficient cD1 and the signal of the 1st layer are completely reconstructed through the above formula by inverse wavelet transform. After inverse transform reconstruction, all the detail coefficients cD n and the approximation coefficients cA n are combined layer by layer, and finally the denoised electrocardiogram feature data set D is obtained, retaining the main feature information in the electrocardiogram signal.
[0132] Example 5
[0133] The specific process of step 5 is as follows
[0134] Step 5.1: Obtain the waveform positions with the feature label R in the electrocardiogram feature data set D denoised in step 4. Based on the R-wave position information, sample 100 electrocardiogram records before the R wave and 200 electrocardiogram records after the R wave, and form an electrocardiogram signal group with 300 electrocardiogram signal points as a data group for subsequent model input.
[0135] Step 5.2: Create a dataSet data array and a labelSet label array.
[0136] Step 5.3: Through iteration, extract the electrocardiogram (ECG) signal group data and corresponding feature labels of each different subject (the present invention is based on 47 different patients) from the denoised ECG feature data set D according to Step 5.1, and store the ECG recording signal group in the dataSet data array in Step 5.2, and the corresponding feature labels will be in the labelSet label array.
[0137] Step 5.4: Use the np.array method (provided by the NumPy library) to convert the dataSet and labelSet arrays created in Step 5.3 into NumPy arrays for numerical operations and scientific calculations. Then, reshape the dataSet array and labelSet array respectively through the reshape method. Each sample in the dataSet array is reshaped into a one-dimensional array of 300 features, and labelSet is a one-dimensional array of single labels. Ensure that the shape of the data meets the input requirements of the subsequent model.
[0138] Step 5.5: Horizontally stack (merge) the one-dimensional dataSet data array and the one-dimensional labelSet label array obtained in Step 5.4. After merging, each row represents a sample, and each row contains two columns, which are the ECG feature data and the feature label respectively, thus forming a two-dimensional array containing complete sample information.
[0139] Step 5.6: Divide the two-dimensional array y obtained in Step 5.5 into a training set, a test set, and a validation set in a ratio of 6:2:2. At the same time, divide the two-dimensional array y into small batches of a unified fixed size (a total of 547 batches), and each batch is a two-dimensional array data containing 128 data features therein, which is used for batch processing of the data set during the training process.
[0140] The specific process of Step 6 is as follows (the process is as Figure 3 shown in the figure, where R is a random number in the interval [0,1], and b represents the population update round (the maximum number of rounds in the present invention is selected as 50 times):
[0141] Step 6.1: Introduce a combination of the hybrid differential evolution algorithm and the grey wolf optimization algorithm, and introduce the attraction factor with ρ(t) and the adaptive parameter p rw to dynamically optimize the position update method of grey wolf optimization. In this embodiment, according to the hierarchical relationship between the α, β, and δ wolves, separate update strategies are adopted for the α, β, and δ wolves respectively.
[0142] Step 6.1.1: Initial setting: Set three dominant wolves in the wolf pack: the α wolf (the best solution), the β wolf (the second best solution), and the δ wolf (the third best solution).
[0143] Step 6.1.2, initialize the convergence curve (including the change records of the optimal solutions (objective function values) of α, β, and δ gray wolves in each generation) using np.zeros (a NumPy library function).
[0144] Step 6.1.3, initialize the positions of α, β, and δ gray wolves as [0, 0] (represented in two-dimensional coordinates);
[0145] Step 6.1.4, update the positions of the wolves. α1, a2, a3 represent three leading individuals (global optimal solution, sub-optimal solution, third-optimal solution) in the current population, and D a D β D δ represents the distance between an ordinary individual and the three leading wolves.
[0146] Position update strategy for δ: During the movement of the δ wolf, the δ wolf updates its position according to the leadership of the α wolf and the β wolf. This method repeatedly considers the leadership factors of the α wolf and the β wolf. In the position update calculation method, the nonlinear adjustment factor ρ(t) is used to dynamically adjust the position. Use the following update formula:
[0147]
[0148] where ρ(t) represents the generated smooth transition value, is the parameter controlling the growth rate, t0 is the parameter determining the center position of the function, t is the current iteration number, are the current positions of different reference individuals in the population, is the obtained position update value. This formula updates the leadership according to the positions of the α wolf and the β wolf. During the update process, random numbers and new weight factors are introduced, making the search not completely dependent on the current optimal position, while also having a certain directionality and randomness.
[0149] Position update criterion for β wolf: The position update of the wolf is dominated by the global optimal solution α wolf, and the current position of the individual is also considered. In the Grey Wolf Optimization (GWO) algorithm, the β wolf refers to the second-best individual in the population. The position update of the β wolf is affected by the global optimal solution (α wolf), and by adjusting the amplitude of the individual update, it helps the population better search for the optimal solution. In the traditional Grey Wolf Optimization (GWO) algorithm, the position update formula of the β wolf overly depends on the global optimal solution, which may lead to the over-concentration of the population during the search process, resulting in insufficient local search ability of the algorithm and the inability to accurately and efficiently explore the global optimal solution. Therefore, use the following update formula:
[0150]
[0151] Among them, a0 is the initial weight (used to control the movement amplitude), λ is the attenuation factor, and t is the current iteration number. ∈·N(0,1) is the random perturbation generated by the normal distribution. Indicates the position of the β wolf in the next iteration. Represents the positions of the α and β individuals in the t-th generation. is the position set of the population, where mean and std represent the standard deviation and the mean respectively. By adjusting the weight factor a(t) and the intensity of the normal distribution random perturbation, this method can well balance the exploration and exploitation of the algorithm.
[0152] α wolf position update criterion: Calculate the random walk probability, calculate the random walk probability according to the fitness of the α wolf, and use the following update formula:
[0153]
[0154] Among them, Indicates the position offset of the current optimal individual α. is the adjustment factor. Represents the absolute difference between the optimal individual position and the population average position. p rw Indicates the probability of random walk, ρ min and p max Represent the minimum probability and the maximum probability of random walk respectively. By setting ρ min and p max to change the degree of random walk, f represents the fitness value of the α wolf, f min and f max Represent the minimum and maximum fitness values among all wolves respectively.
[0155] Adaptive adjustment (Formula 12): Automatically adjust the proportion of exploration and exploitation according to the fitness of the α wolf, so as to increase exploration when the fitness is low. Represents the position of the optimal individual in the current t-th generation. Represents the position of the optimal individual in the next generation (t + 1). According to the calculated random walk probability P rw Determine whether to perform a random walk. If the individual fitness f(α) is low (close to f min ), then P rw is large, which means it is more likely to perform a random walk. If the fitness is high (close to f max ), then P rw is small, tending to retain the current position or use other update strategies to jump out of the local optimum.
[0156] Step 6.2, introduce the differential evolution strategy and the cross adjustment formula, as follows:
[0157] Step 6.2.1. Since the traditional Grey Wolf Optimization algorithm initializes the population randomly, the probability of finding the optimal solution is uncontrollable. First, the diversity of the population is determined by the following formula. N is the average of the squares of the position deviations of all individuals in each dimension from the average value, which represents the dispersion degree of the population in the solution space.
[0158]
[0159] Among them, a is the number of grey wolves in the population, d is the characteristic dimension of each individual, X i,j is the position of the i-th individual in the j-th dimension, is the average position of all individuals in the j-th dimension.
[0160] Step 6.2.2. Selection operation: Based on the initialized population individuals generated in 6.2.1 (including x1 to x n ), assuming that the parental grey wolves x1 and x2 are randomly selected, their individual dimensions (vector space positions) are x1 = (x n,1,1 ; x 1,1,2 ) and x2 = (x 2,1,1 ; x 2,1,2 ). Among them, x 1,1,1 represents the first component of the first dimension of the first parental grey wolf, and x 1,1,2 represents the second component of the first dimension of the first parental grey wolf.
[0161] Step 6.2.3. Crossover update operation (see the specific flowchart in Figure 4 ): Select a crossover probability CR to determine whether to perform the crossover operation. A grey wolf individual represents a specific configuration of the subsequent LSTM model, usually consisting of a set of parameters. The total dimension is D (D = 2 in the present invention), represented by the two-dimensional vector [L, U], where U is the number of iterations and L is the number of hidden layers. j is a certain dimension in the D dimensions (j < D). Generate a random number rand() ∈ [0, 1], and perform the following crossover on dimension j:
[0162]
[0163] Among them, rand is the random number and CR is the crossover probability. U i,j is the value of the j-th dimension of the offspring individual generated after crossover, X 1,j is the value of the first parental in the j-th dimension, X 2,j is the value of the second parental in the j-th dimension. Finally, the new individual X w after random dimension crossover is obtained.
[0164] Step 6.2.4. Individual selection: The new individual X generated by the crossover operation in Step 6.2.3w Compare the fitness with the original individuals X1 and X2. The fitness is obtained by substituting the parameters U and L included in each of X w and X1, X2 into the model to evaluate the accuracy (according to Equation 18).
[0165] Step 6.2.5, adjust the crossover probability CR: It is achieved through a diversity-based feedback mechanism, where the crossover probability depends on the comparison between the diversity and a set target value N target to dynamically adjust the crossover probability CR in Step 6.2.3, enabling the algorithm to have different search capabilities at different stages. The specific formula is as follows:
[0166] CR(t + 1) = CR(t) + y(tanh(N - N target )) (16)
[0167] CR(t) is the crossover probability of the current iteration. y is the adjustment rate, used to control the adjustment rate of CR(t). N is obtained through Equation (14). tanh is the hyperbolic tangent function, used to smooth the adjustment range and ensure that the update of CR(t) is within a reasonable range.
[0168] The function of Equation (16) is to increase CR(t) to increase exploration when N is lower than N target and decrease CR(t) to enhance the local search ability when N is higher than N target . In practical applications, by setting the upper and lower limits of CR(t), it is possible to prevent the CR(t) value from exceeding the effective range and play a stronger control role in the next iteration.
[0169] Step 6.2.6, check whether the current population update round b has reached the set maximum value. If satisfied, terminate the update; otherwise, return to Step 6.1.4 for cycling. Select the individual with the best effect through performance evaluation (Equations 17 - 22) and use its U and L as the final parameters of the LSTM in Step 7.
[0170] Example 6
[0171] The specific process of Step 7 is as follows:
[0172] Step 7.1, the LSTM model structure, which consists of three parts:
[0173] The LSTM layer: It is used to take the two-dimensional array obtained in Step 5.6 as the input data, extract the temporal dependencies and features in the two-dimensional array, and learn the long-term dependence features in the input time series.
[0174] Fully-connected layer I: Receives the output of the LSTM layer, maps high-dimensional features to a lower-dimensional feature space, and at the same time performs a non-linear transformation through the Sigmoid activation function to reduce the dimension and enhance the non-linear expression of the features.
[0175] Fully-connected layer II: Receives the output of fully-connected layer I, and through the Softmax activation function, further maps the features into a classification probability distribution, which is transformed into the final result of the classification task.
[0176] Step 7.2, Model parameter setting: Based on the number of hidden layers L obtained in step 6.3.6, an LSTM model is constructed. The number of units in the LSTM layer is set to L. For the specific model parameters of the experiment, the final output dimension of the LSTM layer is selected as 72 to enter fully-connected layer I, and the output dimension of this layer is 48 to enter fully-connected layer II. The final output shape is a probability distribution of 5 dimensions (the structure is shown in Figure 5 ).
[0177] The specific process of step 8 is as follows:
[0178] Step 8.1, Use the LSTM model constructed in step 7 to perform a classification task on the electrocardiogram signal. First, input the training set obtained by dividing the two-dimensional array y divided in step 5.6 into the LSTM model for training. The number of training iterations is based on the number of iterations U obtained in step 6.2.6. The prediction result is output through the LSTM model, and the cross-entropy loss function, and the formula is as follows:
[0179]
[0180] where K is the total number of sample categories (i.e., the number of categories in the classification task), l i is the label of the true category, and L i is the probability of the i-th category predicted by the model.
[0181] Evaluate the error value between the predicted output and the true feature label. Subsequently, calculate the error Loss layer by layer according to formula 19 for iteration, gradually reduce the value of the loss function, improve the classification performance of the model, and ensure the effective extraction of electrocardiogram signal features and the improvement of classification accuracy. See the loss graph in Figure 6(a) specifically. The horizontal axis represents the number of training iterations, and the vertical axis represents the loss value. In the initial stage, the loss value is relatively high. As the training progresses, the loss value gradually decreases and tends to be stable, indicating that the model gradually learns the features of the electrocardiogram signal for classification.
[0182] Step 8.2: Use the test set and validation set in the two-dimensional array y divided in Step 5.6 to comprehensively evaluate the trained and optimized prediction model. By inputting the test set into the adjusted best model, calculate the deviation between the model prediction value and the actual observed value (according to Formulas (20), (21), and (22)), and comprehensively evaluate the accuracy and reliability of the model from multiple dimensions, specifically referring to the following evaluation metrics. At the same time, evaluate the generalization ability of the model according to the validation set to ensure the effectiveness and stability of the model in actual application scenarios. Specifically, see the accuracy graph in Figure 6(b), where the horizontal axis represents the number of training iterations and the vertical axis represents the accuracy value. The accuracy of the validation set gradually increases and tends to be stable as the model gradually learns features. The final performance of the accuracy graph directly reflects the effect of the model in the classification task.
[0183] The performance metrics used in this step are:
[0184] Accuracy curve, the proportion of the number of correctly predicted samples in the predicted samples to the total number of all samples:
[0185]
[0186] TP: True positive, the number of positive examples correctly predicted by the model. TN: True negative, the number of negative examples correctly predicted by the model. FP: False positive, the number of positive examples wrongly predicted by the model. FN: False negative, the number of negative examples wrongly predicted by the model.
[0187] Loss value curve, showing the change of the value of the loss function:
[0188]
[0189] Among them, N represents the number of samples, y i is the true label, is the predicted label.
[0190] Mean Absolute Error (MAE)
[0191]
[0192] Among them, Φ represents the number of samples, is the predicted value of the sample, and Y is the true value.
[0193] Mean Absolute Percentage Error (MAPE)
[0194]
[0195] Among them, represents the predicted value of the sample, represents the actual value of the sample
[0196] Root Mean Square Error (RMSE)
[0197]
[0198] Among them, represents the predicted value of the sample, represents the actual value of the sample.
[0199] Table 3 Performance indicators of the prediction model of the present invention.
[0200]
[0201] Compared with the traditional LSTM network model, the MAPE of the network model of the present invention is reduced from 10.47% to 9.44% (an increase of about 9.8%), the RMSE is reduced from 0.3869 to 0.2488 (an increase of about 35.7%), and the MAE is reduced from 0.1641 to 0.1242 (an increase of about 24.3%).
[0202] The present invention introduces a differential evolution strategy and realizes a method for self - adapting and dynamically updating the positions of grey wolves to enrich the richness of the population of the grey wolf optimization algorithm. Since the traditional grey wolf optimization algorithm initializes the population randomly, the probability of finding the optimal solution is uncontrollable. By optimizing the position update of grey wolves each time, the global search ability of the grey wolf algorithm and the local search ability of the differential evolution algorithm can be fully utilized, so as to achieve a better balance in the optimization process. This combined method can help the algorithm better explore the search space, avoid falling into local optimal solutions, and improve the convergence speed and performance of the algorithm.
Claims
1. A method for classifying electrocardiogram signals by hybrid differential evolution and improved grey wolf optimization algorithm, characterized in that: Specifically, it includes the following steps: Step 1, establish an electrocardiogram mixed dataset; Step 2, preprocess the dataset established in Step 1 to obtain a one-dimensional flattened array; Step 3, use wavelet transform on the one-dimensional flattened array obtained in Step 2 for decomposition; Step 4, perform denoising processing on the wavelet decomposition result obtained in Step 3 by calculating the threshold; Step 5, perform label data partitioning and format processing on the electrocardiogram feature dataset after denoising in Step 4; Step 6, optimize the grey wolf algorithm; Step 7, construct an LSTM network model according to the optimization result in Step 6; Step 8, train and evaluate the LSTM network model constructed in Step 7.
2. The electrocardiogram signal classification method using the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 1, characterized in that: The specific process of Step 1 is as follows: Step 1.1, take the self-collected electrocardiogram signals as the self-collected dataset and name the self-collected dataset A; Step 1.2, download the MIT-BIH Arrhythmia Dataset from the public database and name this dataset B; Step 1.3, downsample the self-collected data A to make the data sampling frequency consistent with the sampling frequency of the MIT-BIH Arrhythmia Dataset, and unify the digital format by unit conversion and data alignment of dataset A and dataset B; Step 1.4, integrate the annotation systems in dataset A and dataset B to ensure the annotation consistency of all data; Step 1.5, respectively extract the electrocardiogram activity point data marked with key features from the unified data A and dataset B in Step 1.4, and fuse the feature point information and label information in the two obtained datasets A and B to construct a new mixed dataset C.
3. The electrocardiogram signal classification method using the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 2, characterized in that: The specific process of Step 2 is as follows: Read the dataset C obtained in Step 1.5 through the wfdb library of the WaveformDatabase toolkit, and use the flatten method in the numpy library to flatten the signals of each lead in the record into a one-dimensional array, that is, the one-dimensional dataset C.
4. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 3, characterized in that: The specific process of Step 3 is as follows: Decompose the dataset C into approximation coefficients cA1 and detail coefficients cD1; further decompose the approximation coefficient cA1 to obtain new approximation coefficients cA2 and detail coefficients cD2; in each subsequent filtering, recursively decompose the approximation coefficients of the current layer to generate the approximation coefficients cA of the next layer n+1 and the detail coefficients cD of the next layer n+1 , and so on for decomposition, finally obtaining the detail coefficients of each layer from cD1 to cD9 and cA1 to cA9; the decomposition formula is as follows: Among them, r represents the index of the sampling point at the current time point or in the signal, k represents the index of the filter coefficient, n represents the number of layers of wavelet decomposition or the number of iterations, g[k] and h[k] are the filtering coefficients of the low-pass and high-pass filters respectively, and cA n is the approximation coefficient of the nth layer, and cD n is the detail coefficient of the nth layer.
5. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 4, characterized in that: The specific process of Step 4 is as follows: Step 4.1, calculate the threshold for each layer of detail coefficients obtained by wavelet decomposition in Step 3, and the calculation formula is as follows: Among them, m is the length of the signal, usually the number of sampling points in the electrocardiogram signal, median(|cD1|) is the median of the absolute value of the first layer of detail coefficients cD1, and threshold is the final threshold obtained by calculation; Step 4.2, use the threshold threshold calculated in Step 4.1 to perform soft threshold processing on the detail coefficients cD1 to cD9 generated by each layer of wavelet decomposition obtained in Step 3 in turn, and the specific formula is as follows Among them, threshold is the threshold calculated in step 4.1, and w is the coefficient set containing cA1 to cA obtained by wavelet decomposition in step 3 n and the approximation coefficients cD of the last layer n ; Step 4.3, perform wavelet inverse transform reconstruction on the detail coefficients of each layer from cD1 to cD9 after denoising in Step 4.2, overlap and accumulate the signal parts reconstructed from the coefficients of different frequency bands according to the following formula (5), and use the inverse wavelet transform to combine the approximation coefficients cA n and the detail coefficients cD n to obtain the approximation coefficient cA of the upper layer through the inverse transform formula n-1 . The specific formula is as follows where cA n and cD n are the approximation coefficients of the n-th layer, and h[k] are the coefficients of the reconstruction filter; Step 4.4, let n = 9. Starting from the 9th layer, combine the approximation coefficient cA9 and the detail coefficient cD9 of the 9th layer, and generate the signal of the 8th layer through the above formula (5); then continue to reconstruct the generated signal of the 8th layer with the detail coefficient cD8 of the 8th layer to obtain the signal of the 7th layer, and proceed layer by layer forward until the detail coefficient cD1 and the signal of the 1st layer are completely reconstructed through the inverse wavelet transform by formula (5); after the inverse transform reconstruction, all the detail coefficients cD n and the approximation coefficient cA n are combined layer by layer, and finally the denoised electrocardiogram feature dataset D is obtained.
6. The electrocardiogram signal classification method combining differential evolution and improved grey wolf optimization algorithm according to claim 5, wherein: The specific process of Step 5 is as follows: Step 5.1, obtain the waveform positions with the feature label R in the electrocardiogram feature dataset D after denoising in Step 4. Based on the R-wave position information, sample 100 electrocardiogram records before the R wave and 200 electrocardiogram records after the R wave, and form an electrocardiogram signal group with 300 electrocardiogram signal points as a data group; Step 5.2, create a dataSet data array and a labelSet label array; Step 5.3, through iteration, extract the electrocardiogram signal group data and the corresponding feature labels of each different subject from the denoised electrocardiogram feature data set D according to Step 5.1, store the electrocardiogram record signal group into the dataSet data array in Step 5.2, and the corresponding feature labels will be in the labelSet label array; Step 5.4, use the np.array method to convert the dataSet and labelSet arrays created in Step 5.3 into NumPy arrays, and then reshape the dataSet array and the labelSet array respectively through the reshape method. Each sample in the dataSet array is reshaped into a one-dimensional array with 300 features, and labelSet is a one-dimensional array of single labels; Step 5.5, horizontally merge the one-dimensional dataSet data array and the one-dimensional labelSet label array obtained in Step 5.
4. After merging, each row represents a sample, and each row contains two columns, which are the electrocardiogram feature data and the feature label respectively, thus forming a two-dimensional array containing complete sample information; Step 5.6, divide the two-dimensional array y obtained in Step 5.5 into a training set, a test set and a validation set in a ratio of 6:2:
2. At the same time, divide the two-dimensional array y into small batches of a unified fixed size, and each batch is a two-dimensional array data containing 128 data features therein.
7. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 6, characterized in that: The specific process of Step 6 is as follows: Step 6.1, introduce the combination of the hybrid differential evolution algorithm and the grey wolf optimization algorithm, and introduce the attraction factor with ρ(t) and the adaptive parameter p rw Dynamically optimize the position update method of grey wolf optimization. According to the hierarchical relationship among the α, β, and δ wolves, update the α, β, and δ wolves respectively; Step 6.2, according to the updated result of Step 6.1, introduce the differential evolution strategy and the cross adjustment strategy, the number of iteration times U and the number of hidden layers L.
8. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 7, characterized in that: The specific process of Step 6.1 is as follows: Step 6.1.1, set three leading wolves in the wolf pack: α wolf, β wolf, δ wolf; Step 6.1.2, initialize the convergence curve with np.zeros; Step 6.1.3, initialize the positions of α, β, and δ gray wolves to [0,0]; Step 6.1.4, perform position updates on the α wolf, β wolf, and δ wolf.
9. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 8, characterized in that: The specific process of Step 6.1.4 is as follows: The position update criterion for the δ wolf is as follows: During the movement of the δ wolf, the δ wolf updates its position according to the leadership of the α wolf and the β wolf, and dynamically adjusts the position through the non-linear adjustment factor ρ(t). The update formula is as follows: position, and the update formula is as follows: Among them, ρ(t) represents the generated smooth transition value, is the parameter controlling the growth rate, t0 is the parameter determining the center position of the function, t is the current iteration number, is the current position of different reference individuals in the population, is the obtained position update value; The position update criterion for the β wolf is as follows: Use the following formula for update: where a0 is the initial weight, λ is the decay factor, t is the current iteration number, ∈·N(0,1) is the random perturbation generated by the normal distribution, represents the position of the β wolf in the next iteration, represents the positions of the α and β individuals in the t-th generation, is the position set of the population, and mean and std represent the standard deviation and the mean respectively; The position update criterion for the α wolf is as follows: calculate the random walk probability, calculate the random walk probability according to the fitness of the α wolf, and use the following update formula: Among them, represents the position offset of the current optimal individual α, is the adjustment factor, represents the absolute difference between the optimal individual position and the population average position; p rw represents the probability of random walk, ρ min and p max represent the minimum probability and the maximum probability of random walk respectively, f min and f max represent the minimum fitness value and the maximum fitness value among all wolves respectively; represents the position of the optimal individual in the current generation t, represents the position of the optimal individual in the next generation (t + 1).
10. The electrocardiogram signal classification method based on the hybrid differential evolution and improved grey wolf optimization algorithm according to claim 9, characterized in that: The specific process of Step 6.2 is as follows: Step 6.2.1, calculate N through the following formula (14). N is the average of the squares of the position deviations of all individuals in each dimension from the average value, and is used to represent the dispersion degree of the population in the solution space: where a is the number of grey wolves in the population, d is the feature dimension of each individual, and X i,j is the position of the i-th individual in the j-th dimension, and is the average position of all individuals in the j-th dimension; Step 6.2.2, Selection operation: Assume that the parent gray wolves x1 and x2 are randomly selected, and their positions are x1 = (x 1,1,1 ; x 1,1,2 ) and x2 = (x 2,1,1 ; x 2,1,2 ); where x 1,1,1 represents the first component of the first dimension of the first parent gray wolf, and x 1,1,2 represents the second component of the first dimension of the first parent gray wolf; Step 6.2.3, cross-update operation: select a crossover probability CR to determine whether to perform a crossover operation. Assume that the total dimension of the gray wolf individual is D, and j is a certain dimension in D. Generate a random number rand() ∈ [0,1], and perform the following crossover on dimension j: where rand is a random number, CR is the crossover probability, U i,j is the j-th dimensional value of the offspring individual generated after crossover, X 1,j is the value of the first parent in the j-th dimension, X 2,j is the value of the second parent in the j-th dimension; Step 6.2.4, compare the new individual generated by the crossover operation in Step 6.2.3 with the original individual, and select the new individual according to the step result; Step 6.2.5, adjust the crossover probability CR: The crossover probability depends on the comparison between the diversity and a certain set target value N, and dynamically adjusts the crossover probability CR in Step 6.2.
3. The specific formula is as follows: target and specifically adjusts the crossover probability CR in Step 6.2.3 according to the following formula: CR(t + 1)=CR(t)+y(tanh(N - N target )) (15) Among them, CR(t) is the crossover probability of the current iteration, and y is the adjustment rate; Step 6.2.6, check whether the current population update round b reaches the set maximum value. If it is satisfied, terminate the update. Otherwise, return to Step 6.1.4 for cycling, select the individual with the best performance evaluation finally, and use the corresponding iteration number U and the number of hidden layers L as the final parameters of the LSTM in Step 7.