A machine learning project that analyzes synthetic medical symptoms data and builds a classification model to predict medical diagnoses based on patient symptoms, vital signs, and laboratory values.
This project performs comprehensive exploratory data analysis (EDA) on a synthetic medical symptoms dataset and implements a Random Forest classifier to predict medical diagnoses. The model uses various features including patient demographics, symptoms, vital signs, and laboratory test results to classify patients into different diagnostic categories.
- Perform exploratory data analysis on medical symptoms data
- Visualize data distributions, correlations, and patterns
- Build a machine learning model to predict medical diagnoses
- Evaluate model performance using various metrics
- Identify important features for diagnosis prediction
The dataset (synthetic_medical_symptoms_dataset.csv) contains 3,000 patient records with the following information:
Demographics:
age: Patient agegender: Patient gender (Male/Female)
Symptoms (0-3 severity scale):
fever: Fever severitycough: Cough severityfatigue: Fatigue levelheadache: Headache severitymuscle_pain: Muscle pain levelnausea: Nausea severityvomiting: Vomiting severitydiarrhea: Diarrhea severityskin_rash: Skin rash presence/severityloss_smell: Loss of smell severityloss_taste: Loss of taste severity
Vital Signs:
systolic_bp: Systolic blood pressure (mmHg)diastolic_bp: Diastolic blood pressure (mmHg)heart_rate: Heart rate (bpm)temperature_c: Body temperature (ยฐC)oxygen_saturation: Blood oxygen saturation (%)
Laboratory Values:
wbc_count: White blood cell count (ร10ยณ/ยตL)hemoglobin: Hemoglobin level (g/dL)platelet_count: Platelet count (ร10ยณ/ยตL)crp_level: C-reactive protein level (mg/L)glucose_level: Blood glucose level (mg/dL)
Target Variable:
diagnosis: Medical diagnosis (COVID-19, Influenza, Dengue, Malaria, Pneumonia)
- Python 3.7 or higher
- Jupyter Notebook or JupyterLab
-
Clone the repository:
git clone https://github.com/Denixzertyux/SyntheticMedicalSymptoms.git cd SyntheticMedicalSymptoms -
Create a virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
SyntheticMedicalSymptoms/
โ
โโโ synthetic_medical_symptoms_dataset.csv # Dataset file (3,000 patient records)
โโโ medical_symptoms_analysis.ipynb # Jupyter notebook with complete analysis
โโโ requirements.txt # Python package dependencies
โโโ LICENSE # MIT License
โโโ .gitignore # Git ignore file
โโโ README.md # Project documentation
-
Start Jupyter Notebook:
jupyter notebook
-
Open the analysis notebook:
- Navigate to
medical_symptoms_analysis.ipynbin the Jupyter interface - Or directly open it:
jupyter notebook medical_symptoms_analysis.ipynb
- Navigate to
-
Run the cells sequentially:
- Cell 0: Import required libraries and set up environment
- Cell 1: Load the dataset
- Cell 2: Data preprocessing and cleaning
- Cell 3: Exploratory data analysis with visualizations
- Cell 4: Model building and evaluation
- Loads the CSV dataset
- Converts numeric columns to appropriate data types
- Handles missing values (if any)
- Final dataset shape: 3,000 rows ร 24 columns
The notebook generates several visualizations:
- Histograms: Distribution of all numeric features
- Count Plot: Distribution of diagnoses
- Correlation Heatmap: Relationships between numeric features
- Pair Plot: Pairwise relationships for key features
- Box Plot: Age distribution across different diagnoses
- Algorithm: Random Forest Classifier
- Features: All numeric features (excluding gender and diagnosis)
- Train/Test Split: 80/20 with stratification
- Hyperparameters:
n_estimators: 100random_state: 42
The model evaluation includes:
- Accuracy Score: Overall classification accuracy
- Confusion Matrix: Visual representation of classification performance
- Feature Importance: Permutation importance analysis to identify key predictors
- ROC Curve: Receiver Operating Characteristic curve for model performance
The Random Forest classifier achieves an accuracy of approximately 24.17% on the test set. Note that this is a multi-class classification problem with 5 diagnostic categories, so performance should be evaluated in context of:
- Class distribution balance
- Baseline accuracy (random guess: ~20% for 5 classes)
- Confusion matrix patterns
- Feature importance insights
The analysis provides insights into:
- Feature distributions and their relationships
- Which symptoms and vital signs are most predictive
- Patterns in diagnosis distribution
- Correlations between different medical measurements
-
Synthetic Data: This dataset is synthetic and should not be used for real medical decision-making.
-
Model Limitations:
- The model is trained on synthetic data
- Performance metrics are for demonstration purposes only
- Not suitable for clinical use
-
Data Privacy: This is synthetic data, so no real patient information is included.
Potential enhancements to the project:
- Hyperparameter tuning for better model performance
- Feature engineering and selection
- Cross-validation for more robust evaluation
- Additional classification algorithms (SVM, XGBoost, Neural Networks)
- Class imbalance handling techniques
- Multi-class ROC curves for all diagnoses
- Model interpretation using SHAP values
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the open-source community for the excellent libraries used in this project
- Synthetic dataset created for educational purposes
For questions or suggestions, please open an issue on GitHub.