A Bayesian-Optimized Heterogeneous Stacking Framework with Comparative Explainable AI for Hepatitis B Diagnostic Support
Abstract
Hepatitis B diagnosis requires the combined interpretation of viral-load markers, biochemical parameters, demographic information, and clinical symptoms. Developing a reliable machine-learning model for this purpose is challenging when the available clinical dataset is small and model development involves architecture selection, hyperparameter optimization, threshold selection, and explainability analysis. This study developed Bayes Stack-HBV, a Bayesian-optimized heterogeneous stacking framework intended to provide internally validated decision support for hepatitis B classification. The framework used nine predictors comprising two hundred sixteen patient records and combined heterogeneous base learners through an Elastic Net-regularized logistic meta-learner. Model architecture and hyperparameters were optimized using 40 Optuna trials within each outer-fold training set. Performance was evaluated using repeated nested cross-validation with three random seeds, five outer folds, and three inner folds. Preprocessing, SMOTE, model optimization, and decision-threshold selection were restricted to the training and inner-validation data. Bayes Stack-HBV was compared with Default Stack-HBV, Hist Gradient Boosting, Support Vector Machine, Extra Trees, Logistic Regression, and K-Nearest Neighbors. Calibration, paired statistical comparisons, and multi-method explainability analyses were performed using held-out predictions. Across 15 held-out outer-fold evaluations, Bayes Stack-HBV achieved an accuracy of 0.9337 ± 0.0324, balanced accuracy of 0.9357 ± 0.0307, precision of 0.9659 ± 0.0383, sensitivity of 0.9114 ± 0.0670, specificity of 0.9600 ± 0.0471, F1-score of 0.9357 ± 0.0331, MCC of 0.8728 ± 0.0602, ROC-AUC of 0.9844 ± 0.0162, PR-AUC of 0.9892 ± 0.0103, and Brier score of 0.0428 ± 0.0188. Bayes Stack-HBV ranked first on seven of ten mean evaluation measures, indicating a strong specificity- and calibration-oriented performance profile. However, differences relative to the strongest ensemble comparators were not statistically significant after multiple-comparison correction. Explainability analysis identified HBVDNA and ALT Level as influential predictors, supported by expanded explanation-stability and feature-dependency analyses. Bayes Stack-HBV provides promising preliminary evidence as a threshold-aware and interpretable framework for HBV decision support. Its clinical utility and threshold transportability require confirmation through larger, independent, multicenter, and prospective validation studies.