# A Comparative Analysis for Optimizing Machine Learning Model Deployment in IoT Devices
## 4 Result Analysis
### Training on FashionMNIST  
Table 3 lists the traditional performance metrics for training an image classifier on the FashionMNIST dataset using the PyTorch and Libtorch libraries.  
\begin{table}
\begin{tabular}{l l l} \hline \hline
**Metrics** & **PyTorch** & **Libtorch** \\ \hline Accuracy & 89.52\% & **89.7\%** \\ \hline Precision & **89.50\%** & 88.7\% \\ \hline Recall & **89.52\%** & 89.3\% \\ \hline F1-Score & **89.48\%** & 88.9\% \\ \hline Training time & 3.03 h & **2.01 h** \\ \hline Total Power & 2.925 kW & **2.511 kW** \\ \hline Average Temperature & 51.4 °C & **50.2 °C** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Model performance on FashionMNIST dataset. The best results are given in bold.  
Figure 3: User Interface (UI) Design for the decision support system.  
Analyzing the performance of PyTorch and Libtorch on the FashionMNIST dataset reveals distinct advantages for each framework. Both PyTorch and Libtorch performed in a similar manner in terms of the model's prediction capability. Nonetheless, Libtorch had slightly better results while taking a shorter time to train the model.  
Moreover, Libtorch showcases advantages in training efficiency and resource management. It completes training faster by approximately 7% and utilizes less memory and power, which could be crucial in resource-constrained or energy-sensitive environments. Additionally, Libtorch operates at a slightly lower CPU temperature, suggesting more efficient resource use and, potentially, a lower environmental impact. Further comparisons may be drawn with Figure 4, where Libtorch has far more optimized and uniform memory utilization and Pytorch is slightly more sporadic in CPU calls over time.  
Figure 4 depicts the continuous tracking of the external factors for the duration of the training of the model on the FashionMNIST dataset. The metrics are reported every 60 s in a CSV file and then plotted using the matplotlib library in Python. Firstly, by comparing the CPU usage it is apparent that PyTorch uses more CPU computation resources consistently while Libtorch's CPU usage remains low for the first half of the training period and shows a slight increase for the rest of the training period, which is still lower than that of PyTorch. In terms of the memory consumption profile, there is a drastic difference between the two libraries. The PyTorch implementation shows a sustaining fluctuation and an overall higher memory consumption. In comparison, the Libtorch model training shows an almost linear consumption of memory that flattens at around 460 megabytes. For the internal temperature of the CPU, PyTorch surprisingly is lower for most of the time except for a sharp increase right after the initial execution of the training session. Meanwhile, the CPU temperature stays around 80 degrees Celsius for the half of the training period and then significantly decreases to the ambient operating temperature of the device. Finally, the power consumption profile for both PyTorch and Libtorch shows a direct correlation with the respective CPU utilization profiles for each library.