An Explainable Transformer-Based Machine Learning Framework for Bilirubin-Derived Severity Classification of Hepatitis B: A Cross-Domain Validation Study
Abstract
Background: Accurate and comprehensible severity evaluation is necessary for chronic hepatitis B (HBV), which continues to be a significant worldwide health concern. Complex nonlinear interactions among clinical biomarkers are frequently missed by conventional clinical ratings. Objective: Using a novel TabTransformer model, create and assess an explainable artificial intelligence (XAI) framework for four-class bilirubin-based hepatitis severity categorization. Methods: Patients were categorized into Low, Mild, Moderate, and Severe bilirubin-based groups using the UCI Hepatitis dataset (N = 155). MICE was used to impute missing values. Using stratified five-fold cross-validation, the suggested TabTransformer was contrasted with Logistic Regression, SVM, Random Forest, Gradient Boosting, AdaBoost, and MLP. The Indian Liver Patient Dataset (ILPD, N = 583) was used for external validation. SHAP and permutation feature significance were used to assess the model's interpretability. Results: The TabTransformer outperformed all baseline models, achieving 91.2% accuracy, 0.908 weighted F1-score, 0.961 macro-AUC-ROC, and a Brier score of 0.089. The Severe class has an AUC of 0.983, suggesting great discrimination despite the class imbalance. External validation showed good generality, and SHAP identified ascites, prothrombin time, and albumin as the most influential predictors, which is congruent with current clinical knowledge. Conclusions: The proposed explainable TabTransformer paradigm enhances hepatitis severity classification while making clinically meaningful predictions. These findings demonstrate the possibility of transformer-based tabular learning for liver disease risk classification; however, prospective multicenter validation is required before clinical use.