PAX is an intelligent document processing and underwriting decision support system that combines OpenAI Vision API for data extraction, XGBoost for risk prediction, and SHAP for explainable AI. It streamlines insurance form processing while providing transparent, data-driven risk assessment with human-in-the-loop decision making.
AI-generated explanation of the risk assessment and model reasoning:
Feature-by-feature breakdown showing which applicant characteristics drove the prediction:
Human underwriter reviews all information and makes the final binding decision:
PAX automates the insurance underwriting process through a three-stage pipeline:
- Data Extraction β OpenAI Vision API extracts structured data from PDF insurance forms
- Risk Prediction β XGBoost model predicts risk categories (Safe/Warning/Danger) with full explainability
- Decision Support β AI-generated decision summaries + human underwriter review for final approval
| Feature | Description |
|---|---|
| π Smart Form Processing | Drag & drop PDF uploads with automatic field extraction |
| π€ AI-Powered Risk Assessment | XGBoost model trained on insurance underwriting patterns |
| π SHAP Explainability | Understand exactly which factors drove each prediction |
| π¬ Decision Summaries | GenAI-generated explanations for model predictions |
| π€ Human-in-the-Loop | Final underwriter decision with full audit trail |
| π Dependency Analysis | Interactive plots showing feature relationships |
βββββββββββββββββββ
β Frontend β React + Vite
β (React) β Real-time UI
ββββββββββ¬βββββββββ
β HTTP/REST
ββββββββββΌβββββββββ
β FastAPI β Document Processing
β Backend β Risk Prediction
ββββββββββ¬βββββββββ
β
ββββββ΄βββββββββββββββββ
β β
ββββΌβββ βββββββΌβββββ
β PDF β β XGBoost β
βData β β Model β
β + β β+ SHAP β
βOpenAIβ βExplainer β
ββββ¬βββ βββββββ¬βββββ
β β
βββββββββββ¬ββββββββββββ
β
ββββββΌβββββ
β JSON β
β Storage β
βββββββββββ
Frontend
- React 18 with Vite 5
- Interactive visualizations (SHAP plots, dependency charts)
- Lottie animations for processing states
Backend
- FastAPI (async Python web framework)
- OpenAI Vision API (document processing)
- XGBoost + SHAP (ML prediction & explainability)
- Matplotlib (visualization generation)
Data Storage
- JSON files with document metadata
- Pre-trained ML models (XGBoost + preprocessors)
OpenAI Vision API automatically extracts 13 structured fields from insurance forms:
- Age, Sex, Height, Weight (BMI calculation)
- Medical Conditions, Smoker Status
- Occupation, Sports Activities
- Address, Annual Income
- Document ID, Filename, Upload Timestamp
XGBoost model predicts risk category with per-feature importance visualization:
- SHAP Waterfall Plots β Shows how each feature pushes the prediction up or down
- Dependency Plots β Reveals non-linear feature relationships
- Risk Categories β Safe | Warning | Danger
GenAI generates a one-sentence decision summary explaining the model's reasoning (see workflow images at top)
- Python 3.12+
- Node.js 18+
uvpackage manager (install here)- OpenAI API key (get here)
# Clone the repository
cd baselhacks_pax
# Create .env file with your OpenAI API key
cat > code/backend/.env << EOF
OPENAI_API_KEY=sk-your-key-here
EOFcd code/backend
uv sync
uv run uvicorn main:app --reloadBackend runs on http://localhost:8000
API documentation available at http://localhost:8000/docs
cd code/frontend
npm install
npm run devFrontend runs on http://localhost:5173
- Open http://localhost:5173 in your browser
- Drag & drop a PDF insurance form (or click "Browse Files")
- Wait for processing (~2-3 seconds for OpenAI + model prediction)
- Review extracted data and risk assessment
- View SHAP analysis to understand feature impacts
- Edit fields if needed and click "Save"
- Make final underwriting decision with full explanation trail
| Endpoint | Method | Description |
|---|---|---|
/upload |
POST | Upload PDF, extract data, run risk model |
/documents |
GET | List all processed documents |
/documents/{doc_id} |
GET | Get document details + predictions |
/save/{doc_id} |
PUT | Update document data |
/pdf/{doc_id} |
GET | Download original PDF |
| Endpoint | Description |
|---|---|
/waterfalls/{filename} |
SHAP waterfall plot (feature contributions) |
/dependency-plots |
Dependency plots (feature relationships) |
/models |
Model metadata & performance stats |
/analytics |
System-wide analytics & statistics |
baselhacks_pax/
βββ assets/ # Visual assets
β βββ main.png # System overview screenshot
β βββ shap_analysis.png # SHAP explainability example
β βββ decision_exec_summary.png # AI decision summary
β βββ underwriter_decision.png # Final underwriter screen
β βββ bmi_analysis.png # Feature analysis example
β
βββ code/
β βββ backend/
β β βββ main.py # FastAPI application
β β βββ workflow_agent.py # OpenAI integration
β β βββ requirements.txt # Python dependencies
β β βββ pyproject.toml # Project metadata
β β βββ api/
β β β βββ dependency_plots.py # SHAP visualization API
β β βββ data/ # Processed documents (JSON)
β β βββ static/
β β β βββ waterfalls/ # SHAP waterfall plots
β β β βββ dependency_plots/ # Dependency plots
β β β βββ model_recommendations_plot/
β β βββ data/model/ # Pre-trained ML models
β β βββ xgboost_model.json
β β βββ preprocessor.joblib
β β βββ label_encoder.joblib
β β βββ shap_background.npy
β β βββ manifest.json
β β
β βββ frontend/
β βββ src/
β β βββ App.jsx # Main React component
β β βββ components/
β β β βββ FileUpload.jsx # Upload interface
β β β βββ Analytics.jsx # Risk dashboard
β β β βββ DocumentDetail.jsx # Document viewer
β β β βββ CaseDecision.jsx # Underwriter decision UI
β β β βββ SuccessConfetti.jsx # Success animation
β β β βββ AnalysisAnimation.jsx
β β β βββ ExtractionAnimation.jsx
β β β βββ Toast.jsx # Notifications
β β βββ index.css
β β βββ main.jsx
β βββ public/
β β βββ Data Analysis.lottie
β β βββ Data Scanning.lottie
β β βββ success confetti.lottie
β β βββ img/
β βββ package.json
β βββ vite.config.js
β βββ README.md
β
βββ datageneration/ # ML model training
β βββ population_generation.py # Synthetic data generation
β βββ explore_population.ipynb # EDA notebook
β βββ xgboost_shap.ipynb # Model training & SHAP analysis
β βββ synthetic_life_insurance_10000.json
β
βββ documentation/ # Project documentation
βββ licence.txt
βββ readme.md
Training Data: 10,000 synthetic insurance applicants with labeled risk categories
- Safe (Low risk)
- Warning (Medium risk)
- Danger (High risk)
Features: 13 applicant attributes (age, health, occupation, lifestyle)
Explainability: SHAP (SHapley Additive exPlanations)
- Per-sample feature contributions
- Waterfall plots showing decision logic
- Dependency plots revealing feature interactions
What SHAP does:
- Calculates exact contribution of each feature to the final prediction
- Uses game theory (Shapley values) for fair feature attribution
- Generates visualizations showing which factors pushed risk up/down
Visualizations:
- Waterfall Plots β Sequential feature contributions to final decision
- Dependency Plots β Feature value vs SHAP contribution (reveals patterns)
- Force Plots β Interactive feature importance
Once the XGBoost model makes a prediction, OpenAI generates a human-readable explanation:
Inputs to GenAI:
- Model's prediction (Safe/Warning/Danger)
- Top SHAP features (which factors mattered most)
- Feature values from applicant
Output:
One professional sentence explaining the decision
Example output:
"This applicant's combination of pre-existing diabetes and smoking habit with moderate income indicates elevated health risk, resulting in a Warning classification."
The underwriter:
- Reviews the applicant data
- Examines the SHAP analysis (feature contributions)
- Reads the AI decision summary
- Makes final decision (Approve/Decline/Further Review)
- Adds notes for compliance & audit trail
Each processed insurance application includes:
| Field | Type | Description |
|---|---|---|
id |
UUID | Unique document identifier |
age |
Integer | Applicant age in years |
sex |
String | Male / Female / Other |
height_cm |
Float | Height in centimeters (for BMI) |
weight_kg |
Float | Weight in kilograms (for BMI) |
address |
String | Full residential address |
occupation |
String | Job title/profession |
sports |
String | Sports/exercise activities |
medical_conditions |
String | Medical history & diagnoses |
smoker |
String | Yes / No |
annual_income |
String | Annual income with currency |
filename |
String | Original PDF filename |
uploaded_at |
DateTime | Timestamp of upload |
- API Keys: Stored in
.envfile (never commit to git) - Audit Trail: All decisions logged with timestamps
- Data Privacy: PDFs and extracted data stored locally
- No PII Leakage: GenAI prompts don't include sensitive personal info
- Multi-language form support
- Real-time model performance monitoring
- Batch document processing
- Advanced analytics dashboard
- Integration with underwriting workflow systems
- A/B testing framework for model versions
- Custom SHAP plot generation per document
- Document OCR for handwritten forms
Update the ML model with new training data:
cd datageneration
jupyter notebook xgboost_shap.ipynb- Drag & drop interface with file preview
- Calls
/uploadendpoint - Displays extraction progress with Lottie animations
- Displays risk prediction result
- Shows SHAP waterfall plot
- Shows decision summary
- Links to underwriter decision interface
- Orchestrates OpenAI Vision API calls
- Handles response parsing & validation
- Stores extracted data to JSON
- Pre-trained on 10,000 synthetic insurance records
- Predicts risk category + probability
- Returns top-5 feature contributions for SHAP
- Calculates Shapley values for each prediction
- Generates waterfall plot images
- Computes dependency plots for feature analysis
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -am 'Add new feature' - Push branch:
git push origin feature/your-feature - Create Pull Request
See licence.txt for details.
For issues or questions:
- Check existing issues on GitHub
- Review backend README:
code/backend/README.md - Review frontend README:
code/frontend/README.md
Built for Basel Hacks 2025 π¨π



