# An Optimization Precise Model of Stroke Data to Improve Stroke Prediction
## 3 The Computational Findings
### The Random Forest Model  
The random forest model is commonly used to solve classification tasks in data analytics problems. It uses three main parameters--node size, number of trees, and number of features sampled. The method is applied because it can work with large datasets and is simple to understand. The model also provides a high level of predicting outcomes within classification tasks.  
Before defining a model, we apply the resampling procedure with parameters \"replace = True\", and \"n_samples = 1500\" (random_state = 158)) on the minority class; it obtained the following number of observations in each class: class 0-2814 and class 1-1500.  
Applying train_test_split with test_size = 0.5 and random_state = 115 on the new set with 4314 observations, we obtained the training subset and the test subset. We are ready to define a random forest model: RandomForestClassifier (class_weight = 'balanced').  
\begin{table}
\begin{tabular}{c c c} \hline \hline  & **Predicted: NO** & **Predicted: YES** \\ \hline Actual: NO & TN & FN \\ Actual: YES & FP & TP \\ \hline \hline \end{tabular}
\end{table}
Table 2: Structure of a confusion matrix.  
We compute the confusion matrix described in Table 3 and the classification report on the test set to estimate the model fitted on the train subset. Our model used a smaller number of observations from the class \"1\" and obtained larger values of estimated parameters as can be seen in the classification report given in Table 4. The high values of the recall parameter for both classes (0.960 and 0.997) show they were well predicted. In addition, our algorithm uses less computational work to obtain these values.  
Consider the results obtained by [PERSON] and [PERSON] in their paper [18] with the random forest model. The estimated parameters had the following values: the accuracy was 73%, the precision value was 72%, and the recall value was 73.5%. Obviously, these values are smaller than the corresponding values from Table 4 that we achieved.  
[PERSON] and [PERSON] [19] proposed a new approach to model stroke risk based on the Synthetic Minority Over-sampling Technique in the short SMOTE [27] scheme. After data preprocessing, several models are constructed, for example, random forest and decision tree. Finally, they construct the ensemble by combining some learning models. They have used the ensemble to fit it on the train subset and make predictions on the test subset. The random forest model applied by [PERSON] and [PERSON] achieved the values: accuracy 0.98, precision 0.974, and recall 0.974 (Table 3, [19]), and the AUC average value was 0.986 (Table 2, [19]).  
Our model achieved a recall value for the positive class of 0.997 and 0.979 for the AUC parameter. The model accurately predicted whether the patient suffered from stroke or not. The ROC curve can be seen in Figure 2.  
\begin{table}
\begin{tabular}{c c c} \hline \hline  & **Classification Report ([17], Figure 12)** & **Our Experiment** \\ \hline Accuracy & 0.95993 & 0.9731 \\ Precision (Class 1) & 0.94993 & 0.9985 \\ Precision (Class 2) & 0.97033 & 0.9283 \\ Recall (Class 1) & 0.97086 & 0.9608 \\ Recall (Class 2) & 0.94904 & 0.9972 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Random Forest Classifier. Classification reports comparison.  
Figure 2: Random Forest, a ROC curve.