Submitted:
18 July 2025
Posted:
18 July 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
- We address the class imbalance challenge by exclusively applying under-sampling in combination with k-fold cross-validation. This approach preserves as much informative content as possible while promoting robust and unbiased model evaluation.
- This study proposes a revised class grouping to reduce imbalance and better reflect clinical realities. By merging related classes and evaluating models under both original and modified structures, we improve the robustness and applicability of thyroid disease prediction.
- Our study conducts a comparative analysis of different models, demonstrating that ensemble techniques significantly improve predictive accuracy and handle data complexity more effectively, achieving up to 99.44% accuracy.
2. Background
2.1. Models
2.1.1. Random Forest
2.1.2. XGBoost
2.1.3. Bagging
2.1.4. Stacking
2.2. 5-Fold Cross-Validation
2.3. Evaluation Metrics
2.3.1. Accuracy
- (True Positives) represents the number of positive instances correctly classified.
- (True Negatives) represents the number of negative instances correctly classified.
- (False Positives) represents the number of negative instances incorrectly classified as positive.
- (False Negatives) represents the number of positive instances incorrectly classified as negative.
- Number of Correct Predictions is the sum of true positives for all classes.
- Total Number of Predictions is the total number of instances in the dataset.
2.3.2. Precision
2.3.3. Weighted-Averaged Precision
2.3.4. Recall
2.3.5. Weighted-Average Recall
2.3.6. F1 Score
2.3.7. Weighted-Average F1 Score
2.4. Workflow
3. Experiments
3.1. Data Collection
- TSH (Thyroid-Stimulating Hormone): Produced by the pituitary gland, TSH stimulates the thyroid to produce the hormones T3 and T4.
- T3 (Triiodothyronine): One of the primary hormones produced by the thyroid gland, T3 plays a crucial role in the regulation of metabolism.
- TT4 (Total Thyroxine): This measures the total amount of thyroxine (T4) in the blood, including both free and protein-bound forms.
- T4U (Thyroxine-Binding Globulin Uptake): T4U evaluates the binding capacity of thyroid hormones by measuring how much TBG is available in the blood.
- FTI (Free Thyroxine Index): A calculated value that estimates the free (unbound) thyroxine (T4) level by combining the results of TT4 and T4U.
- TBG (Thyroxine-Binding Globulin): A protein that binds to thyroid hormones in the blood, playing a role in transporting them and regulating the amount of free hormones available for use.
3.2. Feature Selection
3.3. Results
3.3.1. Comparison on Imbalanced Data
3.3.2. Comparison on Balanced Data
3.3.3. Comparison on Non-Thyroidal and Thyroidal Condition
4. Discussions
5. Limitation and Future Development
6. Conclusions
References
- Boelaert, K.; Franklyn, J. Thyroid hormone in health and disease. Journal of Endocrinology 2005, 187, 1–15. [Google Scholar] [CrossRef] [PubMed]
- Shankar, K.; Lakshmanaprabu, S.; Gupta, D.; Maseleno, A.; De Albuquerque, V.H.C. Optimal feature-based multi-kernel SVM approach for thyroid disease classification. The journal of supercomputing 2020, 76, 1128–1143. [Google Scholar] [CrossRef]
- Manji, N.; Carr-Smith, J.; Boelaert, K.; Allahabadia, A.; Armitage, M.; Chatterjee, V.; Lazarus, J.; Pearce, S.; Vaidya, B.; Gough, S.; et al. Influences of age, gender, smoking, and family history on autoimmune thyroid disease phenotype. The Journal of Clinical Endocrinology & Metabolism 2006, 91, 4873–4880. [Google Scholar] [CrossRef]
- Strieder, T.G.; Prummel, M.F.; Tijssen, J.G.; Endert, E.; Wiersinga, W.M. Risk factors for and prevalence of thyroid disorders in a cross-sectional study among healthy female relatives of patients with autoimmune thyroid disease. Clinical endocrinology 2003, 59, 396–401. [Google Scholar] [CrossRef] [PubMed]
- Chaubey, G.; Bisen, D.; Arjaria, S.; Yadav, V. Thyroid disease prediction using machine learning approaches. National Academy Science Letters 2021, 44, 233–238. [Google Scholar] [CrossRef]
- Tyagi, A.; Mehra, R.; Saxena, A. Interactive thyroid disease prediction system using machine learning technique. In Proceedings of the 2018 Fifth international conference on parallel, distributed and grid computing (PDGC). IEEE; 2018; pp. 689–693. [Google Scholar] [CrossRef]
- Aversano, L.; Bernardi, M.L.; Cimitile, M.; Iammarino, M.; Macchia, P.E.; Nettore, I.C.; Verdone, C. Thyroid disease treatment prediction with machine learning approaches. Procedia Computer Science 2021, 192, 1031–1040. [Google Scholar] [CrossRef]
- Quinlan, R. Thyroid Disease. UCI Machine Learning Repository, 1986. [CrossRef]
- Raisinghani, S.; Shamdasani, R.; Motwani, M.; Bahreja, A.; Raghavan Nair Lalitha, P. Thyroid Prediction Using Machine Learning Techniques. In Proceedings of the Advances in Computing and Data Sciences; Singh, M., Gupta, P., Tyagi, V., Flusser, J., Ören, T., Kashyap, R., Eds.; Singapore, 2019; pp. 140–150. [Google Scholar] [CrossRef]
- Tyagi, A.; Mehra, R.; Saxena, A. Interactive Thyroid Disease Prediction System Using Machine Learning Technique. In Proceedings of the 2018 Fifth International Conference on Parallel, Distributed and Grid Computing (PDGC); 2018; pp. 689–693. [Google Scholar] [CrossRef]
- Zheng, Z.; Cai, Y.; Li, Y. Oversampling method for imbalanced classification. Computing and Informatics 2015, 34, 1017–1037. [Google Scholar]
- Thabtah, F.; Hammoud, S.; Kamalov, F.; Gonsalves, A. Data imbalance in classification: Experimental evaluation. Information Sciences 2020, 513, 429–441. [Google Scholar] [CrossRef]
- Pan, Q.; Zhang, Y.; Zuo, M.; Xiang, L.; Chen, D. Improved Ensemble Classification Method of Thyroid Disease Based on Random Forest. In Proceedings of the 2016 8th International Conference on Information Technology in Medicine and Education (ITME); 2016; pp. 567–571. [Google Scholar] [CrossRef]
- Mahajan, P.; Uddin, S.; Hajati, F.; Moni, M.A. Ensemble learning for disease prediction: A review. In Proceedings of the Healthcare; MDPI, 2023; Vol. 11, p. 1808. [Google Scholar] [CrossRef]
- Yadav, D.C.; Pal, S. Prediction of thyroid disease using decision tree ensemble method. Human-Intelligent Systems Integration 2020, 2, 89–95. [Google Scholar] [CrossRef]
- Obaido, G.; Achilonu, O.; Ogbuokiri, B.; Amadi, C.S.; Habeebullahi, L.; Ohalloran, T.; Chukwu, C.W.; Mienye, E.; Aliyu, M.; Fasawe, O.; et al. An Improved Framework for Detecting Thyroid Disease Using Filter-Based Feature Selection and Stacking Ensemble. IEEE Access 2024. [Google Scholar] [CrossRef]
- Breiman, L. Random forests. Machine Learning 2001, 45, 5–32. [Google Scholar] [CrossRef]
- Biau, G.; Scornet, E. A random forest guided tour. Test 2016, 25, 197–227. [Google Scholar] [CrossRef]
- Dudek, G. A Comprehensive Study of Random Forest for Short-Term Load Forecasting. Energies 2022, 15, 7547. [Google Scholar] [CrossRef]
- Chen, T.; Guestrin, C. Xgboost: A scalable tree boosting system. In Proceedings of the Proceedings of the 22nd acm sigkdd international conference on knowledge discovery and data mining, 2016, pp. 785–794. [CrossRef]
- Breiman, L. Bagging predictors. Machine learning 1996, 24, 123–140. [Google Scholar] [CrossRef]
- Quinlan, J.R.; et al. Bagging, boosting, and C4. 5. In Proceedings of the Aaai/Iaai, vol. 1; 1996; pp. 725–730. [Google Scholar]
- Shorewala, V. Early detection of coronary heart disease using ensemble techniques. Informatics in Medicine Unlocked 2021, 26, 100655. [Google Scholar] [CrossRef]
- Singh, N.; Singh, P. A stacked generalization approach for diagnosis and prediction of type 2 diabetes mellitus. In Proceedings of the Computational Intelligence in Data Mining: Proceedings of the International Conference on ICCIDM 2018.; Springer, 2020; pp. 559–570. [Google Scholar] [CrossRef]

