Spatial Upscaling-Based Algorithm for Detection and Estimation of Hazardous Gases

Recently, society/industry is getting smarter and sustainable through artificial intelligence-based solutions. However, this rapid advancement is also polluting our air ambience. Hence real-time detection and estimation of hazardous gases/odors in the air ambiance has become a critical need. In this paper, a convolutional neural network (CNN) based multi-element gas sensor arrays signature response analysis approach has been presented to achieve higher accuracy in detection and estimation of hazardous gases. Accordingly, the real-time gas sensor array responses are spatially upscaled and processed on the edge, using lightweight CNNs. For the verification of our hypothesis, we have used a four-element metal-oxide semi-conductor (MOS)-based thick-film gas sensor array, fabricated by our group, by using SnO2, ZnO, MoO, CdS materials for detection and estimation of four target hazardous gases, viz., acetone, car-bon-tetrachloride, ethyl-methyl-ketone, and xylene. The four-element (<inline-formula> <tex-math notation="LaTeX">$2\times 2$ </tex-math></inline-formula>) raw sensor responses are first upscaled to <inline-formula> <tex-math notation="LaTeX">$6\times 6$ </tex-math></inline-formula> responses and a lightweight CNN is trained on 42 samples of <inline-formula> <tex-math notation="LaTeX">$6\times 6$ </tex-math></inline-formula> input vectors. The trained system is then tested using 16 unknown (not used during training) test samples of the considered gases/odors. All the 16 test samples are detected correctly. The Mean Squared Error (MSEs) of detection has been <inline-formula> <tex-math notation="LaTeX">$1.42\times 10^{-14}$ </tex-math></inline-formula> while the estimation accuracy of <inline-formula> <tex-math notation="LaTeX">$2.43\times 10^{-3}$ </tex-math></inline-formula> were achieved for the considered gases. Our designed system is generic in design and can be extended to other gases/odors of interest.


I. INTRODUCTION
Artificial intelligence (AI)-based pattern recognition techniques can achieve high performance in gas sensor systems (electronic nose). With the advent of the internet of things (IoT), the development of low-cost intelligent gas sensor systems are the prime contributors in transforming a city to be smart and sustainable, which is at-attracting the attention of researchers to develop such high-performance systems.
The associate editor coordinating the review of this manuscript and approving it for publication was Md. Moinul Hossain .
Gas sensor systems are helpful to detect (classify) and estimate (quantify) various types of gases/odors, volatile organic compounds, aromas, etc. The gas sensing systems includes several contexts of application for smart cities [1], [2], [3]. The air quality monitoring in a smart city has been demonstrated on hazardous gases/odors such as carbon monoxide, nitrogen dioxide, sulfur dioxide, and particulate matter (e.g., PM10) [1]. Except for gas sensors, the role of advanced sensing and smart sensors can be seen through [2] and [3] in the context of smart city scenarios. Further, gas sensors work on the phenomenon of adsorption of gas/odor molecules VOLUME 11, 2023 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ on the sensor's surface, thereby, lowering the resistance of the sensing elements. This percentage change in resistance of the sensor element is proportional to the affinity of various molecules with different gas sensing elements, typically called the sensor response of the sensing element to that particular gas/odor [4], [5]. Therefore, intelligent gas sensor systems can be designed by creating a gas sensor array using more distinct sensor elements and employing pattern recognition techniques [6], [7], [8], [9], [10], [11], [12], [13], [14]. A schematic diagram for a gas sensing system's processing has been shown in Figure 1.
The conception of gas sensor array was firstly considered by Persaud et al. to mimic the mammalian olfactory system [6]. They had used an array of non-specific gas sensors followed by pattern recognition using neural model. Depending on the demand of application, viz., detection and/or estimation, analysis has been carried out using various pattern recognition techniques [11], [15]. In published literature, principal component analysis (PCA) and its variants [8], [9], [10], [11], [12], [13], [14], [15], [16], linear discriminant analysis (LDA) [9], [10], [11], [14], stepwise discriminant analysis [9], hierarchical cluster analysis [12], [14], average slope multiplication [17], support vector machine (SVM) [18] etc. have been used for the detection of gases delivering different accuracies and success rates. Various neural network-based approaches such as artificial neural net-works (ANNs) [7], [19], [20], the back-propagation neural network [9], [17], multi-layer perceptron (MLP) classifier [21], [18], neural-genetic classification algorithm [15], and field-programmable gate array-based MLP classifier [22] have also been used for pattern recognition in gas sensor array responses (types of responses are shown in Figure 2). Mishra et al. proposed a modular ANN in which two ANN modules are connected using a 4 × 1 multiplexer. The classifier module has two blocks for pre-processing (NDSRT [23]) and detection, respectively. These blocks are single-layer feed-forward neural networks. On the other hand, the quantifier module has parallel blocks for quantifying the respective gas/odor [24]. In [23], authors have proposed a technique NDSRT which enhances the suitability of data for pattern recognition by adjusting inter-and intra-cluster compaction accordingly. They have assessed the proposed technique but not demonstrated the experiment for classifying and quantifying the gases/odors. Also, in [25], Mishra et al. proposed a normalized difference-based classifier in which multi-layer perceptron ANN (MLPANN) is used for detection. Their proposed technique NDSRT [23], outperformed the popular statistical data processing methods viz. PCA, and LDA. Apart from the traditional neural network-based approaches, Peng et al. have proposed a deep convolutional neural network (DCNN) called as GasNet and used for gas classification only, with a success rate of 95.2%. The obtained result by using GasNet has been compared with two other classifiers, SVM and MLP (a traditional fully connected neural network). It is shown that GasNet outperforms the other two classifiers in the context of classification accuracy [18].
This paper uses a spatial upscaling approach to transform steady-state gas sensor responses into a two-dimensional template, with significant data points on which CNNs can be applied. The proposed transformation also retains the information as contained in the raw sensor response. It has been shown using 3D scattering plots of three initial principal components (PCs) for raw and transformed sensor responses (see Figure 8(a)-(b)). It can be observed that the sensor characteristics remain the same after the transformation. A gas sensor system designed with our proposed approach can detect (classify) and estimate (quantify) various types of gases/odors, volatile organic compounds, aromas, etc., with a very high degree of accuracy. This work has been demonstrated the responses of a gas sensor array consisting of four gas sensing elements fabricated using thick-film technology. Considered responses had been recorded using four gases, viz., acetone, carbon-tetrachloride, ethyl-methyl-ketone, and xylene. Utilities of this work are highlighted as follows: 1. The referred datasets have been customized using spatial upscaling to achieve high-performance detection of considered gases/odors using the steady-state responses.
2. The convolutional neural networks (CNNs) have been applied to the customized (scaled-up) dataset, which was not possible on the original dataset.
3. The proposed approach is generic and can be used universally on multi-sensor limited-datapoint responses for high performance using CNNs.

