## 3 Analysis and Comparison of Machine Learning-Based Anomaly Detection
### Machine Learning Models
#### 3.1.1 Decision Tree (DT)  
Decision trees (DTs) are a popular machine learning tool that can be used for both classification and regression. When trained on a dataset, they will gain the ability of classifying new unseen data. A decision tree consists of three types of nodes, namely the root, inner, and leaf nodes. The tree is created using a number of edges that connect these nodes and helps to carry out classification and regression. Among the many DT algorithms, we used the classification and regression trees (CART) method to identify anomalies. This method recursively splits the dataset into subsets by making binary decisions based on the  
\begin{table}
\begin{tabular}{p{113.8 pt} p{113.8 pt} p{113.8 pt} p{113.8 pt}} \hline
**Paper** & **Objectives** & **Contributions** & **Limitations** \\ \hline \multirow{10}{*}{[PERSON] et al. [9]} & \multirow{6}{*}{Activity recognition of multiple residents using historical activity features.} & Different machine learning models like random forest (RF), decision tree (DT), Support Vector Machine (SVM), and k-nearest neighbor (KNN) and neural network models such as Multilayer Perceptron (MLP) and Long Short-term Memory (LSTM) were used to classify human activities. & The considered features are not enough to classify all activities, including anomalies, accurately. \\ \hline \multirow{2}{*}{[PERSON] et al. [6]} & \multirow{2}{*}{Detecting anomalies in human activity in the presence of visitors.} & Applied entropy-based models to classify the samples and identify anomalies. & Finding the optimal threshold for classification is difficult and significantly impacts the performance. \\ \hline \multirow{4}{*}{[PERSON] et al. [37]} & \multirow{2}{*}{Enhancing the human activities’ anomaly detection accuracy.} & Used temporal features in conjunction with the machine learning model to detect the anomalies in human activities. Generated synthetic data to increase the size of the dataset. & The quality of the synthetic data was not validated, and finding the temporal pattern, including the interval, is challenging. \\ \hline \end{tabular}
\end{table}
Table 1: _Cont._  
Figure 1: Workflow of our experiments.  
input features at each stage until it reaches a stopping point or a predetermined depth. The algorithm selects the feature at the tree's root node that optimally divides the dataset into subsets while maximizing a certain criterion. The Gini index, a measure of inequality that may be used to measure any unbalanced distribution between 0 and 1, divides the nodes and creates a decision tree. We determined the feature's Gini Gain by calculating the Gini index across all of the values of a feature within the data collection [43; 44], as shown in Equation (1).  
\[gini(T)=1-\sum_{j=1}^{n}p_{j}^{2} \tag{1}\]  
where \(p_{j}\) indicates the likelihood that a dataset sample will belong to a certain class and \(n\) indicates the total number of classes in the dataset. The Gini Split Info calculates the Gini index across all feature values, and the Gini index of the \(i\)th feature is computed using the following equation (Equation (2)).  
\[GINI_{split}(T)=\sum\frac{N_{i}}{N}gini(T_{i}) \tag{2}\]