## 4 Prediction of Progress in Rehabilitation--Predictive Model
### Methodology
During training, the cost function \(L\left(Y_{target},Y_{pred}\right)\) is minimized  
\[\mathrm{L}(Y_{target},Y_{pred})=\frac{1}{N}\sum_{i=1}^{N}\ell(y_{i},\hat{y}_{ i}), \tag{2}\]  
where \(\ell\) means the chosen error metric (e.g., MSE for regression), \(y_{i}\) represents the actual values, \(\hat{y}_{i}\) are the values predicted by the model, and \(N\) is the number of samples. During training, the model parameters \(\theta\) are updated according to an optimization algorithm, such as the simple gradient descent method  
\[\theta\leftarrow\theta-\alpha\
abla_{\theta}L\left(Y_{target},Y_{pred}\right), \tag{3}\]  
where \(\alpha\) represents the learning rate. Goal: Minimize errors in training data. * Validation:  
Based on the validation results, model parameters may be adjusted, or training may be stopped to avoid overfitting. Goal: Assess the model's ability to generalize to new data. * Testing:  
The test data are separate from the training and validation data, allowing for an unbiased evaluation of the model's effectiveness. The model is evaluated on validation and test sets to monitor generalization. The final value of the error function on the test set is given by \(L\left(Y_{test},\hat{Y}_{test}\right)\), which allows for assessing the model's effectiveness on unseen data. Goal: Provide an objective measure of the model's quality on data not seen during training. 6. Training Process Evaluation: In this step, the training process is evaluated for accuracy in three stages: training, validation, and testing. The model is evaluated using appropriate metrics for prediction errors to understand its ability to generalize as follows: * For regression: _MSE_ (Mean Squared Error), _RMSE_ (Root Mean Squared Error), _MAE_ (Mean Absolute Error). The expression for _MSE_, _RMSE_, and _MAE_ is given as [24] \[MSE=\frac{1}{N}\sum_{i=1}^{N}(y_{i}-\hat{y}_{i})^{2},\ \ \ RMSE=\sqrt{MSE},\ \ \ MAE=\frac{1}{N}\sum_{i=1}^{N}|y_{i}-\hat{y}_{i}|.\] (4) * For classification: accuracy, precision, recall, F1-score, and ROC AUC. * The final evaluation of the learning process is based on the fit between the output data and target data, measured using the fit coefficient and R-value. 7. Simulation: After achieving a satisfactory model, it can be implemented to predict new data. In MATLAB, the obtained model can be used for predictions on new data using dedicated functions. For this process, simulation data (which also consists of input and target data) is used, but for the simulation itself, only input data are utilized. The results from the output data from the simulation (sim output data). The optimal model \(M^{\star}\), tested on the simulation set \(X_{sim}\), generates predictions \(Y_{sim}=M(X_{sim})\), which are continuous if the regression methods were used. 8. Conversion of Continuous Results to Discrete Form The simulation results (sim output data) from regression methods are in a continuous form. It is therefore necessary to convert them to a discrete form. This can be achieved using an appropriate algorithm or function. The simplest way to convert continuous results to discrete was to round the values to the nearest integer. Another approach was to define specific value ranges to represent particular discrete values. Ultimately, the simulation process produced results in a discrete form (sim-d output data). The simulation results \(Y_{sim}\) are transformed into discrete data \(Y_{sim-d}\) using the following: * Rounding: Rounding the continuous values to the nearest integer \[Y_{sim-d}=round(Y_{sim}).\] (5) * Assigning to Intervals: The values in \(Y_{sim}\) are assigned to intervals corresponding to integer values using the function \(P\), where \(P(Y_{sim})\) returns discrete intervals. 9. Simulation Evaluation--Final Assessment of Model Performance Once the simulation results \(Y_{sim-d}\) are converted to a discrete form, they are compared with the actual target values.