# Detection of Smoking in Indoor Environment Using Machine Learning
## Materials and Methods
### Feature Selection for Machine Learning
#### 2.2.2 Problem Definition and Application Method
Using the kernel trick, it can achieve the same result as adding multiple polynomial features without actually adding polynomial features. \(a,b\) are vectors describing the centers, \(\gamma\) is the value of the parameter, \(\|a\ -\ b\|\) is the distance of Euclidean Distance. Gaussian Radial Basis Function Formula (2) is as below. \[\text{Gaussian Radial Basis Function (RBF) : }K(a,b)=exp(-\gamma\|a\ -\ b\ \ \|^{2}) \tag{2}\]  
\(\gamma\) is polynomial order. R-order polynomial kernel Formula (3) is as below. \[\text{R-order polynomial kernel : }K(a,b)=\left(a^{T}b\ +\ 1\right)^{r} \tag{3}\]  
In this experiment, we selected the maximum margin boundary (Hyperplane) linearly to maximize the SVM classification margin. However, when using linear SVM, it is difficult to classify data only linearly in a high-dimensional space with many predictors. So, using a nonlinear SVM, a hyperplane was created to classify the four situations: heating, cooking, smoking, and non-smoking. In nonlinear SVM, the Gaussian RBF kernel trick is used because the Gaussian makes the curved hyperplane softer than the polynomial kernel, which enables more accurate classification of high-dimensional spaces. Using the KNN model, 4 attributes (CO\({}_{2}\), TVOC, PM 2.5, PM 10) were used as 1 vector, and k = 3 was set the distance of each vector was obtained using the Euclidean distance, while a cluster was created in a 4D space using supervised learning. For example, when new data needs to be classified, if there are many neighbors belonging to cluster 0 among the three closest neighbors, the data are classified as 0, and if there are many neighbors belonging to cluster 1, the data are classified as 1. MLP (Multilayer perceptron), called Feed-forward Neural Network, or Neural Network, is a generalized form of Linear Model that makes decisions through several steps. [27]. Normally, in multi-layered learning method, a single hidden layer, given enough neurons, can form any mapping needed. In practice, two hidden layers are often used to speed up convergence. Problems that require more than two hidden layers were rare prior to deep learning. Two or fewer layers will often suffice with simple data sets. However, with complex datasets involving time-series or computer vision, additional layers are required [28; 29]. Given from this conventional hidden layer implementation of the MLP method, we conducted 1 input layer with 4 properties, 1 output layer, and 2 hidden layers. Rectified Linear Unit (ReLu) was used as the activation function of the layers excluding the output layer, and the output layer was set to sigmoid for binary classification. Besides of supervised learning, K-means clustering, the most-well known unsupervised learning, was used. The K-means algorithm is a separate clustering algorithm that groups given data into k clusters, and operates in a manner that minimizes the variance of the difference between each cluster and the distance. Since the k-means algorithm randomly determines the initial value of each cluster, the desired result may not be obtained depending on the location of the initial value. Alternatively, clusters may not be formed well even if the cluster size, cluster density, and data distribution are unusual. Due to this limitation, the majority voting method, which is a method of performing clustering several times and assigning it to the cluster that appears most frequently, is often used [27]. The k-means was calculated using the Euclidean distance between the vectors, and the initial cluster number was set to 2 to categorize smoking and non-smoking cases. The initial number of clusters was set to 2 (\(k\) = 2) (smoking group, non-smoking group). First, K-means clustering is calculated in advance using the training data, and the test data is classified into proximity clusters by Euclidean distance. In addition, this model calculates the cluster center of each data and predicts the cluster index (0,1). The case of smoking is automatically classified as 1, and the case of non-smoking is automatically classified as 0.