Keywords

1 Introduction

Compared with oil and natural gas, hydrogen energy has a higher conversion rate and lower carbon emissions, which is regarded as one of the feasible solutions to solve the problem of fossil fuel environmental pollution and energy crisis [1]. However, hydrogen is a flammable gas and hydrogen leakage in confined spaces may occur in the process of hydrogen transportation and hydrogen storage. In this case, it has potential risks of combustion and explosion. Therefore, it is necessary to design hydrogen leakage methods.

With the development of material science and artificial intelligence, gas sensors have been widely used in the field of explosive detection [2]. Most gas detection methods utilize gas sensors + machine learning to identify flammable gases. They generally assume that the training and test sets are independent and equally distributed. The prediction model is built on the training set and applied to the test set. However, due to aging, temperature and humidity interference, even the same concentration of the target gas, the response of the gas sensor is still different, i.e., sensor drift. In this context, the methods which assume that the training set and the test are identically distributed are not competent for gas detection in the drift scene in practical application.

For gas detection with sensor drift, Zhang et al. [3] proposed a machine learning method based on subspace projection to suppress gas sensor drift. Artursson et al. [4] introduced a drift counteraction method based on principal component analysis and partial least squares, and thus suppress sensor drift by removing drift direction component. Vergara et al. [5] designed a machine learning approach, namely the integration of classifiers, to solve the problem of gas identification over long periods of time. However, the accuracy of existing methods is still low. Therefore, a gas sensor compensation method based on subspace alignment is proposed. This method is suitable for gas identification in drift scene with high accuracy by aligning global domains and subdomains in the new subspace.

2 Methodology

The source domain with D-dimension are denoted as \(X_{S} = [x_{s}^{1} ,x_{s}^{2} , \cdots ,x_{s}^{{N_{S} }} ] \in \Re^{{D \times N_{S} }}\), and the target domain with D-dimension are denoted as \(X_{T} = [x_{T}^{1} ,x_{T}^{2} , \cdots ,x_{T}^{{N_{T} }} ] \in \Re^{{D \times N_{T} }}\). \(P \in \Re^{D \times d}\) represents a base matrix. \(\left\| \cdot \right\|_{2}\) is the l2-norm. \(tr\left( \cdot \right)\) denotes the trace operator.

2.1 Subspace Alignment Method (SAM)

To suppress sensor drift, the proposed SAM utilizes P to achieve domain alignment, and thus reduce distribution divergence between source domain and target domain. First, we focus on the alignment of the global distribution based on marginal distribution distance in the subspace.

$$ \mathop {\min}\limits_{P} \left\| {\mu_{S} - \mu_{T} } \right\|_{2}^{2} = \mathop {\min }\limits_{P} \left\| {\frac{1}{{N_{S} }}\sum\limits_{i = 1}^{{N_{S} }} {y_{S}^{i} } - \frac{1}{{N_{T} }}\sum\limits_{j = 1}^{{N_{T} }} {y_{T}^{j} } } \right\|_{2}^{2} $$
(1)

where \(\mu\) denotes the centre of the domain in the subspace. \(y_{S}^{i} = P^{T} x_{S}^{i}\) (\(i = 1,2,...,N_{S}\)) and \(y_{T}^{j} = P^{T} x_{T}^{j}\) (\(j = 1,2,...,N_{T}\)) are the projected samples in the subspace. Then we rewrite (3) as:

$$ \begin{gathered} \mathop {\min }\limits_{P} \left\| {\frac{1}{{N_{S} }}\sum\limits_{i = 1}^{{N_{S} }} {y_{S}^{i} } - \frac{1}{{N_{T} }}\sum\limits_{j = 1}^{{N_{T} }} {y_{T}^{j} } } \right\|_{2}^{2} \hfill \\ = \mathop {\min }\limits_{P} tr(P^{T} (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} P) \hfill \\ \end{gathered} $$
(2)

