## 6 Results, Implementation, and Testing
### Machine Learning Classification Results  
Applying the grid search on the existing machine learning models available in Scikit-Learn, we found 10 models with the best overall classification performance. In Table 2, the performance results of the top 10 algorithms, evaluated by the above metrics, were documented.  
The Random Forest Classifier stood out as the most effective model in our evaluations. To better understand its performance, we split the dataset: 80% was used for training and the remaining 20% for testing. Considering the stochastic nature of the Random Forest algorithm, we ran it 100 times to ensure we captured a consistent measure of its capabilities. In all these runs, it achieved a maximum accuracy of 98.59%.  
Figure 7 presents the confusion matrix with the results of applying the trained algorithm to the test dataset. The model showed good performance on the fall detection task. There was no missed fall event nor false positive of fall classification, which is critically important to this product. However, occasional failures were observed when the algorithm attempted to discriminate between motion and steps, attributable to the similar inertial characteristics presented by these classes. Overall, the RandomForestClassifier model demonstrated superior performance.  
As for the proposed six-layer deep learning model, the CNN was trained using the same walker dataset to perform the motion classification task. Then, 80% of the samples were randomly selected for training, and the remaining 20% of samples were used for validation. The model was trained for 10 epochs. The results show that CNN reached an overall classification accuracy of 97.4%, which is lower than the Random Forest classifier. Although many high-performance, deeper CNN models may be trained to reach superior accuracy using the same dataset, the microcontroller on the hardware prototype can only handle a small CNN with a few layers and limited parameters due to the constraint of processing power and memory. We attempted to use deeper models using the TinyML library to generate the C code for implementation. But, it failed to load into the microcontroller during the execution, exceeding its usable memory limit.  
\begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Machine Learning Model** & **Accuracy** & **Precision** & **Recall** & **F1-Score** \\ \hline Random Forest Classifier & 98.59\% & 98.62\% & 98.59\% & 98.58\% \\ \hline Hist Gradient Boosting Classifier & 97.79\% & 97.80\% & 97.78\% & 97.78\% \\ \hline Extra Trees Classifier & 97.71\% & 97.72\% & 97.71\% & 97.70\% \\ \hline Bagging Classifier & 95.56\% & 95.63\% & 95.56\% & 95.55\% \\ \hline Extra Tree Classifier & 92.58\% & 92.62\% & 92.58\% & 92.52\% \\ \hline Decision Tree Classifier & 90.48\% & 90.57\% & 90.48\% & 90.45\% \\ \hline KNeighbors Classifier & 89.31\% & 91.09\% & 89.31\% & 89.28\% \\ \hline NuSVC & 88.83\% & 91.72\% & 88.83\% & 88.26\% \\ \hline Gaussian NB & 88.59\% & 90.63\% & 88.59\% & 87.63\% \\ \hline Logistic Regression CV & 87.30\% & 88.70\% & 87.30\% & 86.73\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Performance metrics of multiple machine learning classifiers for the inertial measurement unit dataset.