Diagnosis Prediction Model for Pediatric Appendicitis using Artificial Intelligence Transformer Model
This project develops an AI-based diagnosis prediction model for pediatric appendicitis using Transformer Models and compares it with traditional machine learning approaches (Decision Trees, Gradient Boosting, XGBoost).
├── 01_Data Audit/ # Data quality assessment
├── 02_Target Leak Control/ # Target leakage prevention
├── 03_Feature Categorization/ # Feature classification system
├── 04_Preprocessing Pipeline/ # Data preprocessing pipeline
├── 05_Transformer_Model/ # Transformer model implementation
├── 06_Decision_Trees/ # Decision Tree models
├── 07_Gradient_Boosting/ # Gradient Boosting models
├── 08_XGBoost/ # XGBoost models
├── 09_GUI_Application/ # User interface for predictions
├── Dataset 1/ # First dataset (images and Excel)
├── Dataset 2/ # Second dataset (CSV)
└── model_comparison.py # Model comparison script
- Multiple AI Models: Transformer, Decision Tree, Gradient Boosting, XGBoost
- Real Dataset Integration: Uses actual pediatric appendicitis datasets
- Interactive GUI: User-friendly interface for medical professionals
- Comprehensive Evaluation: Model comparison with medical statistics metrics
- Data Preprocessing: Automated pipeline for data cleaning and preparation
- Sensitivity (True Positive Rate): Ability to correctly identify appendicitis cases
- Specificity (True Negative Rate): Ability to correctly identify non-appendicitis cases
- PPV (Positive Predictive Value): Probability that positive prediction is correct
- NPV (Negative Predictive Value): Probability that negative prediction is correct
- For screening (high sensitivity needed): Transformer (77.20%)
- For confirmation (high specificity needed): XGBoost (95.36%)
- Consider ensemble approach for balanced performance
- Loads and manages pre-trained models
- Handles data preprocessing
- Provides prediction interface
- Interactive form for patient data input
- Real-time AI predictions with 4 model options
- Medical interpretation of results
- Features: scroll wheel support, temperature scaling for Transformer
- Individual training scripts for each model type
- Comprehensive evaluation metrics
- Feature importance analysis
- Dataset 1: Pediatric appendicitis cases with imaging data
- Dataset 2: Regensburg Pediatric Appendicitis dataset (782 samples)
- Pediatric patients (<18 years old)
- Suspected acute appendicitis cases
| Model | Accuracy | Sensitivity | Specificity | PPV | NPV | Best Use Case |
|---|---|---|---|---|---|---|
| XGBoost | 85.30% | 68.91% | 95.36% | 90.11% | 83.33% | High specificity |
| Decision Tree | 84.98% | 73.95% | 91.75% | 84.62% | 85.17% | Balanced performance |
| Gradient Boosting | 84.98% | 69.75% | 94.33% | 88.30% | 83.56% | High PPV |
| Transformer | 77.00% | 77.20% | 71.43% | 98.68% | 10.20% | High sensitivity |
- April 4: 96.4% specificity (CrossEntropyLoss)
- April 25: 71.4% specificity (BCEWithLogitsLoss with pos_weight)
- Trade-off: Improved sensitivity (69.8% → 77.2%) at cost of specificity
- Python 3.8+
- Required packages listed in requirements.txt
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
cd 09_GUI_Application
python prediction_gui.py- Launch the GUI application
- Select desired AI model
- Input patient data
- Get AI-powered diagnosis prediction
- Review medical interpretation
- AI Expert: Model training and evaluation
- Medical Expert: System validation and diagnosis review
- Medical Student: Learning and case familiarization
- Demographic: Age, Sex, Height, Weight, BMI
- Clinical: Pain symptoms, nausea, appetite loss
- Laboratory: WBC, CRP, temperature, neutrophils
- Imaging: Ultrasound findings, appendix measurements
- Scoring: Alvarado Score, Pediatric Appendicitis Score
- Diagnosis: Appendicitis/No Appendicitis
- Confidence: Prediction probability (0-1)
- Risk Assessment: Clinical interpretation
- Embedding Dimension: 128
- Layers: 6
- Attention Heads: 4 (GUI) / 8 (checkpoint)
- Loss Function: BCEWithLogitsLoss with pos_weight
- Temperature Scaling: 1.0788 (probability calibration)
- Features: 30 clinical + 8 missing indicators = 38 total
- Normalization: StandardScaler on numerical features
- Accuracy, Precision, Sensitivity (Recall)
- Specificity, PPV, NPV
- F1-Score, ROC-AUC
- AI predictions supplement, not replace, clinical judgment
- Data privacy and confidentiality maintained
- Model limitations clearly communicated
09_GUI_Application/saved_models/
├── Decision_Tree.pkl
├── Gradient_Boosting.pkl
├── XGBoost.pkl
├── Transformer.pt (with temperature scaling)
└── metadata.pkl
06_Decision_Trees/decision_tree_model_fair_20260404_193942.pkl
07_Gradient_Boosting/gradient_boosting_model_fair_20260404_194743.pkl
08_XGBoost/xgboost_model_fair_20260404_195216.pkl
05_Transformer_Model/best_advanced_transformer_model.pth
- Loss Function: CrossEntropyLoss → BCEWithLogitsLoss with pos_weight
- Architecture: Increased embed_dim (64→128), layers (4→6)
- Features: Added temperature scaling for probability calibration
- Performance: Improved sensitivity (69.8%→77.2%) at cost of specificity (96.4%→71.4%)
- Consolidated Models: All models now in
saved_models/directory - Enhanced UX: Scroll wheel support, improved layout
- Updated Files: Replaced old GUI files with optimized
prediction_gui.py
- Enhanced Transformer architecture
- Additional datasets for training
- Real-time clinical integration
- Mobile application development
If you use this project in research, please cite appropriately.
[Specify your license here]
[Your contact information]