where \(u\) is the centre of the domain in the original space. For example, \(u_{S} = \frac{1}{{N_{S} }}\sum\nolimits_{i = 1}^{{N_{S} }} {x_{{_{S} }}^{i} }\) and \(u_{T} = \frac{1}{{N_{T} }}\sum\nolimits_{j = 1}^{{N_{T} }} {x_{{_{T} }}^{j} }\).

We then consider aligning subdomains with the same category between domains, which is formulated as follows

$$ \begin{gathered} \mathop {\min }\limits_{P} \sum\limits_{c = 1}^{C} {\left\| {\frac{1}{{N_{{_{S} }}^{c} }}\sum\limits_{{y_{S}^{i} \in class \, c}} {y_{S}^{i} } - \frac{1}{{\hat{N}_{{_{T} }}^{c} }}\sum\limits_{{\hat{y}_{S}^{i} \in class \, c}}^{{}} {\hat{y}_{T}^{j} } } \right\|_{2}^{2} } \hfill \\ = \mathop {\min}\limits_{P} tr\left( {\sum\limits_{c = 1}^{C} {P^{T} (u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} P} } \right) \hfill \\ \end{gathered} $$
(3)

where \(\hat{y}_{T}^{j}\) represents the j-th sample whose classifier prediction result belong to class c from the target domain. \(\hat{N}_{{_{T} }}^{c}\) is the number of samples whose classifier prediction result belong to class c. \(\hat{u}_{{_{T} }}^{c}\) is the centre of c-class samples from the target domain.

To prevent data distortion from source and target domains, it is necessary to maximize the following term

$$ \begin{gathered} \mathop {\max }\limits_{P} ((1 - \alpha_{1} ) \times tr(P^{T} X_{S} X_{S}^{T} P) + \alpha_{1} \times tr(P^{T} X_{T} X_{T}^{T} P)) \hfill \\ \mathop { = \max }\limits_{P} (tr((1 - \alpha_{1} ) \times P^{T} X_{S} X_{S}^{T} P + \alpha_{1} \times P^{T} X_{T} X_{T}^{T} P)) \hfill \\ \end{gathered} $$
(4)

where \(\alpha_{1} \in [0,1][0,1]\).

Finally, the proposed SAM simultaneously optimizes (2), (3) and (4), which is formulated as:

$$ \mathop {\min }\limits_{P} \frac{{\alpha_{2} \times tr(P^{T} (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} P) + \alpha_{3} \times tr(\sum\limits_{c = 1}^{C} {P^{T} (u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} P} )}}{{tr((1 - \alpha_{1} ) \times P^{T} X_{S} X_{S}^{T} P + \alpha_{1} \times P^{T} X_{T} X_{T}^{T} P)}} $$
(5)

To achieve a unique solution, (5) is rewritten as

