# Detection of Smoking in Indoor Environment Using Machine Learning
## Materials and Methods
### Evaluation Metrics  
We describe conceptual metrics used to evaluate the classification performance of a model or pattern in machine learning. The factors that evaluate the model can ultimately be defined as the relationship between the predicted answer and the actual correct answer. The correct answer is divided into True and False, and the predictive model is divided into Positive and Negative. That way, we can divide the case by a \(2\times 2\) matrix as shown Figure 7 below. The actual smoking is true value, and the actual non-smoking situation has a false value. If smoking is predicted in the predictive model, it has a positive value, and if it is predicted as non-smoking,  
Figure 7: Contextual matrix. it has a negative value. In this matrix, we need to be careful about the false positives and false negatives. False positive is to misjudge what is wrong as right, False Negative is when it is judged that what is right is wrong. The viewpoints that we consider as important differ depends on the situation. The denominator of accuracy is all everyday situations such as smoking, non-smoking, heating, and cooking, and the numerator is a summed value of true positive predicting smoking in a smoking situation and a true negative predicting not smoking in a non-smoking state. The accuracy formula, precision formula, recall Formula (4) are as below. \[ \begin{array}{l}\text{{Accuracy }}=\frac{\text{{True}}}{\text{{Every situations}}}=\frac{\text{{True }\text{{Positive}}}+\text{{True Negatives}}}{\text{{True Positives}}+\text{{True Negatives}}+\text{{False Negatives}}}\\ \text{{Precision }}=\frac{\text{{Actual}\text{{smoking cases predicted by smoking}}}}{\text{{Total amount predicted by smoking}}}=\frac{\text{{True}\text{{Positive}}}}{\text{{True Positives}}+\text{{False Positives}}}\\ \text{{Recall }}=\frac{\text{{Actual}\text{{smoking cases predicted by smoking}}}}{\text{{Total amount of situations that are actually smoking}}}=\frac{\text{{True}\text{{Positive}}}}{\text{{True Positives}}+\text{{False Negatives}}}\\ \end{array}  \tag{4}\]  
Precision measures the actual smoking in all situations predicted as smoking. The denominator is the sum of the total predicted amount of smoking, the true positives predicted that who actually smoked and the false positives predicted that who smoked even though who did not actually smoke. And the numerator has the true positives predicted that who actually smoked. Recall is the predicted proportion of smoking among actual smoking situations. It is a measure to sensitively judge the smoking situation. The denominator of the recall is (actual smoking situation) the sum of the true positive, predicted as smoking by actual smoking, and the sum of the false negative, predicted that actual smoking but did not smoke. The molecule actually smoked and is calculated as the value of the true positive predicted as smoking. The F1 score is the harmonic average of Precision and Recall. The F1 score can accurately evaluate the model's performance when the data label is unbalanced, and the performance can be expressed as a single number. The F1 score Formula (5) is as below. \[ \begin{array}{l}\text{{F1 score }}=\text{{2 }}\star\frac{1}{\frac{1}{\text{{Precision }}}+\frac{1}{\text{{Recall}}}}=\text{{2 }}\star\frac{\text{{Precision }}\star\text{{Recall}}}{\text{{Precision }}+\text{{Recall}}}\\ \end{array}  \tag{5}\]  
F1 is used because it is evaluated differently according to the importance in various aspects such as the status of the user and the supplier, rather than simply judging the performance of the model based on accuracy, precision, and recall. Additionally, the reason for using the F1 score is related to the nature of the IoT sensor we used. The sensor data used in the time series is sensitive and reliable, so data verification is required. Therefore, there is a limit to evaluating only the accuracy result, so the F1 score was also used as an evaluation scale.