This project is a complete end-to-end Machine Learning application that predicts whether an insurance claim will be requested based on specific policy and claim details. It features a robust FastAPI backend for model serving and a user-friendly Streamlit frontend.
- Machine Learning Pipeline: Trained using XGBoost with optimized preprocessing (StandardScaler & OneHotEncoder).
- Data Validation: Powered by Pydantic for strict input validation.
- RESTful API: FastAPI-based backend with automated documentation (Swagger UI).
- Interactive UI: Streamlit-based web interface for easy predictions.
Model with APIs/
├── APIwithModel.py # FastAPI Backend
├── frontend.py # Streamlit Web App
├── ModelClasses.py # Pydantic Data Models & Validation
├── ModelBuilding.ipynb # ML Research & Training Notebook
├── final_insurance_model.pkl # Trained Model Artifact
└── InsurenceData.csv # Dataset
-
Clone the Repository:
git clone <your-repo-url> cd "Model with APIs"
-
Install Dependencies:
pip install fastapi uvicorn streamlit pandas joblib xgboost scikit-learn requests
python APIwithModel.pyThe API will be available at http://127.0.0.1:8000. You can view the interactive docs at /docs.
Open a new terminal and run:
streamlit run frontend.pyThe web interface will open automatically in your browser.
The system expects the following data points:
- Claim Reason: Travel, Medical, Phone, or Other.
- Data Confidentiality: Low, Medium, High, or Very low.
- Claim Amount: The total value of the claim.
- Premium/Amount Ratio: Ratio of policy premium to the claim amount.
Developed as part of the FastAPI Learning Journey.
- Dataset Link:
https://www.kaggle.com/datasets/usmanfarid/customer-churn-dataset-for-life-insurance-industry