A. GAS SENSOR ARRAY RESPONSES/DATASET
The dataset used to assess our proposed approach is steadystate responses of a gas sensor array, fabricated using thick-film technology. Electrical resistance of the sensor elements changes when it is exposed to analyte gases. Schematic structure of a gas sensor element and the sensing mechanism is shown in Figure 3. It is an integrated fourelement chip, as show in figure 1 and the required materials/ components were supplied by Electro Science Laboratories (ESL), USA [26].
The gas sensing elements were fabricated on tin oxide (SnO2) as its base material while cadmium sulfide (CdS), molybdenum oxide (MoO), and zinc oxide (ZnO), were used as dopants, for fabricating respective sensor elements, taken 10% by weight to parent material. Firstly, it was calibrated in different ambiances (e.g., closed air, open air, closed nitrogen, air flow, and nitrogen flow). It was then characterized for four gases/odors, viz., acetone (ace), carbon-tetrachloride (car), ethyl-methyl-ketone (emk), and xylene (xyl), respectively, capturing responses at different concentration levels of each gas. The detailed type and specification about the corresponding gas sensor array fabrication and experimentation has been shown in Table 1. Comprehensive details can be found in [26].
The sensor characteristics of the observed gases/odors are shown in Figure 4(a)-(d). Data extraction from the characteristics has been explained in [16]. Further-more, the formula for calculating concentration in parts per million (ppm) and a table of basic parameters of each respective gas are given in [23]. This dataset has been organized in two parts viz., the training and testing dataset consisting of 42 samples distributed as 8, 10, 12, 12, and 16 samples distributed as 2, 3, 6, 5, respectively, with a four-element vector in each, also called 'signature patterns' of the gas sensor array for respective gas samples. When we sample the gas sensor responses (10-100Hz sampling rate), both the transient and steady state responses are captured. However, Steady-state samples are the prime representative of respective gas and its sample concentration. Therefore, in this proposed work, we have utilized the concept of steady state gas sensor responses of the gas sensor array and have reduced the needful samples to only a hundred steady state samples taken from a total of sixty thousand samples consisting of transient and steady state responses [27].

