# Regressive Machine Learning for Real-Time Monitoring of Bed-Based Patients
## 2 Materials and Methods
### Models  
Following a review of various models, taking into account their performance, complexity, and susceptibility to overfitting, the decision was made to employ the Decision Tree Regressor, the Gradient Boosting Regressor, and the Bagging Regressor. The Bagging Regressor is an ensemble model that primarily uses the Decision Tree Regressor as its base regressor. Detailed descriptions of all three models are provided below.  
The Decision Tree Regressor (DTR) is a simple model that splits the data at certain thresholds to make predictions. The formula for a decision tree can be represented as  
\[Y=f(X)=\sum_{m=1}^{M}c_{m}I(x\in R_{m}), \tag{2}\]  
where \(Y\) is the output, \(X\) is the input, \(R_{m}\) are the regions of the data space that result from the splits, \(c_{m}\) are the constants (mean of the target variable in the region \(R_{m}\)), and \(I\) is the indicator function.  
The Gradient Boosting Regressor (GBR) is a more complex model that fits new predictors to the residual errors of the previous predictor. The formula for gradient boosting can be represented as:  
\[F_{m}(x)=F_{m-1}(x)+\sum_{j=1}^{J}\gamma_{jm}I(x\in R_{jm}), \tag{3}\]  
where \(F_{m}(x)\) is the boosted model at step \(m,F_{m-1}(x)\) is the boosted model at the previous step, \(R_{jm}\) are the regions of the data space that result from the splits, \(\gamma_{jm}\) are are the optimal coefficients, and \(I\) is the indicator function.  
The Bagging Regressor (BR) is an ensemble model that fits base regressors on each random subset of the original dataset and then aggregates their individual predictions to form a final prediction. The formula for bagging can be represented as  
\[F(x)=\frac{1}{B}\sum_{b=1}^{B}f_{b}(x), \tag{4}\]  
where \(F(x)\) is the final prediction, \(B\) is the number of base regressors, and \(f_{b}(x)\) is the base regressor. In the context of a BR, base regressors are the individual models that are trained on different subsets of the original dataset. The final prediction of the BR is typically an average of the predictions made by each of these base regressors. In this study, the number of base regressors (\(B\)) is 50. It means that the BR is training 50 separate instances of its base regressor on different subsets of the data. These 50 models collectively make up the BR. In Python, BR is implemented using the DTR as the base regressor. BR enhances the performance of DTR by reducing overfitting and improving prediction accuracy.  
The default hyperparameters, as provided by the Python libraries for the DTR, GBR, and BR methods, were employed in this study. This selection was based on a series of experiments involving various parameters, none of which demonstrated a significant improvement over the default settings. These default hyperparameters, having been well optimized and extensively tested by the ML community, were deemed appropriate. By adhering to these default settings, a simpler methodology was maintained without sacrificing the results, which is considered beneficial at this stage for facilitating easier reproducibility and replicability of the study.