## 3 Methodology
### iForest Outlier Detection
Finally, a random forest model was trained to learn from five classes (moving in and out through the gate, moving near the gate, turning back, and static tags) on the prepared training set and its prediction results were compared to the testing set to evaluate the model's accuracy. In this study, the input features are the statistical information from RSS and timestamps of RFID tags and the output is the movement types. The random forest model has 100 trees (\(T\)), and 36 features (\(F\)), and uses the Gini index for splitting the reduced number of features (\(d\)). Machine learning models were used to classify the different types and directions of movement for tagged products. The classification models were implemented in Python, XGBoost, and Scikit-learn and used default parameters provided by Scikit-learn [36]. The models were evaluated using stratified 10-fold cross-validation and their performance was measured using true positive (TP), true negative (TN), false positive (FP), and false negative (FN) rates [37]. TP and TN represent correctly classified instances, while FP and FN represent incorrectly classified instances (see Table 2). ## 4 Results and Discussion

This section discusses the performance of the proposed model and how outlier detection and the oversampling impact it. We also demonstrate the usefulness of the model by applying it to a web-based monitoring system. ### Performance of Machine Learning Models

We examined the performance of machine learning models and the effect of iForest outlier detection and SMOTE data balancing on the model's accuracy. We compared a model based on a random forest with iForest and SMOTE to other classification models for predicting five types of movement and direction of tags. We used several Machine Learning algorithms, including multi-layer perceptron (MLP), logistic regression (LR), K-nearest neighbor (KNN), decision tree (DT), naive bayes (NB), eXtreme Gradient Boosting (XGBoost), and adaptive boosting (AdaBoost), as models for predicting tag movement and direction. The results in Table 3 show the performance of different models in terms of accuracy, precision, recall, and f-score, using both RSS and Timestamp features. Our findings showed that the proposed model outperformed the other models by up to 94.251%, 93.751%, 98.612%, 93.502%, and 93.332% for accuracy, precision, specificity, recall, and f-score, respectively. \begin{table}
\begin{tabular}{c c} \hline
**Metric** & **Formula** \\ \hline \(Average\)\(accuracy\) & \(\frac{\sum_{i=1}^{i}\frac{\eta_{i}+\eta_{i}}{\eta_{i}+\eta_{i}+\eta_{i}}}{\sum _{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}+\eta_{i}}}\) \\ \(Precision_{M}\) & \(\frac{\sum_{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}{\sum _{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}\) \\ \(Specificity_{M}\) & \(\frac{\sum_{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}{\sum _{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}\) \\ \(Recall_{M}\) & \(\frac{\sum_{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}{\sum _{i=1}^{i}\frac{\eta_{i}}{\eta_{i}+\eta_{i}}}\) \\ \(Fscore_{M}\) & \(\frac{(\beta^{2}+1)Precision_{M}Recall_{M}}{\beta^{2}Precision_{M}+Recall_{M}}\) \\ \hline \end{tabular}
\end{table} 
Table 2: Measures for multi-class classification. \(tp_{i}\), \(fp_{i}\), \(fn_{i}\), and \(tn_{i}\) are true positive, false positive, false negative, and true negative for class \(C_{i}\), respectively. \(M\) indices represent macro-averaging. The proposed model was found to be highly accurate in detecting the movement and direction of tags. If tags moving in through the gate are wrongly classified as moving out, the management will think the products have been shipped to other supply chain partners. On the other hand, if tags moving out the gate are wrongly classified as moving in, the management will believe the products have been stored in cold storage. This shows that using the RF with iForest and SMOTE model will significantly improve warehouse management accuracy.