B. THE PROPOSED APPROACH
Motivation: CNNs require a specific input format for their one-dimensional (1D) and two-dimensional (2D) versions, respectively [28]. 1D-CNN is effectively used to analyze the time-series sensor response where the response feature vector has sufficient length. Also, n filters in 1D-CNN contain only n feature vector instead of n × n feature vector in 2D-CNN. As aforesaid, the steady-state sensor response has a limited feature vector size; therefore, 2D-CNN can get more feature vectors using the same number of filters. Nevertheless, the feature vector of steady-state response cannot be converted into a 2D array of sufficient dimension as required by 2D-CNN.
Hence, steady-state samples acquired from a sensor array are incompatible with 2D-CNN in its present form. It could have been possible to transform this limited data at the sample level. Accordingly, in this paper, a spatial upscaling-based approach is used which the upscales the input vectors to leverage the 2D-CNN providing high-performance analysis.

C. SPATIAL UPSCALING
The feature vector of each gas sample obtained from a gas sensor array consists of data points corresponding to each gas VOLUME 11, 2023 sensor element's steady-state values. Therefore, each sample's gas sensor array response will be a feature vector having a length equal to the number of gas sensor array's sensing elements. Each of these sample vectors can be rearranged into a 2D array. The number of sensing elements (sensor) may or may not be equal to a perfect square number, thereby, two cases have been discussed below: Case I: If the number of features is a non-perfect square number n, it cannot be converted into the format such that: p × p = n, where p is a natural number, i.e., p ∈ N Here, the zero-padding will increase the number until the nearest perfect square number. This zero-padding makes the modified number of features (n + δ) where δ is the number of added null features, ensuring that it is a perfect square number. Further, find a factor p of (n + δ) such that: p × p = (n + δ), where p is a natural number, i.e., p ∈ N Case II: If the number of features is a perfect square number n, it is possible to represent it such that: p × p = n, where p is a natural number, i.e., p ∈ N Let's say the dataset is in the form of S × L, where S represents the total number of samples and L represents the total number of features (sensor elements) in each response for the gas sensor array to the respective sample.
ALGORITHM: As per workflow, it has been shown in Figure 5, for obtaining a suitable 2D array from sensor array responses for each sample. Pseudocode is given as follows: INPUT: Sample's feature vector length L≥2. OUTPUT: 2D array corresponding to each sample. 1) BEGIN 2) Calculate the total number of features L.
3) Check whether L is a non-perfect square or a perfect square number. 4) If L is a non-perfect square number, then  i) Using zero padding, add δ null features to the dataset to make L(new) = (L + δ), the next nearest perfect square number.
ii) Find a factor p such that: p × p = L(new). 5) If L is a perfect square number, then i) Find the factors p such that p × p = L. 6) The Dataset is converted into the form of S × p × p. 7) END Once a suitable 2D array is formed with the help of padding [27], spatial upscaling can now be applied. The spatial upscaling procedure is described below: Suppose that there are eight mirrors placed at the edges of the sample's 2D array in directions: east, west, north, south, north-west, south-east, north-east, and south-west. These directions are shown in Figure 6. Hence, the obtained mirror images of the original sample array are mosaicked around it at their respective places. A schematic diagram of the obtained augmented sample (valid to process with CNN called CNN Ready) is shown in Figure 7. From this figure, it can also be observed that the raw sensor responses of shape (2 × 2) have been scaled up into a transformed sample of shape (6 × 6). Thus, the obtained data with transformed samples can now be processed with CNNs as 2-D input with good choices of suitable kernels for classifying and quantifying gases/odors. It can further be observed that the original sensor response characteristics (signature patterns) and that of the augmented samples show the same cluster distribution as shown in Figure  8(a)-(b), respectively, indicating that the information has not been altered.

D. CONVOLUTIONAL NEURAL NETWORK (CNN)
A 2D-CNN has been customized to classify and quantify the gas sensor array responses by taking the scaled-up (6 × 6) 2D inputs. This section provides a brief introduction to specialized layers of CNN [29]: Convolutional Layers: This layer is used for automatic feature extraction with the help of kernels. Multiple kernels convolve with the input image and extract composite features in the form of a map. The stack of obtained feature maps is then forwarded as input to the next layer.
Pooling Layers: This layer is used to reduce the number of trainable parameters, concerning the input size.
Flatten and Fully Connected Layers: After using the convolutional and pooling layers, a flattened layer is used to convert the 2-D/3-D output feature maps into a single vector. Subsequently, dense or fully connected layers having connected each neuron to each neuron of the previous and successive layers are used.
The Output Layer: For detection, a layer named 'softmax' is used, with neurons equal to targets. On the other hand, the linear activation layer is used as the output layer for regression.
In this experiment, we have chosen a CNN model consisting of a pair of convolutional layers, a flatten layer, a fully connected or a dense layer, and the output layer (softmax or linear activation). Pooling layers are unnecessary since the spatial extent of input is already limited compared to image-like data. Interestingly, our designed CNN can classify respective gas/odor samples and quantify the concentration of the samples very accurately. The schematic block diagram of the customized 2D-CNN is shown in Figure 9. The related parameters of the trained CNN model have been given in Table 2.

