Skip to content

Predict patient satisfaction using machine learning based on doctor experience, reviews, fees, and wait times. Includes data prep and model comparison with LazyPredict.

Notifications You must be signed in to change notification settings

Usama-Codez/Patient-Satisfaction-Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Patient Satisfaction Prediction using Machine Learning

Patient Satisfaction Prediction is a machine learning project that predicts patient satisfaction levels using doctor related metrics. Designed with efficiency, clarity, and model benchmarking in mind, complete with automated evaluation.


πŸ“Š Project Overview

This project explores how doctor experience, fees, wait times, and other metrics impact patient satisfaction. It applies various machine learning techniques to:

  • πŸ“Œ Preprocess and normalize raw data
  • πŸ€– Train and evaluate multiple models (manually + via LazyPredict)
  • πŸ“ˆ Benchmark performances
  • πŸ“ Save results for further analysis

🧠 Features

  • βœ… Handles missing values automatically
  • πŸ“ Normalizes numerical data using MinMaxScaler
  • βš–οΈ Balances dataset using SMOTE
  • πŸ§ͺ Trains multiple classifiers including:
    • Logistic Regression
    • Random Forest
    • Decision Tree
    • AdaBoost
    • KNN
    • SVM
    • Naive Bayes
    • XGBoost
  • πŸ€– Uses LazyPredict to automatically benchmark many models
  • πŸ“Š Saves model performance comparisons as CSV
  • 🎯 Voting Classifier for accuracy boosting
  • πŸ“¦ Cleanly modular and well-commented code

πŸ—‚οΈ Dataset

  • Location: ./dataset/doctors_dataset.csv
  • Contains:
    • Experience (Years)
    • Total Reviews
    • Satisfaction Rate (%)
    • Avg Time to Patients
    • Wait Time
    • Fee (PKR)
    • Target label (Satisfaction: Satisfied / Unsatisfied)

πŸ§ͺ Algorithms & Tools Used

Type Tools/Libraries
Programming Python 3.11+
ML Frameworks scikit-learn, xgboost, lazypredict, imblearn
Visualization seaborn, matplotlib
Data pandas, numpy
IDE Jupyter Notebook / VS Code

πŸ”„ How to Run the Project

1. Set up the environment

# Clone the repo
git clone https://github.com/Usama-Codez/Patient-Satisfaction-Prediction.git
cd Patient-Satisfaction-Prediction

Create & activate a virtual environment

python -m venv newenv
newenv\Scripts\activate

Install dependencies

pip install -r requirements.txt

2. 🧠 Run the notebook

You can Use any of the following IDEs:

  • Jupyter Notebook
  • Jupyter Lab
  • Google Colab Make sure to select the correct environment when running your notebook.

πŸ“‰ πŸ“ˆ Confusion Matrix, ROC curve and Evaluations:

Correlation Heat Map:

Confusion Matrix Logistic Regression model:

image

ROC Curve Logistic Regression model:

image

Evaluating LogisticRegression

Accuracy: 58.76% Precision: 0.95 Recall: 0.59 F1 Score: 0.73 ROC-AUC: 0.5667822806377023

Confusion Matrix Random Forest Classifier:

image

ROC Curve Random Forest Classifier:

image

Evaluating Random Forest Classifier

Accuracy: 90.58% Precision: 0.95 Recall: 0.95 F1 Score: 0.95 ROC-AUC: 0.735426554703663

Confusion Matrix XGBoost:

image

ROC Curve XGBoost:

image

Evaluating XGBoost

Accuracy: 90.96% Precision: 0.94 Recall: 0.96 F1 Score: 0.95 ROC-AUC: 0.7725142996227334

Confusion Matrix SVM:

image

ROC Curve SVM:

image

Evaluating SVM

Accuracy: 72.32% Precision: 0.95 Recall: 0.75 F1 Score: 0.84 ROC-AUC: 0.6031702567847147

Confusion Matrix KNN:

image

ROC Curve KNN:

image

Evaluating KNN

Accuracy: 76.27% Precision: 0.94 Recall: 0.80 F1 Score: 0.86 ROC-AUC: 0.5284166970913959

Confusion Matrix Decision Tree:

image

ROC Curve Decision Tree:

image

Evaluating DecisionTree

Accuracy: 79.66% Precision: 0.95 Recall: 0.83 F1 Score: 0.88 ROC-AUC: 0.6035049288061336

Confusion Matrix NaiveBayes:

image

ROC Curve NaiveBayes:

image

Evaluating NaiveBayes

Accuracy: 63.09% Precision: 0.95 Recall: 0.64 F1 Score: 0.76 ROC-AUC: 0.5259827187538031

Confusion Matrix AdaBoost:

image

ROC Curve AdaBoost:

image

Evaluating AdaBoost

Accuracy: 77.21% Precision: 0.96 Recall: 0.79 F1 Score: 0.87 ROC-AUC: 0.7437325057806986

Testset evaluations:

Fitting 3 folds for each of 108 candidates, totalling 324 fits Best Parameters: {'max_depth': None, 'min_samples_leaf': 1, 'min_samples_split': 2, 'n_estimators': 100} Best Cross-Validation Accuracy: 0.9363507779349364

Author: Usama Akram

πŸ“Œ License

This project is licensed under the MIT License.

About

Predict patient satisfaction using machine learning based on doctor experience, reviews, fees, and wait times. Includes data prep and model comparison with LazyPredict.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published