Sensor drift correction method and system based on transfer learning
The transfer learning method corrects sensor drift, which solves the problem of gas sensor accuracy degradation caused by sensor drift, and improves the accuracy of lung cancer detection.
Patent Information
- Application Number
- CN202411646649.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2044-11-18
AI Technical Summary
Sensor drift leads to a decrease in accuracy and reliability of gas sensors in lung cancer detection, and the accuracy and stability of existing domain adaptive methods are insufficient.
Using a transfer learning-based method, by collecting sensor response data from healthy individuals and lung cancer patients, building source domain and target domain data sets, performing feature extraction and domain adaptation, using the transformation matrix P for data correction, maximizing cross-domain category information and minimizing distribution distance, and updating pseudo-labels to achieve drift correction.
Effectively correct sensor drift, improve the classification accuracy of gas sensors in intelligent lung cancer detection, and ensure that the data is suitable for machine learning algorithms.
Smart Images

Figure CN119598254B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of gas sensors, and in particular to a sensor drift correction method and system based on transfer learning. Background Art
[0002] The odor detection system is an artificial olfactory system inspired by the biological nasal organ, designed to identify various odors and volatile organic compounds (VOCs). Lung cancer is one of the most deadly cancers worldwide. Despite continuous improvements in treatment methods, its prognosis is poor, and detection methods are invasive and harmful to the human body. The application of odor detection systems in lung cancer screening, prevention, and regular testing is of great significance. However, there are still some problems to be solved to achieve accurate odor detection and identification. Among them, the sensor array, as a key component of this technology, inevitably has drift problems, making it difficult for the algorithm to make accurate medical decisions.
[0003] Sensor drift is a common problem that can degrade gas sensor performance and affect system accuracy and reliability. Drift is typically caused by environmental factors such as sensor aging, poisoning, and temperature and humidity fluctuations. This can distort distributions, increase data uncertainty, and reduce performance. In the field of biomimetic olfaction, sensor drift causes the response of sensor arrays to exhibit nonlinear dynamic changes. Consequently, gas sensors do not always respond identically to the same type of gas. Currently, domain adaptation methods can correct for this drift, but directly applying these methods to intelligent lung cancer detection still lacks accuracy and stability. Summary of the Invention
[0004] The present invention provides a sensor drift correction method and system based on transfer learning, which solves the technical problem of how to correct drifted sensor data.
[0005] To solve the above technical problems, the present invention first provides a sensor drift correction method based on transfer learning, comprising the following steps:
[0006] S1. Collect sensor response data from healthy individuals and lung cancer patients at two different time periods, and use the labeled early data as the source domain dataset and the unlabeled late data as the target domain dataset.
[0007] S2. Perform feature extraction on the source domain dataset and the target domain dataset using the same preprocessing process to obtain a source domain data feature set and a target domain data feature set;
[0008] S3. Based on transfer learning, the source domain data feature set is used to perform domain adaptation on the target domain data feature set to obtain a drift-corrected target domain data feature set;
[0009] The step S3 specifically includes the following steps:
[0010] S31, minimizing the joint distribution distance between the target domain data feature set and the source domain data feature set after projection mapping, maximizing the difference between different categories of the target domain data feature set and the source domain data feature set, and retaining category information for classification as a goal, obtaining a functional relationship for obtaining a transformation matrix P;
[0011] S32. Calculating known parameters in the functional relationship based on the target domain data feature set and the source domain data feature set;
[0012] S33, based on the known parameters, solving the functional relationship to obtain an initial transformation matrix P0;
[0013] S34, calculating a new target domain data feature set and a new source domain data feature set based on the initial transformation matrix P0;
[0014] S35, training a classifier using the new source domain data feature set, and predicting the classifier using the new target domain data feature set to obtain a pseudo label of the new target domain data feature set;
[0015] S36, updating the pseudo-label of the target domain data feature set, updating the known parameters related to the pseudo-label in the functional relationship, and returning to step S33;
[0016] S37, repeat steps S33 to S36 until the number of iterations is reached, and output the current transformation matrix P t As the optimal transformation matrix P, output the current classifier f;
[0017] S38. Based on the optimal transformation matrix P and the target domain data feature set, obtain the target domain data feature set after drift correction.
[0018] Furthermore, in step S32, the functional relationship is: Where Z is the total feature data set including the target domain data feature set and the source domain data feature set, W c is the maximum mean difference matrix of the conditional probabilities between the source domain feature dataset and the target domain feature dataset after domain adaptation, c=0 corresponds to the case when the label class is not distinguished, c=1,2,…,C represents the c-th class label, C represents the label type, K represents the joint probability matrix between the source domain feature dataset and the target domain feature dataset after domain adaptation, φ is the Lagrange multiplier, α is the measurement parameter of the category information, and I is the unit matrix.
[0019] Furthermore, the step S31 specifically includes the following steps:
[0020] Calculate the source domain feature dataset D s and target domain feature dataset D t The marginal difference d between m (D s ,D t )=Tr(P T ZW0Z T P), W0 is D s With D t The maximum mean difference matrix between them, the superscript T indicates matrix transposition, and Tr() indicates matrix trace;
[0021] Calculate the source domain feature dataset D s and target domain feature dataset D t The conditional distribution difference between W c D s With D t The maximum mean difference matrix of conditional probabilities between ;
[0022] d m (D s ,D t ) and d c (D s ,D t ) add them together to get D s With D t The difference in joint probability distribution between When c=0, the labels are not distinguished, and the difference between the overall sample means of the source domain and the target domain is calculated;
[0023] Based on the Bayesian formula Expand and get d(D s ,D t )=M T +M D , M T is a matrix that measures the transferability of the same category across domains, M D =Tr(P T ZKZ T P) is a matrix that measures the discriminability between different categories in different domains;
[0024] An objective function is constructed with the goal of minimizing the joint distribution distance between the target domain data feature set and the source domain data feature set after projection mapping, maximizing the difference between different categories of the target domain data feature set and the source domain data feature set, and retaining category information for classification;
[0025] The objective function is solved to obtain the functional relationship.
[0026] Furthermore, the objective function is constructed as follows: T ZHZ T Under the condition of P=I, we can get The minimum transformation matrix P.
[0027] Furthermore, solving the objective function comprises the steps of:
[0028] Solving the objective function using the Lagrangian method to obtain a Lagrangian function;
[0029] The Lagrangian function is differentiated with respect to the transformation matrix P to obtain the functional relationship.
[0030] Furthermore, in step S1, the collected sensor response data includes 6 experimental stages P1-P6, namely, air baseline collection stage, helium baseline collection stage, pre-concentration stage, thermal desorption stage, sampling stage and cleaning stage. In stage P1, the filtered air enters the system at a higher flow rate; in stage P2, helium is blown into the system at high speed as the carrier gas; in stage P3, the sample gas is blown into the adsorption tube at high speed, and the gas outside the adsorption range of the adsorption tube responds; in stage P4, the gas adsorbed by the adsorption tube in stage P3 is desorbed; in stage P5, helium is purged from the system at a low speed in the opposite direction, and the gas desorbed from the adsorption tube is blown out and sent into the gas chamber to react with the sensor. At this time, the gas that responds is the gas adsorbed by the adsorption tube in stage P3; and in stage P6, the entire gas path is cleaned.
[0031] Furthermore, in step S2, the pre-processing process includes:
[0032] Each response data of each sensor is filtered using an N-order mean filter;
[0033] Extract the response data of each sensor at stages P1, P2, P3, and P5;
[0034] The response data of the P1 stage is used as the baseline of the response data of the P3 stage, and the first-category features and the second-category features of the two stages are extracted;
[0035] The response data of the P2 stage is used as the baseline of the response data of the P5 stage, and the first-category features and second-category features of the two stages are extracted;
[0036] Normalizing the first-category features and the second-category features of the P1 stage and the P3 stage to obtain first-category normalized features of the response data of the sensor;
[0037] The first-category features and the second-category features of the P2 stage and the P5 stage are normalized to obtain the second-category normalized features of the response data of the sensor.
[0038] Furthermore, the process of filtering with an N-order mean filter is as follows: the filtered value of the j-th sensor at the i-th sampling point in the d-th sample Equal to the response value of the jth sensor at the i-th sampling point in the d-th sample of the original data set and the sum of the following (N-1) response values (i.e. ) minus the maximum value of these N response values (i.e. ) minus the minimum value of these N response values (i.e. ) and then divide the difference by (N-2);
[0039] The first-category feature of the P1 and P3 stages is: the mean value of the P3 stage minus the mean value of the P1 stage. The first-category feature of the P1 and P3 stages is: the median value of the response of the P3 stage minus the mean value of the P1 stage.
[0040] The first category feature of the P2 and P5 stages is: the average value of the P5 stage minus the average value of the P2 stage. The first category feature of the P2 and P5 stages is: the second category feature is: the median response of the P5 stage minus the average value of the P2 stage.
[0041] Furthermore, the process of normalizing the first-category features and the second-category features in the P1 and P3 stages is formulated as follows: is the corresponding normalized feature representation, f d,j,1 ,f d,j,2 are the first and second features of the P1 and P3 phases of the j-th response data of the d-th sensor, respectively. β is the weight factor. and σ1,σ2 are f d,j,1 ,f d,j,2 The mean and standard deviation of
[0042] The process of normalizing the first and second category features of the P2 and P5 stages is formulated as follows: is the corresponding normalized feature representation, f d,j,3 ,f d,j,4 are the first and second features of the P2 and P5 phases of the j-th response data of the d-th sensor, respectively. and σ3,σ4 are f d,j,3 ,f d,j,4 The mean and standard deviation of .
[0043] The present invention also provides an intelligent lung cancer detection system, the key of which is that it includes an exhaled breath detection system and a sensor drift correction module. The exhaled breath detection system is used to perform steps S1 and S2 in the sensor drift correction method based on transfer learning, and the sensor drift correction module is used to perform step S3. The sensor drift correction module is also used to use the classifier f and the optimal transformation matrix P to predict the input exhaled breath feature data of the lung cancer patient, and output the pseudo label corresponding to the exhaled breath feature data of the lung cancer patient as the lung cancer detection result.
[0044] It should also be noted that the sensor drift correction method and system based on transfer learning provided by the present invention can also be used in other gas sensor intelligent detection applications besides lung cancer detection.
[0045] The present invention provides a sensor drift correction method and system based on transfer learning. The method first collects sensor response data from healthy individuals and lung cancer patients at two different time periods, and uses the labeled early data as the source domain data set and the unlabeled later data as the target domain data set. The data is then preprocessed to extract features to obtain a source domain data feature set and a target domain data feature set. Finally, the target domain data feature set is domain-adapted based on transfer learning to obtain a drift-corrected target domain data feature set. The present invention corrects drift by minimizing the distance between the marginal distribution and the conditional distribution and forcing the maximization of cross-domain category information, and preprocesses the original data set to extract a small number of representative features to highly represent the original data, ensuring that the data can be effectively used by machine learning algorithms. Experimental results show that the present invention can effectively correct sensor drift and achieve high classification accuracy in intelligent detection based on gas sensors, such as intelligent detection of lung cancer. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 is a flow chart of a sensor drift correction method based on transfer learning provided by an embodiment of the present invention;
[0047] Figure 2 2 is a schematic diagram of the gas sampling phase of the breath detection system provided by an embodiment of the present invention;
[0048] Figure 3 is a schematic diagram of a sensor array provided by an embodiment of the present invention;
[0049] Figure 4 is an example diagram of a response curve of a sensor array provided by an embodiment of the present invention;
[0050] Figure 5 is a visualization image of the data before and after drift correction provided by an embodiment of the present invention;
[0051] Figure 6This is the confusion matrix provided by an embodiment of the present invention when predicting the response data of the first four sensors. DETAILED DESCRIPTION
[0052] The following describes the embodiments of the present invention in detail with reference to the accompanying drawings. The embodiments are provided for illustrative purposes only and are not to be construed as limiting the present invention. The accompanying drawings are provided for reference and illustration only and do not constitute a limitation on the scope of protection of the present invention. Many changes may be made to the present invention without departing from the spirit and scope of the present invention.
[0053] The sensor drift correction method based on transfer learning provided by the embodiment of the present invention is as follows: Figure 1 As shown, the steps include:
[0054] S1. Collect sensor response data from healthy individuals and lung cancer patients at two different time periods, and use the labeled early data as the source domain dataset and the unlabeled late data as the target domain dataset.
[0055] S2. Use the same preprocessing process to extract features from the source domain dataset and the target domain dataset to obtain the source domain data feature set and the target domain data feature set;
[0056] S3. Based on transfer learning, the source domain data feature set is used to perform domain adaptation on the target domain data feature set to obtain the drift-corrected target domain data feature set.
[0057] Wherein, step S3 specifically includes the steps of:
[0058] S31, minimizing the joint distribution distance between the target domain data feature set and the source domain data feature set after projection mapping, maximizing the difference between different categories of the target domain data feature set and the source domain data feature set, and retaining category information for classification, to obtain a functional relationship for obtaining the transformation matrix P;
[0059] S32. Calculating known parameters in the functional relationship based on the target domain data feature set and the source domain data feature set;
[0060] S33, based on the known parameters, solve the function relationship to obtain the initial transformation matrix P0;
[0061] S34, calculating a new target domain data feature set and a new source domain data feature set based on the initial transformation matrix P0;
[0062] S35. Using the new source domain data feature set to train a classifier, and using the new target domain data feature set to predict the classifier, to obtain a pseudo label of the new target domain data feature set;
[0063] S36, updating the pseudo-labels of the target domain data feature set, updating the known parameters related to the pseudo-labels in the functional relationship, and returning to step S33;
[0064] S37, repeat steps S33 to S36 until the number of iterations is reached, and output the current transformation matrix P t As the optimal transformation matrix P, output the current classifier f;
[0065] S38. Based on the optimal transformation matrix P and the target domain data feature set, obtain the target domain data feature set after drift correction.
[0066] Based on the above-mentioned transfer learning-based sensor drift correction method, the present invention also provides an intelligent lung cancer detection system, which includes an exhaled breath detection system and a sensor drift correction module. The exhaled breath detection system is used to perform steps S1 and S2 in the transfer learning-based sensor drift correction method, and the sensor drift correction module is used to perform step S3. The sensor drift correction module is also used to use the classifier f and the optimal transformation matrix P to predict the input exhaled breath feature data of the lung cancer patient, and output a pseudo-label corresponding to the exhaled breath feature data of the lung cancer patient as a lung cancer detection result.
[0067] First, in order to effectively collect odor data from lung cancer patients and healthy individuals in the method and system, this embodiment designs an exhaled breath detection system, which mainly includes a gas collection component, a pre-enrichment component, a detection and identification component, and a host computer. It can realize automatic gas sampling, concentration and enrichment of exhaled gas, odor signal conversion, preliminary signal processing and transmission, and overall component control.
[0068] The gas collection assembly primarily consists of a PTFE tube, a mass flow controller (MFC), an air pump, a three-way valve, and a five-way valve. The negative pressure generated by the air pump draws the gas under test through the PTFE tube into the detection and identification assembly, achieving automatic sampling. Sampling at different stages is achieved through the interface switching between the three-way valve and the five-way valve, controlled by a host computer.
[0069] The pre-enrichment component consists of a heating device unit (including an adsorption tube, a temperature sensor, a heating tube), a PID (proportional integral differential) temperature controller, and a computer control unit.
[0070] The sensor array, comprised of gas sensors, is the core component of the detection and recognition system. It improves the sensor's minimum detection limit, enabling detection of even low concentrations of VOCs in exhaled breath. The composition of the sensor array influences the system's ultimate recognition and detection performance. To isolate the sensor array from external gases, a gas chamber covers the sensor array. Gas is delivered to the inlet chamber to react with the sensor array.
[0071] The host computer is mainly used for odor signal conversion, preliminary signal processing and transmission.
[0072] Gas sampling of breath detection system can be divided into Figure 2 The six experimental stages P1-P6 shown are respectively the air baseline collection stage (P1), the helium baseline collection stage (P2), the pre-concentration stage (P3), the thermal desorption stage (P4), the sampling stage (P5) and the cleaning stage (P6). The specific operating procedures and principles of each stage of the entire experiment are as follows:
[0073] P1: Filtered air enters the system at a higher flow rate;
[0074] P2: Helium is blown into the system at high speed as carrier gas;
[0075] P3: The sample gas is blown into the adsorption tube at high speed. Gas with a carbon content within the adsorption range of the adsorption tube is adsorbed by the tube. The remaining gas not adsorbed by the adsorption tube enters the gas chamber and reacts with the sensor, generating a response in this stage. That is, the response gas generated in this stage is gas outside the adsorption range of the adsorption tube.
[0076] P4: In this stage, the system is heated to 270°C. The main purpose is to desorb the gas adsorbed by the adsorption tube in the P3 stage, so that the VOCs in it can be separated from the adsorption tube for the next stage of reaction.
[0077] P5: Helium is purged from the system at a low speed in the opposite direction for 6 minutes, blowing out the gas desorbed from the adsorption tube and sending it into the gas chamber to react with the sensor. The gas that responds at this time is the gas adsorbed by the adsorption tube in the P3 stage.
[0078] P6: Turn off the heating system, turn on the fan, and purge the sensor array with filtered air until the system temperature drops to room temperature. This stage cleans the entire gas path and ensures the system is ready for the next gas experiment.
[0079] The sensor array used in this embodiment is as follows Figure 3 As shown in Figure 1, part of the sensors are metal oxide sensors and part of the sensors are electrochemical sensors. Figure 4 As shown, it can be seen that different sensors have different overall response characteristics, and sensors at the same stage also have different performances.
[0080] Next, data preprocessing is performed.
[0081] The breath experiment data is saved in the a.txt file format, which contains the voltage value (mV) of each sensor at each sampling point throughout the entire experiment. The dimension of the data collected by each sensor is the product of the number of sampling points and the number of sensors. This is a high-dimensional time series matrix, with each sensor having hundreds or thousands of sampling points. Directly using it in a machine learning algorithm would be computationally prohibitive. Therefore, it is necessary to preprocess the raw data to extract a small number of representative features to provide a high-level representation of the raw data and ensure that the data can be effectively used by the machine learning algorithm. The preprocessing process includes steps such as filtering, feature extraction, and normalization.
[0082] In order to clearly express the data preprocessing process, the original data set is defined as Where D is the total number of odor data, and each time through the six experimental stages P1-P6, all the sensor data collected is one odor data, Z d and c d Represent the d-th odor data and its corresponding class label respectively. Where m is the number of sampling points, n is the number of sensors in the sensor array, that is, each odor data includes m×n sampling voltage values, forming an m×n dimensional voltage value array, where This represents the voltage value of the jth sensor at the i-th sampling point for the d-th odor data (the element in the i-th row and j-th column of the voltage value array). In the experimental design, D = 278, m = 3990, and n = 19. The dataset used in this paper is exhaled breath data collected from healthy individuals and lung cancer patients at different times.
[0083] During normal sensor operation, glitches, oscillations, or fluctuations often appear in the signal due to factors such as electromagnetic interference, noise, and ripple voltage in the circuit. Therefore, before extracting features, it is necessary to filter the response signal. For each sensor response in a single odor data set, an N-order (15-order in this example) mean filter was designed and implemented to reduce the noise introduced during the entire data collection process.
[0084] The filtering process is expressed as:
[0085]
[0086] in, is the filtered value of the jth sensor at the i-th sampling point in the d-th sample, is the response value of the jth sensor at the i-th sampling point in the d-th sample of the original data set, N is the order of the filtering equation, max{} represents the maximum value within {}, and min{} represents the minimum value within {}. The filtering process can be interpreted as: the filtered value of the jth sensor at the i-th sampling point in the d-th sample Equal to the response value of the jth sensor at the i-th sampling point in the d-th sample of the original data set and the sum of the following (N-1) response values (i.e. ) minus the maximum value of these N response values (i.e. ) minus the minimum value of these N response values (i.e. ) and then divide the difference by (N-2).
[0087] Next, a small number of representative features are extracted to characterize the raw data. Two features are selected for each sensor, namely: (1) average value; (2) median value. Let F be the feature matrix obtained after feature extraction, and the feature elements contained are expressed as (f d,j,k ) D×n (d = 1, ..., D, j = 1, ..., n, k = 1, 2), where d represents the dth sample, D is the total number of samples, j represents the jth sensor, n represents the total number of sensors, and k is the kth feature extracted. For each of the two selected features, it is necessary to subtract the stable value of the baseline phase during the corresponding extraction process.
[0088] In the feature extraction of this example, since the experimental design is a multi-stage mode, each experimental data contains 6 stages, but only a part of them is used for feature extraction. For each experimental data sample, the stages used for feature extraction are P1, P2, P3 and P5 respectively. Among them, the P1 baseline stage is used as the baseline of the P3 stage, and the P2 gas baseline stage is used as the baseline of the P5 stage. Here, P3 and P1 are called a group of stages, and P5 and P2 are called a group of stages. For each experimental sample data, two groups of experimental stage features are extracted. The first and second types of features extracted from the pre-concentration stage (P3) using the P1 stage as the baseline are expressed as:
[0089]
[0090] Among them, z avg,P3 is the average value of the P3 stage, z mid,P3 is the median response value of the P3 stage, z base,P1 is the average value of stage P1. Similarly, taking stage P2 as the baseline, the first and second category features extracted from stage P5 are expressed as:
[0091]
[0092] Among them, z avg,P5 is the average value of P5 stage, z mid,P5 is the median response value of P5 stage, z base,P2 is the average value of the P2 stage.
[0093] After feature extraction, each experimental data generates 4×19-dimensional feature data, and a feature matrix F with lower data dimension is obtained. The vectorized representation of the feature is:
[0094]
[0095] Among them, F1 and F2 are the vectorized representations of the features extracted in the P3 and P5 stages, and the upper right subscript T represents the matrix transpose.
[0096] Through this transformation, the multiple features extracted from the sensor signal can be converted into a one-to-one correspondence between the feature vector and the sensor. In the subsequent optimization process, the optimized sensor ranking will be directly obtained. The sensors in the sensor array are of various types, with different performances and significant differences in output signals. In order to eliminate the differences in the response data attributes between sensors and solve the problem of incomparable sensor data, a weighted modified "Z-score" normalization method is derived to standardize the data. Since the two features extracted at the same stage are vectorized, the two features of the P3 and P5 stages are uniformly normalized during the normalization process:
[0097]
[0098] in, are the normalized feature representations of the features extracted in stages P3 and P5, β is the weight factor, 0≤β≤1, and σ1, σ2, σ3, σ4 are f d,j,1 ,f d,j,2 ,f d,j,3 ,f d,j,4 After data preprocessing, common machine learning methods can be used for sensor drift correction and intelligent lung cancer detection.
[0099] This example uses data with a certain time span from the same breath detection system to study time drift. Table 1 shows the distribution of the dataset used in this example. The time of the breath test is divided into early experiments and late experiments. In transfer learning, data is usually divided into a source domain and a target domain. The source domain refers to the domain where labeled data or knowledge already exists, usually the domain of the training dataset or the domain of the training task. In the source domain, there is a large amount of labeled data or trained models that can be used to train learning tasks. The target domain is the domain where knowledge or models are transferred from the source domain to a new domain or task.
[0100] Table 1 Distribution of experimental sample categories in two different periods
[0101]
[0102] The target domain is usually the domain where practical problems need to be solved, but due to data scarcity and difficulty in labeling, it may not be possible to directly use traditional machine learning methods for training. In drift calibration, the source domain and target domain are usually divided according to whether the data drifts, that is, the source domain data is the data that has not drifted, and the target domain data is the data that has drifted. Samples in the later stages of the experiment have already produced varying degrees of drift, which is considered to be the target domain. Therefore, this embodiment proposes a joint domain adaptation method to overcome the differences caused by temporal drift.
[0103] Definition: Source Domain There are n s feature data, target domain There are n t Feature data, Z s 、Z t are the feature datasets of the source domain and the target domain respectively, L s is the label set of the source domain; Z s Including s eigenvectors, where the i-th eigenvector is represented by z s,i Similarly, Z t Including t eigenvectors, where the jth eigenvector is represented by z t,j ;L s Including C-type label, z s,i The corresponding label is represented as l s,i The target domain does not contain labels, but during the training process, since the training needs to output the labels of the target domain, it is assumed here that the feature space and label space of the two domains are the same. In domain adaptation, a transformation matrix P is defined to map the feature data to the regenerated Hilbert space (RHS), and the data distribution is aligned after the feature transformation. In terms of distribution, it is assumed that the marginal distribution and conditional distribution of the source domain and the target domain are different, that is, P(Z s )≠P(Z t ),P(L s ∣Z s )≠P(L t ∣Z t ), the joint distribution is also different: P(Z s ,L s )≠P(Z t ,L t ).
[0104] The design of domain adaptation methods can be considered from two aspects: minimizing the joint distribution distance after projection mapping, reducing the difference between domains, and achieving migration; maximizing the difference between different categories in the source domain and the target domain, and retaining category information for classification. Specifically, the measurement of distribution distance is based on the MMD (Maximum Mean Discrepancy) distance calculation. By minimizing the MMD distance design, the similarity and traction of the distribution can be achieved, so that the target domain distribution is closer to the source domain to achieve migration. For the preservation of cross-domain category information, the Bayesian formula is used to expand the representation of cross-domain information of different categories, and it is maximized when designing the optimization target.
[0105] First, for the migration operation, from the perspective of data distribution, the marginal distribution and conditional distribution between data are uniformly represented. The marginal distribution difference between the source domain and the target domain can be expressed as d m (D s ,D t ) and expands to:
[0106]
[0107] Z is inclusive of Z s 、Z t The total feature data set is , P is the transformation matrix, W0 is the MMD matrix, and Tr() represents the matrix trace. The element in the i-th row and j-th column of W0 is calculated according to the following rules:
[0108]
[0109] Among them, z i and z j They represent the i-th and j-th samples in the total feature dataset Z respectively.
[0110] The conditional distribution difference d between the source domain and the target domain c (D s ,D t ) is recorded as:
[0111]
[0112] in, Represent the number of c-th class samples in the source domain and target domain respectively, represents the c-th class samples of the source domain and the target domain, W represents the square of the Frobenius norm of the matrix, that is, the sum of the squares of all elements of the matrix. c is the MMD matrix of conditional probability, expressed as:
[0113]
[0114] By adding equation (6) and equation (8), we can get the expression of joint probability distribution difference:
[0115]
[0116] Here, c=0 corresponds to the case of formula (6), which calculates the difference between the overall sample means of the source domain and the target domain. c=1 to c=C represent the conditional distribution differences between different categories.
[0117] Next, we consider the maximum representation of category difference information. Based on the Bayesian formula, we expand Equation (10):
[0118]
[0119] in, They are the labels of the source domain data and the pseudo labels of the target domain data, respectively. Represents the label belonging to category c in the source domain data. Indicates that the target domain belongs to the class . is the target domain and the source domain (i.e. ) have labels of the same category. Represent the conditional probability distribution of the source domain and the target domain when the category c is given, It represents the difference in the joint probability distribution between the two conditional probability distributions of the source domain and the target domain. Represents the category in the target domain The conditional probability distribution of hour, represents the difference in joint probability distribution between different categories in the source domain and the target domain, M T is a matrix that measures the transferability of the same category across domains, M D is a matrix that measures the discriminability between different categories in different domains. Therefore, we obtain a representation of the category difference and constrain it to maximize it, M D It is stripped out of the formula as a subsequent optimization term to ensure that the category information is preserved to the greatest extent possible.
[0120] Next, we can get M D The expansion derivation of :
[0121] M D =Tr(P T ZKZ T P) (12)
[0122] The joint probability matrix Expressed as G s and G t One-Hot encoding is defined as: G s=[L s (:,1)×(C-1),...,L s (:,C)×(C-1)], L s (:,i) represents the i-th column of all rows of the source domain feature dataset, and ×(C-1) represents repetition (C-1) times. express hour All rows and columns 1 to C.
[0123] At this point, the cross-domain distribution distance and class differential have been expressed using the trace of the matrix. Combining Equations (9) and (12), adding regularization terms to prevent overfitting, we can construct an architecture with the minimum distribution distance. Considering the special case of minimization will lead to the global optimal solution P = 0, which is meaningless. To avoid this situation, the projection should also consider the data variance before and after the transformation, so as to maximize the data to maintain the original properties. Therefore, the constructed objective function can be expressed as:
[0124]
[0125] The objective function can be interpreted as: T ZHZ T Under the condition of P=I, we can get The minimum transformation matrix P, where λ represents the regularization coefficient and I represents the identity matrix, represents the square of the Frobenius norm.
[0126] Solve equation (13) using the Lagrangian method and obtain the Lagrangian function:
[0127]
[0128] Among them, φ is the Lagrange multiplier and α is the measurement parameter of category information.
[0129] Taking the derivative of L with respect to P, we get:
[0130]
[0131] By solving equation (15), the optimal transformation matrix P can be obtained.
[0132] The process of solving the optimal transformation matrix P includes the following steps:
[0133] According to the source domain and target domain feature data sets, construct the MMD matrices W0 and W c , construct the joint probability matrix K;
[0134] Based on W0, W c , K solves equation (15) and obtains the initial transformation matrix P0;
[0135] exist Train the classifier f on Predict the pseudo label in the target domain
[0136] Update the pseudo labels of the target domain feature dataset Update W c ;
[0137] Repeat the above steps until the number of iterations t is reached and output the current transformation matrix P t is the optimal transformation matrix P, and outputs the current classifier f.
[0138] During testing, classifier f outputs pseudo-labels corresponding to the input target domain data and the optimal transformation matrix P as the detection result. When applied to intelligent lung cancer detection, classifier f outputs pseudo-labels corresponding to the input lung cancer patient's breath feature data and the optimal transformation matrix P as the detection result.
[0139] The data used in the experiment consisted of breath samples collected from lung cancer patients and healthy individuals using a breathalyzer. Due to the long experimental time span, significant drift existed, affecting the validity of the data. The proposed transfer learning algorithm was used to correct the drift and to divide the data into source and target domains based on the chronological order of the experiments.
[0140] Figure 5 It is a visualization image of the data before and after drift correction, where (a) is the visualization of the original data, and (b) is the visualization image of the data after the drift correction process of the present invention. S-cancer, S-health, T-cancer, and T-health correspond to the source domain lung cancer sample, source domain healthy sample, target domain lung cancer sample, and target domain healthy sample, respectively. Figure 5 As can be seen from (a), there is a big difference between the distribution of target domain data and the distribution of source domain data. Some samples in the target domain are significantly different from the overall distribution, indicating that there is a large drift between the target domain data and the source domain data, and the drift is uncertain, which shows the necessity of using domain adaptation algorithms. Figure 5 As can be seen from (b), after the drift correction of the present invention is adopted, the difference between the distribution of the target domain data and the distribution of the source domain data is greatly reduced, which is beneficial to improving the classification accuracy of the target domain.
[0141] Since the accuracy is highest when the first four sensors are used, the classification method proposed in this invention is used to classify the features of these four sensors, and the following is obtained: Figure 6The confusion matrix shown in Figure 1 shows the number of correctly predicted samples on the main diagonal, while the number of incorrectly predicted samples on the subdiagonal represents the number of samples in each of the two classes. The resulting classification accuracy is 50 / 58 = 86.2%. Using all sensor data for classification, the accuracy is 79.31%.
[0142] It can be seen that the application of the sensor drift correction method and system based on transfer learning provided by the present invention can effectively correct sensor drift and achieve high classification accuracy in intelligent lung cancer detection. In summary, the embodiments of the present invention provide a sensor drift correction method and system based on transfer learning. The method first collects sensor response data from healthy individuals and lung cancer patients at two different time periods, and uses the labeled early data as the source domain dataset and the unlabeled later data as the target domain dataset. The data is then preprocessed to extract features to obtain source domain data feature sets and target domain data feature sets. Finally, domain adaptation is performed on the target domain data feature set based on transfer learning to obtain a drift-corrected target domain data feature set. The present invention performs drift correction by minimizing the distance between the marginal distribution and the conditional distribution and forcing the maximization of cross-domain category information. The original data set is preprocessed to extract a small number of representative features to provide high representation of the original data, ensuring that the data can be effectively used by machine learning algorithms. Experimental results show that the present invention can effectively correct sensor drift and achieve high classification accuracy in intelligent lung cancer detection.
[0143] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered as equivalent replacement methods and are included in the scope of protection of the present invention.
Claims
1. A sensor drift correction method based on transfer learning, characterized in that: Including steps: S1. Collect sensor response data from healthy individuals and lung cancer patients at two different time periods, and use the labeled early data as the source domain dataset and the unlabeled late data as the target domain dataset. S2. Perform feature extraction on the source domain dataset and the target domain dataset using the same preprocessing process to obtain a source domain data feature set and a target domain data feature set; S3. Based on transfer learning, the source domain data feature set is used to perform domain adaptation on the target domain data feature set to obtain a drift-corrected target domain data feature set; The step S3 specifically includes the following steps: S31, minimizing the joint distribution distance between the target domain data feature set and the source domain data feature set after projection mapping, maximizing the difference between different categories of the target domain data feature set and the source domain data feature set, and retaining category information for classification as a goal, obtaining a functional relationship for obtaining a transformation matrix P; S32. Calculating known parameters in the functional relationship based on the target domain data feature set and the source domain data feature set; S33, based on the known parameters, solving the functional relationship to obtain an initial transformation matrix P0; S34, calculating a new target domain data feature set and a new source domain data feature set based on the initial transformation matrix P0; S35, training a classifier using the new source domain data feature set, and predicting the classifier using the new target domain data feature set to obtain a pseudo label of the new target domain data feature set; S36, updating the pseudo-label of the target domain data feature set, updating the known parameters related to the pseudo-label in the functional relationship, and returning to step S33; S37, repeat steps S33 to S36 until the number of iterations is reached, and output the current transformation matrix P t As the optimal transformation matrix P, output the current classifier f; S38. Based on the optimal transformation matrix P and the target domain data feature set, obtain the target domain data feature set after drift correction.
2. The sensor drift correction method based on transfer learning according to claim 1, characterized in that: In step S32, the functional relationship is: Where Z is the total feature data set including the target domain data feature set and the source domain data feature set, W c is the maximum mean difference matrix of the conditional probabilities between the source domain feature dataset and the target domain feature dataset after domain adaptation, c=0 corresponds to the case when the label class is not distinguished, c=1,2,…,C represents the c-th class label, C represents the label type, K represents the joint probability matrix between the source domain feature dataset and the target domain feature dataset after domain adaptation, φ is the Lagrange multiplier, α is the measurement parameter of the category information, I is the identity matrix, and λ represents the regularization coefficient.
3. The sensor drift correction method based on transfer learning according to claim 2, characterized in that: The step S31 specifically includes the following steps: Calculate the source domain feature dataset D s and target domain feature dataset D t The marginal difference d between m (D s ,D t )=Tr(P T ZW0Z T P), W0 is D s With D t The maximum mean difference matrix between them, the superscript T indicates matrix transposition, and Tr() indicates matrix trace; Calculate the source domain feature dataset D s and target domain feature dataset D t The conditional distribution difference between W c D s With D t The maximum mean difference matrix of conditional probabilities between ; d m (D s ,D t ) and d c (D s ,D t ) add them together to get D s With D t The difference in joint probability distribution between When c=0, the labels are not distinguished, and the difference between the overall sample means of the source domain and the target domain is calculated; Based on the Bayesian formula Expand and get d(D s ,D t )=M T +M D , M T is a matrix that measures the transferability of the same category across domains, M D =Tr(P T ZKZ T P) is a matrix that measures the discriminability between different categories in different domains; An objective function is constructed with the goal of minimizing the joint distribution distance between the target domain data feature set and the source domain data feature set after projection mapping, maximizing the difference between different categories of the target domain data feature set and the source domain data feature set, and retaining category information for classification; The objective function is solved to obtain the functional relationship.
4. The sensor drift correction method based on transfer learning according to claim 3, characterized in that: The objective function is constructed as follows: T ZHZ T Under the condition of P=I, we can get The minimum transformation matrix P.
5. The sensor drift correction method based on transfer learning according to claim 4, characterized in that: Solving the objective function comprises the steps of: Solving the objective function using the Lagrangian method to obtain a Lagrangian function; The Lagrangian function is differentiated with respect to the transformation matrix P to obtain the functional relationship.
6. The sensor drift correction method based on transfer learning according to any one of claims 1 to 5, characterized in that: In step S1, the collected sensor response data includes 6 experimental stages P1-P6, namely, air baseline collection stage, helium baseline collection stage, pre-concentration stage, thermal desorption stage, sampling stage and cleaning stage. In stage P1, the filtered air enters the system at a higher flow rate; in stage P2, helium is blown into the system at high speed as a carrier gas; in stage P3, the sample gas is blown into the adsorption tube at high speed, and the gas outside the adsorption range of the adsorption tube responds; in stage P4, the gas adsorbed by the adsorption tube in stage P3 is desorbed; in stage P5, helium is purged from the system at a low speed in the opposite direction, and the gas desorbed from the adsorption tube is blown out and sent into the gas chamber to react with the sensor. At this time, the gas that responds is the gas adsorbed by the adsorption tube in stage P3; and in stage P6, the entire gas path is cleaned.
7. The sensor drift correction method based on transfer learning according to claim 6, characterized in that: In step S2, the pre-processing process includes: Each response data of each sensor is filtered using an N-order mean filter; Extract the response data of each sensor at stages P1, P2, P3, and P5; The response data of the P1 stage is used as the baseline of the response data of the P3 stage, and the first-category features and the second-category features of the two stages are extracted; The response data of the P2 stage is used as the baseline of the response data of the P5 stage, and the first-category features and second-category features of the two stages are extracted; Normalizing the first-category features and the second-category features of the P1 stage and the P3 stage to obtain first-category normalized features of the response data of the sensor; The first-category features and the second-category features of the P2 stage and the P5 stage are normalized to obtain the second-category normalized features of the response data of the sensor.
8. The sensor drift correction method based on transfer learning according to claim 7, characterized in that: The process of filtering with an N-order mean filter is as follows: the filtered value of the j-th sensor at the i-th sampling point in the d-th sample is Equal to the response value of the jth sensor at the i-th sampling point in the d-th sample of the original data set The difference between the sum of the next (N-1) response values minus the maximum of these N response values minus the minimum of these N response values is divided by (N-2); The first-category feature of the P1 and P3 stages is: the mean value of the P3 stage minus the mean value of the P1 stage. The first-category feature of the P1 and P3 stages is: the median value of the response of the P3 stage minus the mean value of the P1 stage. The first category feature of the P2 and P5 stages is: the average value of the P5 stage minus the average value of the P2 stage. The first category feature of the P2 and P5 stages is: the second category feature is: the median response of the P5 stage minus the average value of the P2 stage.
9. The sensor drift correction method based on transfer learning according to claim 8, characterized in that: The process of normalizing the first and second category features of the P1 and P3 stages is formulated as follows: is the corresponding normalized feature representation, f d,j,1 ,f d,j,2 are the first and second features of the P1 and P3 phases of the j-th response data of the d-th sensor, respectively. β is the weight factor. and σ1,σ2 are f d,j,1 ,f d,j,2 The mean and standard deviation of The process of normalizing the first and second category features of the P2 and P5 stages is formulated as follows: is the corresponding normalized feature representation, f d,j,3 ,f d,j,4 are the first and second features of the P2 and P5 phases of the j-th response data of the d-th sensor, respectively. and σ3,σ4 are f d,j,3 ,f d,j,4 The mean and standard deviation of .
10. A sensor drift correction system based on transfer learning, characterized by: The invention comprises a breath detection system and a sensor drift correction module. The breath detection system is used to perform steps S1 and S2 in the sensor drift correction method based on transfer learning according to any one of claims 1 to 9. The sensor drift correction module is used to perform step S3. The sensor drift correction module is further used to use the classifier f and the optimal transformation matrix P to predict the input breath characteristic data of the lung cancer patient, and output a pseudo label corresponding to the breath characteristic data of the lung cancer patient as a lung cancer detection result.
Citation Information
Patent Citations
A Correction Method for Gas Sensor Based on Machine Learning
AU2020100700A4
Target domain migration extreme learning-based electronic nose heterogeneous data identification method
CN105913079A