III. RESULS
This paper uses spatial upscaling approach, which can upscale samples having a limited number of features, e.g., (2 × 2) obtained as the steady-state response from a gas sensor array to a (6 × 6), as in our case. The upscaled samples are used for training and testing purposes for pattern analysis using CNNs, followed upscaling uses the recursion as depicted in Figure 6 [30]. A CNN has been then trained and tested to verify the effectiveness of the scaled-up dataset at the sample level. It may be noted that CNN cannot be applied on initially captured 1D or 2D steady-state sensor responses wherever the sensor array consists of a few sensor elements. Design details of this CNN have been shown in Table 2. The feature maps automatically extract the features contained in the local area of the input. The feature maps obtained from the first convolutional layer are fed to the next convolutional layer as inputs. The convolved feature maps obtained from successive convolutional layers have been shown in Figure 10  matrix are well-matched with the sample's actual class. Also, all other elements of the confusion matrix are zeros, only indicating that there are 'zero' wrongly classified test samples. Further, Cohen's kappa coefficient [31] is also calculated from the confusion matrix given in Figure 11 in the form of another metric for detection assessment. It attains a value between 0 and 1. It is also a robust measure to know the quality of detection. The level of agreement has been defined based on the obtained value of the kappa coefficient (k). It is calculated using the equation (1).
where i = {ace: acetone, car: carbon-tetrachloride, emk: ethyl-methyl-ketone, xyl: xylene}; Ri, and Pi are the total number of reference samples, and correctly predicted samples for the respective gases/odors; N represents the number of test samples. Here, N=16, diagonal sum (D)=2+3+6+5=16, and (Ri × Pi) = 2 × 2 + 3 × 3 + 6 × 6 + 5 × 5 = 74. By substituting the respective values in the equation (1), we get k = 1. We have attained the perfect level of agreement in interpreting the kappa coefficient. Further, on inspection of the actual detection performance data, the mean squared error (MSE) for detection is also very low, i.e., 1.42 × 10 −14 with a maxi-mum/minimum squared error (Max SE/Min SE) of 1.42 × 10 −14 for all the test samples. The detection performance error for each sample is shown in Figure 12. The MSE has been calculated using (2): where T i stands for target value, P i stands for the predicted value, and N is the total number of samples.

B. ESTIMATION PERFORMANCE
The designed CNN has also been trained to estimate the concentration of the respective gas/odor samples. The estimation    performance of CNN has also been tested by using 16 unknown test samples, unused while training. The exact concentration for each of these samples is also available   accurately, as recorded during the experiment. The estimation performance while testing for 16 unknown test samples, a very low MSE 2.43 × 10 −3 has been achieved. At the same time, Max and Min SE were found 9.08 × 10 −3 and 6.50×10 −5 , respectively. The sample-wise squared error plot is shown in Figure 13. A performance chart of both detection and estimation performance has been given in Table 3.

IV. DISCUSSION AND CONCLUSION
The used spatial upscaling approach is a highly effective approach to achieving a high degree of detection and estimation performance using CNN. It is a breakthrough especially in the gas sensor intelligent system development that uses the steady-state responses of the gas sensor array for analysis. Such systems are vital in making smart cities sustainable and their management more reliable. Especially, the contribution of gas sensor systems is crucial to make the smart cities clean and green (eco-friendly). In the context of experimentation, as the results show, our proposed approach using CNN achieves a very low MSE, i.e., 1.42 × 10 −14 in detection, and 2.43 × 10 −3 in estimation for 16 unknown test gas/odor samples. The proposed approach is generic that can be utilized in each research field due to the inevitable usage of sensors. According to the authors' best knowledge, the proposed application of CNN on steady-state gas sensor array responses is the very first application of CNN on steady-state responses of gas sensor systems. It can also be implemented for use in real-time gas sensing applications after training the sensor system in laboratory conditions.