## 4 Prediction of Progress in Rehabilitation--Predictive Model  
### Methodology  
To predict the progress in patients' health following post-stroke rehabilitation, machine learning methods in the MATLAB vR2023b environment were utilized. The predictive modeling study involves several key steps. Below is an overview of the process:  
1. Data Collection:  
The first step is gathering data for training and testing the model. These data may include patient information as parameters \(X=\{x_{1,X_{2}},\ldots,x_{m}\}\), where \(x_{i}\) represents age, gender, depression level, and health outcomes measured on various scales such as RMA1, RMA2, RMA3, and ADL. Results before rehabilitation are marked as \(X_{pre}\) and after rehabilitation as \(X_{post}\). Ensuring the quality of the collected data is crucial to verify that it is representative of the studied population and free of errors. 2. Data Preparation:  
The collected data are processed in several steps as follows:  
* Data cleaning, which includes removing errors and filling in missing values. The dataset before cleaning is \(X\) and after \(X_{clean}\). * Normalization or standardization \(x_{i}^{\prime}\) of data to ensure consistency and facilitate model training. \[x_{i}^{\prime}=\frac{x_{i}-\mu_{i}}{\sigma_{i}}\] (1) where \(\mu\) and \(\sigma\)\(i\)\(\sigma_{i}\) means the value and deviation of the standard deviation \(x\) and \(x_{i}\). * Feature engineering, which involves creating new variables \(f(X)=f_{1},f_{2},\ldots,f_{k}\) from existing data. 3. Data Splitting  
The data \(X_{clean}\) is split into two sets: a training set, \(X_{train}\), and a simulation dataset, \(X_{sim}\). The training set is used for training and adjusting the model parameters, while the simulation set is used later to assess the model's performance on new data that it has not seen before. Training set \(X_{train}\) with corresponding labels \(Y_{train}\), used to optimize the model parameters. Simulation set \(X_{sim}\), used to evaluate the model on data that the model has not seen before. The sets are disjoint, i.e., \(X_{train}\ \bigcap\ X_{sim}=\varnothing\). Model Selection:  
Before training, different predictive models are tested, such as decision trees, logistic regression, Random Forest, and XGBoost. These models are evaluated based on their ability to predict the outcome variables such as RMA1, RMA2, RMA3, and ADL. The tested predictive models, denoted as \(M=\{M_{1},M_{2},\ldots,M_{k}\}\), are evaluated based on their ability to predict the output variables \(Y=\{RMA1,RMA2,RMA3,ADL\}\). In the first stage, the type of prediction to be applied is determined--classification or regression--depending on whether the expected output is discrete or continuous. While data in the current analysis is discrete, continuous data produced by regression methods can be converted into discrete form through appropriate transformations. These transformations are carried out at the simulation stage. On this step, the following variables were determined:  
* For classification: the predicted output values \(Y_{pred}\) take on discrete values. * For regression: the predicted values \(Y_{pred}\) are continuous and may later be transformed into discrete values during the stage of transforming simulation results. During the research, several predictive models with varying input and output data structures, as well as different parameters, were tested. Model Training:  
The training data are split into input and target data. There are three distinct stages during training, each evaluated as follows:  
* Training:  
Data are passed through the network, and weights are updated according to a learning algorithm (such as feedforward backpropagation). The aim is to adjust the model to best represent the relationships in the training data. The training set \(X_{train}\) is divided into an input dataset \(X_{in}\) and an output dataset \(Y_{target}\).