1. Introduction
CH
4 and CO are common dangerous gases in industrial production and daily life, which often cause explosions, fires, poisoning, and other accidents. In order to effectively prevent such accidents, it is necessary to carry out rapid and accurate identification for CH
4, CO, and their mixed gases. At present, the common detection methods are mass spectrometry, light spectrum, gas chromatography, and a chemical method, which can accurately identify the gas composition and concentration [
1,
2,
3,
4]. However, their disadvantages, such as high cost, huge equipment, complicated operations, and time-consuming analysis greatly limit their applications. In contrast, semiconductor gas sensors have been widely used for gas detection due to their advantages of small volume, high sensitivity, low power consumption, and real-time detection [
5,
6].
However, semiconductor gas sensors have inherent cross-sensitivity to different kinds of gases. It is therefore impossible to accurately detect and identify the composition and concentration of the mixed gas by using only one semiconductor gas sensor [
7]. By combining different types of gas sensors into a sensor array, the multi-dimensional information of the target gas could be obtained so that the detection and identification of complex atmosphere could be realized [
7,
8,
9]. Electronic nose (E-nose) is a system designed based on this principle to mimic the biological olfactory function. It has been applied in many fields, such as agriculture and the food industry [
10], the environment [
11], and disease diagnosis [
9]. When CH
4, CO, or their mixed gases exist in the ambient air, it is expected to realize the detection and identification of such gases by using E-nose.
Although many research studies on the detection and identification of CH
4 and CO have been carried out using E-nose, there are still some problems: (1) Most previous studies mainly focused on investigating single gases [
12,
13], but there are often mixed gases in the actual environment, so these studies cannot meet the requirement of practical applications. (2) The reported research on gas identification through E-nose is usually based on analyzing the entire response process of E-nose, which makes the detection time relatively long, meaning it cannot meet the requirements of rapid detection [
14,
15]. (3) Most studies that achieve high identification accuracies require running complex algorithms (e.g., neural network algorithm) [
15,
16], which limit the application of this technique to portable products.
In order to solve the abovementioned problems of using E-nose to identify gases, in this paper, an E-nose system with seven homemade semiconductor gas sensors was first designed and then used to detect CH4, CO, and their mixed gases with different composition and concentrations. In order to improve the detection speed, this paper proposes a feature extraction method based on the start stage of the E-nose response so that the detection process no longer needs to wait for the sensors to reach stable state. Subsequently, two polynomial fitting methods for extracting gas features are designed according to the characteristics of the E-nose response curves. Finally, in order to shorten the time consumption of the calculation and reduce the complexity of the identification model, linear discriminant analysis (LDA) is introduced to reduce the dimensionality of the extracted feature datasets, and the XGBoost-based gas identification model is trained using the LDA optimized feature datasets. The experimental results show that the proposed method can obtain sufficient features representing the target gas, shorten the gas identification time, and achieve high accuracy for CH4, CO, and their mixed gases.
2. Methodology of Gas Identification
Figure 1 illustrates the flowchart of the gas identification method proposed in this paper, which consists of three main processes: data acquisition, data processing, and gas identification. The data acquisition process obtains the response of the E-nose to the target gas. However, the original response may contain noise information, which may come from electromagnetic interference, signal transmission failure, and the fluctuation of the experimental environment. The purpose of data preprocessing is to filter out the noise and interference information from the collected response signal. For training the identification model, as many as possible key features that can represent the target gas need to be first extracted. The feature dataset composed of these preliminary extracted features is normally of high dimensionality. In order to shorten the time consumption of the calculation and reduce the complexity of the recognition model, the feature dataset needs to be optimized by dimensionality reduction algorithms. Finally, in order to realize the identification of the target gas, the optimized feature dataset is used to train the gas identification model.
In order to reduce the complexity of the identification model, an identification model based on the XGBoost algorithm is proposed in this paper. XGBoost is an improvement based on the gradient boosting algorithm proposed by Friedman [
17], which has been proven to be highly effective in the fields of medicine [
18] and material and fault detection [
19,
20]. However, there are still few reported applications on gas identification. The specific execution logic of the gas identification algorithm based on XGBoost is as follows:
Assume that a given feature dataset consists of
m gas samples, and each sample has
n features. The XGBoost model is considered an integrated model composed of
t base models, and one base model represents a tree (gases with different categories), so the predicted value of the XGBoost model to identify the
m gas samples can be expressed as:
where
xi is the features of gas sample, and
fk is the predicted value of the
kth tree model. We iterate each tree to obtain the optimal
by fitting the residual difference of the current model. The objective function is given by Equation (2), and the goal of XGBoost model is to minimize the value of
obj.
where
is the loss function to measure the deviation between the real value
and the predicted value
, and
is a regularization term to balance the complexity of the model.
could be calculated as the following equation:
where
ωj is the value of the leaf node (gas samples with the same category),
T is the number of leaf nodes, and
λ and
γ represent the penalty coefficient. In the process of generating the
fth tree, the predicted value and the objective function can be represented by Equations (4) and (5), respectively:
Substitute Equation (4) into Equation (5), and the objective function is then approximated by a second-order Taylor expansion, and we find the
ff that minimizes the objective function, as shown in Equation (6):
where
gi and
hi are the first and second derivatives of the loss function, respectively. Therefore, the optimal value of leaf
j (
) can be calculated by Equation (7), and the predicted value
ff(
xi) of the
fth tree can be expressed as
.
where
q(
xi) indicates which leaf node the sample
xi falls on, and
represents the sample number of leaf node
j. The optimal value of the objective function can be calculated by Equation (8):
Calculate the information gain of each gas feature according to Equation (9), and select the branch with the largest gain to construct the model.
where
,
lL, and
lR are the sample sets of the left and right branch after splitting the leaf nodes.
According to the above principles, t trees can be constructed, and all the trees are combined to form the identification model. For the sample classified into a leaf node, its final prediction result can be obtained by accumulating the value of all the corresponding leaf nodes.
4. Results and Discussion
4.1. Response of the E-Nose
Affected by the characteristics of the sensitive material of the sensor, the steady-state value of different sensors will change with some factors, such as ambient atmosphere, temperature, and humidity. It may be that the absolute change value of the sensor resistance is small, but its relative change rate is very large, or vice versa. In order to avoid the impact of such a situation on the subsequent gas detection and identification, we use Equation (10) to convert the original data collected by E-nose.
where
R0 is the steady-state resistance of the sensor in the air, and
Rt is the real-time resistance of the sensor when it is exposed in the target gas.
Figure 4 shows the typical response spectrum of the E-nose to the detected gases converted by Equation (10). As the sensors of the E-nose system are n-type SMO and tested gases are reducing gases, the
Rs values of all sensors are positive. It can be seen that when the target gas was sent into the sensor array chamber, all the sensors exhibited fast responses. Their responses reached the maximum value as the target gas was completely injected into the test chamber. For instance, the absolute resistance value of Sensor CH1 in air is about 8.7 kΩ, and its maximum responses in G3, G6, and G15 reduce to 8.3, 8.0, and 7.5 kΩ, respectively. When the clean air was introduced, all the sensors can quickly return to their initial states. This result indicates that the as-designed E-nose system has good detection ability.
An interesting phenomenon can also be found from
Figure 4. In the start stage when the target gas was sent into the test chamber, the sensor array showed obvious differences for different types of gases, that is, the start stage of the response curves of different types of gases has good discrimination. The start stage is actually the reaction process between the detection gas and the sensitive material of the sensor [
21]. For the experimental gases, this process takes about 15 s (from 30th s to about 45th s). Therefore, we can use the response data of this process to distinguish the gases. In the next section, a feature extraction method based on the start stage of the E-nose response is explained in detail for achieving rapid detection and identification of the gases.
4.2. Gas Feature Extraction
At present, most of the feature extraction methods used in the E-nose system are manual, such as calculating the maximum value, minimum value, slope, integral, difference, and derivative of the response curve. However, this method relies on the empirical knowledge of the researcher and requires a large number of tentative experiments. To overcome this shortcoming, this paper proposes a feature extraction method through fitting the start stage of the gas response curve with polynomials. In order to compare the effectiveness of the proposed feature extraction method, we also constructed the manual feature dataset commonly used for E-nose based on previous studies [
10,
22]. The details of the construction process of each feature dataset are as follows:
4.2.1. Manual Feature Dataset
As shown in
Table 3, the manual feature dataset extracted 24 features from each sensor, and a total of 168 features were obtained for 7 sensors (24 × 7 = 168). The extracted features were sequentially connected to form a feature vector (see
Figure 5). Each type of target gas was detected 10 times, and the final feature dataset contained 25,200 features (15 × 10 × 168).
4.2.2. Overall Polynomial Fitting Feature Dataset
According to the analysis of the experimental data, the start stage response curves of the CH
4, CO, and CH
4-CO gases can be well-fitted by Equation (11), as shown in
Figure 6. The polynomial coefficients are considered as the extracted features. Some 11 features were then extracted from each sensor for a total of 77 features for the 7 sensors (11 × 7 = 77). The feature dataset was also organized in the same way as shown in
Figure 5, which contained a total of 11,550 features (15 × 10 × 77).
where
y represents the response value of the gas sensor,
x is the detection time, and
A, B... are the fitting coefficients of the polynomial.
4.2.3. Piecewise Polynomial Fitting Feature Dataset
Although Equation (11) can fit the response curve of the sensors well, there are some deviations, especially at both ends of the curve (see
Figure 6). Therefore, in order to better match the characteristics of the response curve, we proposed an idea of using piecewise fitting. As illustrated in
Figure 6, the response curve was cut into two parts and fitted with two low-order polynomials, respectively, and finally the fitting parameters of the two polynomials were combined to construct the feature dataset. This can not only effectively reduce the calculation of the fitting process, but also hopefully improve the accuracy of the curve fitting. Experimental data showed that each part of the curve could obtain satisfactory fitting accuracy by using a quartic polynomial Equation (12). The coefficients
A,
B,
C,
D, and
E are the extracted features. A total of 10 features were extracted from the 2 quartic polynomials, and finally a dataset containing 10,500 features (15 × 10 × 70) was constructed.
4.3. Analysis of Gas Features
The gas feature datasets obtained by the abovementioned three feature extraction processes have very high dimensionalities (higher than 70). In order to shorten the time consumption of the calculation and reduce the complexity of the recognition model, we employed linear discriminant analysis (LDA) to reduce their dimensionalities before the training of the identification model. LDA is a powerful supervised algorithm that computes the linear discriminant by considering the scatter of samples both within classes and between classes.
Figure 7 shows the results of LDA dimensionality reduction on the feature datasets established above. It can be seen that, whether for single gases or mixed gases, as the number of discriminants increases, the discriminability rate of samples is significantly improved. For the single gases, higher precision identification of samples can be achieved by retaining three-dimensional features. while for the mixed gases, only about five-dimensional features are required. This result indicates that the feature extraction methods proposed in the previous section are sufficient to represent the gas category information. It also reveals that the identification of mixed gases is more difficult than that of single gases.
Figure 8 shows the scatter plot of single gas samples after LDA feature dimensionality reduction. It can be seen that the first three features of all feature datasets can clearly distinguish different gas samples. It is worth noting that for overall polynomial fitting features, some samples overlap slightly (gas G1 and G3), which may be caused by the relatively large deviations in the data fitting process (see
Figure 6). However, for the mixed gases, it seems that the samples cannot be completely distinguished only through the first three features (see
Figure 9). This is because the gas sensor array has cross-sensitivity to both CH
4 and CO. The responses of the sensors to the mixed gases are therefore more complex than that of the single gases, so those features extracted would be partially overlapped and confused. Although the situation of mixed gases is more complicated, there is an obvious phenomenon: the piecewise polynomial fitting feature dataset is significantly better than the overall polynomial fitting dataset because the samples of the former are better clustered. In contrast, the sample distribution of the latter are more dispersed.
4.4. Identification Accuracy
Since the number of features required for the identification of single gases and mixed gases is different, to achieve rapid identification of gas categories, a binary classifier based on XGBoost was first constructed to evaluate whether the sample is a single gas or a mixed gas. Then, further identification will be carried out according to the evaluation results. In order to ensure the accuracy and stability of the XGBoost model, it was trained and verified using a five-fold cross-validation method, in which the subsets for training and verification were randomly generated multiple times.
The experimental results confirmed that the XGboost model is able to determine with complete accuracy whether the target gas is a single gas or a mixed gas. The further experimental results are shown in
Figure 10. For the six single gases, the identification accuracy of the manual feature dataset can exceed 80% when two features are retained, and 100% identification accuracy can be achieved with five features. For the overall polynomial fitting feature dataset and the piecewise polynomial fitting feature dataset, 100% accuracy can be obtained when two-dimensional features were used. In particular, for the piecewise polynomial fitting feature dataset, the accuracy of 90% can be achieved with only one-dimensional features. This confirms that the efficiency of feature extraction by piecewise polynomial fitting is highest among the three extraction methods. For mixed gases, the improvement trends of the identification accuracy as a function of the number of features are similar to those of single gas, but the satisfactory identification accuracy requires a larger number of features, that is, four-dimensional features are required (see
Figure 10b). Some researchers also reported the detection and identification of CO and CH
4 gases in recent years [
12,
15]. The identification accuracies they obtained were around 98%, but these studies employed complex models, such as neural networks. Compared with these previous studies, our proposed method also achieves satisfactory accuracy and is more convenient in terms of identification time consumption.
The experimental results also indicate that the polynomial fitting feature dataset proposed in this paper is more efficient than the manual feature dataset, whether for single gases or for mixed gases. Although the more effective manual feature dataset can be constructed if more tentative experiments can be carried out, this is undoubtedly a laborious work. Therefore, it is more convenient to extract gas features through polynomial fitting. It is worth noting that although both the overall polynomial fitting and the piecewise polynomial fitting could obtain perfect identification efficiency when retaining a sufficient number of features, the piecewise polynomial fitting requires fewer parameters (10 parameters) than that of the overall polynomial fitting (11 parameters). Moreover, the overall polynomial fitting is more time-consuming because of the higher order of Equation (11), so we can draw a conclusion that the piecewise polynomial fitting is more advantageous than the overall polynomial fitting. Therefore, constructing the gas feature dataset by piecewise polynomial fitting, then reducing the dimensionality of the original feature dataset by LDA, and finally constructing the identification model based on the XGBoost algorithm is a rapid and efficient method for identifying CH4, CO, and their mixed gases.