5. Experimental Results and Analysis
This section presents the experimental results obtained from the comparative evaluation of the four machine learning models (Random Forest, Multinomial Naive Bayes, Logistic Regression, and Support Vector Machine) applied to classifying textual medical notes into four disease categories. All experiments were conducted using the scikit-learn library in Python, which provides reliable and standardized implementations of machine learning algorithms and evaluation tools [
34]. Each model was trained and optimized using the best hyperparameter configurations determined through cross-validation, as detailed in
Section 4.1-4.4. The experiments were conducted on the preprocessed dataset containing 9,633 labeled records. The evaluation focuses on multiple performance metrics, including accuracy, precision, recall, and F1-score, computed in both macro- and weighted-averaged forms. The following subsections present detailed results for each model, followed by a comparative analysis highlighting their relative strengths, weaknesses, and suitability for medical text classification tasks.
5.1. Random Forest Classification Model Evaluation
The Random Forest (RF) classifier was trained and optimized through grid search with 5-fold cross-validation to identify the most effective parameter configuration. The best performing model was obtained with the following parameters: bootstrap = True, max_depth = None, max_features = ’sqrt’, min_samples_leaf = 4, min_samples_split = 2, and n_estimators = 400. This configuration allows the model to grow deep trees with random feature subsets while maintaining generalization through leaf size regularization.
The confusion matrix in
Table 2 shows how the Random Forest model’s predictions are distributed across the four disease categories on the test set.
We can see that 290 notes of Neoplasms (Class 1), 87 notes of Digestive System Diseases (Class 2), 125 notes of Nervous System Diseases (Class 3), and 271 notes of Cardiovascular Diseases (Class 4) were correctly classified. While 32 notes of Digestive System Diseases (Class 2) and 30 notes of Nervous System Diseases (Class 3) were misclassified into Neoplasms (Class 1), 38 notes of Nervous System Diseases (Class 3) were misclassified into Cardiovascular Diseases (Class 4), likely due to overlapping terminology in clinical text.
Table 3 summarizes the classification report, which includes class-wise precision, recall, F1-score, and support.
Among all categories, Neoplasms (Class 1) and Cardiovascular Diseases (Class 4) achieved the highest recall values (0.90 and 0.89), showing that the model effectively identified these disease types. In contrast, Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3) had lower recall values (0.60 and 0.64), reflecting greater confusion with other classes. The high precision for Digestive System Diseases (0.84) and Cardiovascular Diseases (0.82) demonstrates its reliability in avoiding false positives, while the strong recall for Neoplasms highlights its ability to correctly identify oncological notes.
Overall, the Random Forest classifier performed competitively across all metrics, establishing a strong baseline for textual medical note classification.
5.2. Naive Bayes Model Evaluation
The Multinomial Naive Bayes (MNB) classifier was evaluated after hyperparameter tuning using 5-fold cross-validation, which identified the optimal settings as and fit_prior = False. This configuration provided the best balance between bias and variance, preventing over-smoothing while allowing the model to rely primarily on the word distribution within each disease class. The final model was trained using these optimal parameters and evaluated on the held-out test set of 964 medical notes.
Table 4 presents the confusion matrix of the Naive Bayes classifier, which illustrates how the model classified the four disease categories based on word-occurrence probabilities.
The matrix shows that Cardiovascular Diseases (Class 4) and Neoplasms (Class 1) were predicted most accurately, with relatively few misclassified samples. In contrast, Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3) show moderate confusion with other categories, likely because of overlapping medical terminology and common clinical symptoms in the textual data.
Table 5 lists the classification report, which includes class-wise precision, recall, F1-score, and support.
The classification report provides a quantitative summary of model performance. The model achieved an overall accuracy of 0.80. Neoplasms (Class 1) and Cardiovascular Diseases (Class 4) achieved the highest precision (0.86 and 0.84, respectively) and recall (0.79 and 0.86), demonstrating that the Naive Bayes model effectively distinguishes these well-defined disease categories. In contrast, Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3) yielded slightly lower recall values (0.75 each), suggesting moderate misclassification between these two categories. Naive Bayes obtained a macro-averaged precision of 0.78, recall of 0.79, and F1-score of 0.78, while the weighted averages were all approximately 0.80.
Overall, the Multinomial Naive Bayes classifier produced balanced results with strong overall accuracy and consistent weighted averages across all metrics. Its efficiency and simplicity make it a reliable baseline model for multiclass medical note classification, particularly when computational efficiency and interpretability are desired.
5.3. Logistic Regression Model Evaluation
The Logistic Regression (LR) classifier was evaluated after extensive hyperparameter optimization using 5-fold cross-validation. The best configuration was obtained with the parameters: C = 1, class_weight = None, l1_ratio = 0.5, max_iter = 1000, multi_class = ’multinomial’, penalty = ’elasticnet’, and solver = ’saga’. This combination of elastic-net regularization and the SAGA solver provided a balanced control of both L1 and L2 penalties, enabling the model to handle sparse features while maintaining good generalization. The multinomial formulation was chosen to directly optimize the cross-entropy loss for the four disease categories.
The confusion matrix in
Table 6 summarizes the classifier’s predictions across the four disease categories on the test set.
Most Neoplasms (Class 1) and Cardiovascular Diseases (Class 4) notes were correctly identified, demonstrating the model’s effectiveness in detecting strong class-specific textual patterns. Moderate confusion occurred between Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3), likely due to shared terminology and overlapping clinical contexts in medical narratives.
The detailed performance metrics are shown in
Table 7, presenting class-wise precision, recall, F1-score, and support.
The classification report shows the Logistic Regression classifier achieved an overall accuracy of 0.83. Cardiovascular Diseases (Class 4) and Neoplasms (Class 1) obtained the highest recall values of 0.88 and 0.87, respectively, indicating strong discriminative capability for these categories. Neoplasms (Class 1) also performed strongly with an F1-score of 0.85, while Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3) showed slightly lower recall values (0.70 and 0.76, respectively), suggesting partial overlap in their textual characteristics. Logistic Regression achieved a macro-averaged precision of 0.82, recall of 0.81, and F1-score of 0.81, with weighted averages of 0.83 across all metrics.
Overall, the Logistic Regression model demonstrated robust and consistent performance across all categories. Its high accuracy and balanced precision-recall scores confirm its effectiveness for multiclass text classification of medical notes. The model’s interpretability and well-calibrated probability estimates further highlight its suitability for clinical NLP tasks, establishing it as the best-performing approach among the four models evaluated.
5.4. Support Vector Machine Classification Model Evaluation
The Support Vector Machine (SVM) classifier was trained and optimized using grid search with 5-fold cross-validation. The optimal configuration was identified as C = 1, class_weight = None, and kernel = ’linear’. The linear kernel was selected because it provided the best balance between classification accuracy and computational efficiency, particularly for the high-dimensional sparse feature space derived from the vectorized medical text. The regularization parameter () offered a suitable trade-off between maximizing the margin and minimizing classification error, while maintaining stable convergence across folds.
Table 8 presents the confusion matrix, which summarizes the model’s predictions across the four disease categories on the test set.
Most Neoplasms (Class 1) and Cardiovascular Diseases (Class 4) were correctly identified, while moderate confusion occurred between Digestive System Diseases (Class 2) and Nervous System Diseases (Class 3). This overlap likely results from shared medical terminology and similar contextual patterns in the clinical text.
The performance metrics in
Table 9 reveal balanced precision, recall, and F1-scores across all categories.
The classification report indicates that the model achieved an overall accuracy of 0.80 on the test set. Cardiovascular Diseases (Class 4) achieved the highest precision and recall (0.86 and 0.87), demonstrating that the SVM effectively identified this category with minimal misclassification. Neoplasms (Class 1) also performed well, with an F1-score of 0.81. Nervous System Diseases (Class 3) attained a recall of 0.75, whereas Digestive System Diseases (Class 2) showed slightly lower recall (0.70), with some overlap into the Neoplasms category, which is an expected outcome given the linguistic similarity of pathological terms across gastrointestinal and neoplastic conditions.
Overall, the Support Vector Machine classifier showed stable performance across all metrics. Its ability to handle high-dimensional, sparse textual features made it particularly suitable for this dataset. The results confirm that SVM offers a robust balance between predictive accuracy and generalization, establishing it as a competitive model for textual medical note classification.
5.5. Model Comparison and Discussion
The comparative performance analysis of the four machine learning models, i.e., Random Forest (RF), Multinomial Naive Bayes (MNB), Logistic Regression (LR), and Support Vector Machine (SVM), revealed consistent and competitive results across all approaches. Each algorithm achieved a strong level of predictive accuracy on the test set, demonstrating that traditional machine learning techniques remain effective for multiclass medical text classification when supported by comprehensive feature preprocessing.
Table 10 summarizes the overall classification accuracy of the four models.
Among the evaluated models, Logistic Regression achieved the highest overall accuracy (0.83) and the best weighted F1-score, indicating that it effectively captured linear decision boundaries within the vectorized text representation. The use of elastic-net regularization allowed the model to balance sparsity and complexity, reducing overfitting while maintaining interpretability.
Random Forest, Support Vector Machine, and Multinomial Naive Bayes classification models achieved similar accuracies (0.80), demonstrating stable and reliable performance across all disease categories. Random Forest showed strong recall for Neoplasms and Cardiovascular Diseases, confirming its ability to model nonlinear relationships and handle noisy textual features. The linear SVM achieved balanced precision and recall by effectively separating high-dimensional sparse features using its margin-maximization principle. The Multinomial Naive Bayes classifier, though based on a simplifying independence assumption, performed competitively and remained the most computationally efficient, making it well suited for large-scale or real-time clinical applications.
Across all models, the best performance was observed for Cardiovascular Diseases and Neoplasms, where domain-specific terminology (e.g., “myocardial infarction,” “tumor,” “lesion”) provided clearer linguistic cues for classification. In contrast, Digestive System Diseases and Nervous System Diseases exhibited higher misclassification rates, likely due to overlapping vocabulary and symptom-related expressions such as “pain,” “treatment,” and “study.”
From a methodological perspective, Logistic Regression and SVM offered the best trade-off between accuracy, interpretability, and computational efficiency, while Random Forest provided valuable insight into feature importance. Overall, the comparable accuracy across all four models underscores the robustness of traditional machine learning methods for clinical text classification.