| Feature | Definition |
|---|---|
| age | The patient’s age |
| sex | Sex which the patient identifies with |
| on thyroxine | If the patient is currently taking thyroxine |
| query on thyroxine | If there is a question about the patient taking thyroxine |
| on antithyroid meds | If the patient is currently on antithyroid medications |
| sick | If the patient is currently unwell |
| pregnant | If the patient is pregnant |
| thyroid surgery | If the patient has had thyroid surgery in the past |
| I131 treatment | If the patient is receiving I131 treatment |
| query hypothyroid | If the patient thinks they have hypothyroidism |
| query hyperthyroid | If the patient thinks they have hyperthyroidism |
| lithium | If the patient is on lithium treatment |
| goitre | If the patient has an enlarged thyroid (goitre) |
| tumor | If the patient has a tumor |
| hypopituitary | If the patient has an underactive pituitary gland |
| psych | If the patient has a psychological condition |
| TSH | Thyroid-stimulating hormone level in the patient’s blood |
| T3 | Triiodothyronine (T3) level in the patient’s blood |
| TT4 | Total thyroxine (TT4) level in the patient’s blood |
| T4U | Thyroxine uptake (T4U) level in the patient’s blood |
| FTI | Free Thyroxine Index (FTI) level in the patient’s blood |
| Category | Definition |
|---|---|
| - | No condition |
| A | Hyperthyroid |
| F | Primary hypothyroid |
| G | Compensated hypothyroid |
| K | Concurrent non-thyroidal illness |
| Algorithms | Accuracy | Precision | Recall | F1 score |
|---|---|---|---|---|
| Logistic Regression | 0.9290 | 0.9262 | 0.9290 | 0.9241 |
| Decision Tree | 0.9665 | 0.9674 | 0.9665 | 0.9665 |
| Random Forest | 0.9753 | 0.9770 | 0.9753 | 0.9740 |
| Xgboost | 0.9753 | 0.9767 | 0.9753 | 0.9756 |
| SVM | 0.9331 | 0.9329 | 0.9331 | 0.9298 |
| Artificial Neural Network | 0.9430 | 0.9429 | 0.9430 | 0.9427 |
| Bagging 3dt | 0.9761 | 0.9782 | 0.9761 | 0.9766 |
| Bagging 3rf | 0.9719 | 0.9739 | 0.9719 | 0.9724 |
| Bagging 3xgb | 0.9739 | 0.9759 | 0.9739 | 0.9744 |
| Stacking 3rf+rf | 0.9716 | 0.9728 | 0.9716 | 0.9719 |
| Stacking 3rf+xgb | 09689 | 0.9704 | 0.9689 | 0.9694 |
| Stacking 3xgb+xgb | 0.9603 | 0.9635 | 0.9603 | 0.9612 |
| Algorithms | Accuracy | Precision | Recall | F1 score |
|---|---|---|---|---|
| Logistic Regression | 0.8724 | 0.8781 | 0.8724 | 0.8700 |
| Decision Tree | 0.9695 | 0.9700 | 0.9695 | 0.9695 |
| Random Forest | 0.9763 | 0.9772 | 0.9763 | 0.9761 |
| Xgboost | 0.9729 | 0.9738 | 0.9729 | 0.9728 |
| SVM | 0.9063 | 0.9096 | 0.9063 | 0.9056 |
| Artificial Neural Network | 0.9199 | 0.9220 | 0.9199 | 0.9195 |
| Bagging 3dt | 0.9763 | 0.9769 | 0.9763 | 0.9762 |
| Bagging 3rf | 0.9661 | 0.9676 | 0.9661 | 0.9661 |
| Bagging 3xgb | 0.9650 | 0.9659 | 0.9650 | 0.9648 |
| Stacking 3rf+rf | 0.9763 | 0.9771 | 0.9763 | 0.9762 |
| Stacking 3rf+xgb | 0.9786 | 0.9792 | 0.9786 | 0.9785 |
| Stacking 3xgb+xgb | 0.9842 | 0.9851 | 0.9842 | 0.9842 |
| Algorithms | Accuracy | Precision | Recall | F1 score |
|---|---|---|---|---|
| Logistic Regression | 0.9029 | 0.9030 | 0.9029 | 0.8956 |
| Decision Tree | 0.9921 | 0.9924 | 0.9921 | 0.9921 |
| Random Forest | 0.9921 | 0.9924 | 0.9921 | 0.9921 |
| Xgboost | 0.9921 | 0.9925 | 0.9921 | 0.9921 |
| SVM | 0.9402 | 0.9409 | 0.9402 | 0.9376 |
| Artificial Neural Network | 0.9560 | 0.9571 | 0.9560 | 0.9558 |
| Bagging 3dt | 0.9932 | 0.9936 | 0.9932 | 0.9932 |
| Bagging 3rf | 0.9887 | 0.9892 | 0.9887 | 0.9887 |
| Bagging 3xgb | 0.9910 | 0.9914 | 0.9910 | 0.9909 |
| Stacking 3rf+rf | 0.9887 | 0.9891 | 0.9887 | 0.9887 |
| Stacking 3rf+xgb | 0.9921 | 0.9931 | 0.9921 | 0.9923 |
| Stacking 3xgb+xgb | 0.9944 | 0.9949 | 0.9944 | 0.9944 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).