Skip to content

About

2023-2022, A data science and AI project developed at ATC Innovatics Center to address fraud detection challenges in the auto insurance industry. Using machine learning models the project improved fraud detection rates to 90% and identified dominant patterns in fraudulent claims, enabling more effective fraud detection

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Auto Insurance Fraud Detection

Auto Insurance Fraud Detection

Can we tell, from the details of a claim alone, which auto-insurance claims are likely to be fraudulent?

This project walks through the full workflow on a public dataset of 1,000 auto-insurance claims: exploring the data, preparing it without leaking information, and training an interpretable decision-tree classifier that is tuned, evaluated and compared against honest baselines.

Why this problem is interesting

  • Imbalanced target - only about a quarter of claims are fraudulent, so a model that predicts "legit" for everything already looks accurate while catching nothing. The project therefore stratifies every split and judges models on precision, recall, F1 and PR-AUC rather than accuracy alone.
  • Messy, real-world columns - a ? placeholder for missing values, identifier columns, free-text addresses, dates, and ~150 columns once the categories are one-hot encoded for only 800 training rows.
  • Interpretability matters - fraud investigators need to understand why a claim was flagged, which is where a decision tree shines.

Workflow

Notebook What it does
01_exploratory_analysis Inspects the data, quantifies class imbalance, compares distributions of fraud vs. legit claims, ranks categorical features with Cramér's V, derives days_to_incident, and justifies every dropped column.
02_data_preparation Stratified train/test split first, then a single ColumnTransformer pipeline (median / unknown imputation, IQR outlier capping, one-hot encoding). Feature selection (constant, duplicate and highly-correlated removal, then mutual information + random-forest ranking) uses the training data only.
03_decision_tree_model Dummy baselines, an overfitting demonstration, a validation curve for tree depth, grid search with stratified 5-fold CV, test-set evaluation (confusion matrix, ROC and PR curves), feature importances and a plot of the tree itself.
8.0 - Auto_Insurance_Classification_SVM Linear SVM. Scaling inside a pipeline (leak-free), baselines, validation curve for C, grid search with stratified 5-fold CV, test-set evaluation, coefficient plot and distance-to-boundary histogram.
9.0 - Auto_Insurance_Classification_KSVM Kernel SVM. Scaled vs. raw features, linear / polynomial / RBF / sigmoid compared, C x gamma heat-map, grid search, support vectors, permutation importance and a 2-D picture of the decision boundary.
10 - Auto_Insurance_Classification_KNN K-nearest neighbours. Validation curve for k, search over weighting and distance metric (tuned on PR-AUC), decision threshold chosen from out-of-fold predictions, "why was this claim flagged?" neighbour table, and a final comparison of all models.

Project structure

auto-insurance-fraud-detection/
├── notebooks/            # EDA, preparation, decision tree, SVM, kernel SVM, KNN - run in order
├── src/
│   └── fraud_toolkit.py  # paths, plot theme, data loader, IQR capper, Cramér's V
├── scripts/
│   ├── make_banners.py          # draws the header images in assets/
│   └── generate_demo_data.py    # synthetic data for smoke-testing only
├── data/
│   ├── raw/              # put insurance_claims.csv here (not tracked by git)
│   └── processed/        # created by the notebooks
├── models/               # fitted preprocessor + tuned models (created by the notebooks)
├── reports/
│   ├── figures/          # every chart, saved as PNG
│   ├── feature_ranking.csv
│   └── metrics*.json     # test metrics of each final model (tree, SVM, kernel SVM, KNN)
├── assets/               # banner images
└── requirements.txt

Getting started

git clone https://github.com/walidwh21/DS_Auto_Insurance_Fraud_Detection
cd DS_Auto_Insurance_Fraud_Detection

python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -r requirements.txt
  1. Download the auto-insurance claims CSV (1,000 rows, 39 columns, target column fraud_reported) and save it as data/raw/insurance_claims.csv. The dataset is commonly found on Kaggle under that file name.

  2. Launch Jupyter and run the notebooks in order:

    jupyter lab

    01_exploratory_analysis → 02_data_preparation → 03_decision_tree_model → 8.0 SVM → 9.0 KSVM → 10 KNN

No dataset at hand? python scripts/generate_demo_data.py creates a synthetic file with the same schema so you can check that everything runs. The notebooks pick it up automatically if the real CSV is missing and print a warning - metrics computed from it are meaningless.

Design choices worth noting

  • No data leakage. The train/test split happens before imputation, outlier handling and feature selection; all of those are fitted on the training set only and merely applied to the test set.
  • One reusable pipeline. Preprocessing lives in a single scikit-learn ColumnTransformer, saved as models/preprocessor.joblib, so new claims can be transformed exactly like the training data.
  • Capping instead of deleting outliers. With ~1,000 rows, dropping rows is costly; values are clipped to the IQR fences instead.
  • Missing means "not recorded". ? values become an explicit unknown category rather than being imputed or dropped.
  • Metrics that fit the problem. F1 is used to tune the tree, and ROC-AUC / PR-AUC are reported next to it; the "always legit" baseline shows why accuracy alone would be misleading.

Results

Running notebook 03 writes the final test-set metrics to reports/metrics.json and a model comparison table (baselines vs. unconstrained tree vs. tuned tree) in the notebook. All figures are saved to reports/figures/.

The SVM and KNN notebooks add one design choice: these models are distance-based, so the real-valued columns are standardised inside a Pipeline (re-fitted in every cross-validation fold), while one-hot columns are left as 0/1. KNN has no class weighting, so its decision threshold is picked from out-of-fold predictions on the training set.

Tech stack

Python · pandas · NumPy · scikit-learn · SciPy · Matplotlib · seaborn · Jupyter

About

2023-2022, A data science and AI project developed at ATC Innovatics Center to address fraud detection challenges in the auto insurance industry. Using machine learning models the project improved fraud detection rates to 90% and identified dominant patterns in fraudulent claims, enabling more effective fraud detection

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages