# Hospital Length-of-Stay Prediction Using Machine Learning Algorithms--A Literature Review
## 4 Materials and Methods
### Most Important Metrics for Hospital LoS Prediction  
To develop effective hospital LoS prediction models, it is essential to evaluate their performance using various metrics that reflect different aspects of the model's accuracy and utility.  
This subsection explores the most important metrics used for evaluating hospital LoS prediction models. Each metric serves to measure different dimensions of the model's performance, ranging from predictive accuracy to the practical impact on healthcare operations. Understanding these metrics is fundamental for selecting the right model for specific healthcare scenarios and for guiding ongoing improvements to predictive strategies.  
* Mean Absolute Error (_MAE_)--measures the average magnitude of the errors in predictions, without considering their direction. It is the average over the test sample of the absolute differences between the prediction and actual observation where all individual differences have an equal weight; The _MAE_ is obtained using the following formula: \[MAE=\frac{1}{N}\sum_{i=1}^{N}\lvert\beta-y_{1}\rvert,\] (1)
* Accuracy--a fundamental metric used to evaluate the performance of classification models, including those used for predicting hospital LoS in healthcare settings. It measures the proportion of correct predictions made by the model out of the total number of predictions. In the context of regression models, accuracy can be adapted to evaluate how often the predicted hospital LoS falls within a specific acceptable range of the actual hospital LoS; The accuracy of a classification model is defined as: \[Accuracy=(TP+TN)/(TP+TN+FP+FN),\] (2)
* \(R^{2}\) Score--a statistical metric used to evaluate the goodness of fit of a regression model. It measures the proportion of the variance in the dependent variable (e.g., hospital LoS) that is predictable from the independent variables. In the context of hospital LoS prediction, \(R^{2}\) indicates how well the model's predictions approximate the actual outcomes [27].  
The coefficient of determination, \(R^{2}\), is a measure of how well the model explains the variability of the dependent variable. It is calculated by the following formula:  
\[R^{2}=1-\frac{\sum_{i=1}^{N}(\hat{y}-\overline{y})^{2}}{\sum_{i=1}^{N}(y_{i}- \overline{y})^{2}}, \tag{3}\]
* \(F1\)_Score_--a metric used to evaluate the performance of classification models, especially when dealing with imbalanced classes. It is the harmonic mean of precision and recall, providing a single score that balances both the concerns of false positives and false negatives. The formula for the F1 score is: \[F1\ Score=2\times\frac{Precision*Recall}{Precision+Recall},\] (4)
* Root Mean Squared Error (_RMSE_)--a widely used metric for evaluating the performance of regression models. It measures the average magnitude of the errors between predicted and actual values, taking the square root of the average squared differences. The _RMSE_ provides a way to quantify how far off a model's predictions are from the actual outcomes, and it is useful for comparing different models or understanding model performance in predicting hospital LoS.  
The formula for the _RMSE_ is:  
\[RMSE=\sqrt{\frac{1}{N}{\sum_{i=1}^{N}(\hat{y}-y_{i})}^{2}}, \tag{5}\]  
Understanding these metrics is essential for selecting the most appropriate model for specific healthcare scenarios and guiding the refinement of predictive strategies. Each metric offers unique insights into the model's performance, helping developers to evaluate not only the accuracy of predictions, but also their practical implications in healthcare settings.