$$ \left\{ \begin{gathered} \mathop {\min }\limits_{P} (\alpha_{2} \times tr(P^{T} (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} P) + \alpha_{3} \times tr(\sum\limits_{c = 1}^{C} {P^{T} (u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} P} ) \hfill \\ s.t.(1 - \alpha_{1} ) \times P^{T} X_{S} X_{S}^{T} P + \alpha_{1} \times P^{T} X_{T} X_{T}^{T} P = I \hfill \\ \end{gathered} \right. $$
(6)

where \(I \in \Re^{d \times d}\) is the identity matrix.

After that, the Lagrange function L is introduced:

$$ \begin{aligned} L & = \alpha_{2} \times tr(P^{T} (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} P) + \alpha_{3} \times tr(\sum\limits_{c = 1}^{C} {P^{T} (u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} P} ) \\ & \quad - tr((I - ((1 - \alpha_{1} ) \times P^{T} X_{S} X_{S}^{T} P + \alpha_{1} \times P^{T} X_{T} X_{T}^{T} P))\Phi ) \\ \end{aligned} $$
(7)

where \(\Phi = {\text{diag}}(\phi_{1} ,\phi_{2} , \ldots ,\phi_{d} ) \in \Re^{d \times d}\) denote the Lagrange multipliers.

According to \(\frac{\partial L}{{\partial P}} = 0\), we can get

$$ \begin{aligned} & ((1 - \alpha_{1} ) \times X_{S} X_{S}^{T} + \alpha_{1} \times X_{T} X_{T}^{T} ))^{ - 1} (\alpha_{2} (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} \\ & \quad + \alpha_{3} \sum\limits_{c = 1}^{C} {(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} } )P \, = P\Phi \\ \end{aligned} $$
(8)

P can be solved by eigenvalue decomposition based on A. i.e.,

$$ AP \, = P\Phi $$
(9)

where

$$ \begin{aligned} A & = ((1 - \alpha_{2} ) \times X_{S} X_{S}^{T} + \alpha_{2} \times X_{T} X_{T}^{T} )^{ - 1} \left( {(1 - \alpha_{1} ) \times (u_{S} - u_{T} )(u_{S} - u_{T} )^{T} } \right. \\ & \quad \left. { + \alpha_{1} \times \sum\limits_{c = 1}^{C} {(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )(u_{{_{S} }}^{c} - \hat{u}_{{_{T} }}^{c} )^{T} } } \right). \\ \end{aligned} $$

Therefor, \(P^{*}\) is formulated as

$$ P^{*} = [P_{1} ,P_{2} ,...,P_{d} ] $$
(10)

where \(P_{k}\) (\(k = 1,2,...,d\)) denotes the eigenvector with respect to the k-th minimum eigenvalue.

2.2 The Proposed Framework

The proposed framework first calculates P according to (10), and the source domain and target domain are projected into the subspace, thus reducing the distribution differences between domains. Then, the data of the subspace is input into ELM [6] for training, and thus obtain the prediction result of the target domain. Finally, the target domain is iteratively optimized to predict the results and P (see Fig. 1).

Fig. 1.
figure 1

Average accuracy with different Iterations.

3 Experiments

3.1 Dataset

The benchmark sensor drift dataset was collected over 36-month from UCSD [5], including acetone, acetaldehyde, ethanol, ethylene, ammonia, and toluene. There are 13,910 samples in the data set and each sample consists of 128-dimensional feature vector. The benchmark sensor drift dataset is divided into ten batches, as shown in Table 1.

Table 1. The sensor drift dataset.

3.2 Experimental Results

The experimental environment is an Intel(R) core (TM) i7-10750H CPU@2.60 GHz, 16 GB memory, Windows 11 and Python 3.6. We set batch 1 as the training set (source domain) and batch t (t = 2, 3, …, 10) as the test set (target domain). The proposed method is compared with several drift compensation methods, including SVM, ELM and DRCA [3].

The experimental results are shown in Table 2. Compared with SVM, ELM and DRCA, the proposed method achieves the highest classification accuracy by reducing the distribution difference. Therefore, these results show that the proposed drift compensation strategy is competent for gas detection in long-term drift scenarios.

Table 2. Experiment results.

During training we hope to use as few iterations as possible to achieve the highest accuracy. Figure 2 shows the average accuracy of the proposed method with iterations. The results show that the proposed method is effective and the highest average accuracy is achieved in fewer iterations.

Fig. 2.
figure 2

Average accuracy with different Iterations.

4 Conclusion

Hydrogen leakage detection in confined spaces is the guarantee of successful hydrogen transport and hydrogen storage technology. In this paper, focusing on the practical application scenario, a drift compensation method for gas sensor is proposed. In this method, subspace alignment is realized by aligning subdomains and global domains, and thus reducing the distribution difference due to sensor drift. Experimental results show that the proposed method achieves the highest classification accuracy in the long-term drift with an average accuracy of 79.83%.