A Django-based web application that predicts the most suitable drug for a patient based on their medical information. Powered by a trained machine learning model, this app demonstrates the real-world application of AI in healthcare.
πΈ Interface Preview
Demo of prediction form:
- π§Ύ Patient Data Form: User-friendly form to collect:
- Age
- Gender (Sex)
- Blood Pressure
- Cholesterol
- Sodium-to-Potassium Ratio (Na_to_K)
- π€ ML Drug Prediction: Predicts the most effective drug using a pre-trained ML model.
- π Admin Panel: Manage entries and oversee patient predictions with Djangoβs built-in admin interface.
- π Model Integration: Seamlessly integrates a trained scikit-learn model into the Django backend.
- π― Accurate Predictions: Based on well-curated training data and effective preprocessing.
- Algorithm Used: (e.g., Decision Tree Classifier / Random Forest / Logistic Regression)
- Training Data: [Include dataset source or summary if applicable]
- Target Classes: Drug A, Drug B, Drug C, Drug X, Drug Y (example)
- Input Features:
Age
(Integer)Sex
(Male/Female)Blood Pressure
(Low/Normal/High)Cholesterol
(Normal/High)Na_to_K
(Float β Sodium-to-Potassium Ratio)
- Backend: Django (Python)
- Machine Learning: scikit-learn, pandas, joblib
- Frontend: HTML5, CSS3, Bootstrap (Optional)
- Database: SQLite3 (default Django DB)
- Model Deployment: Integrated with Django views
git clone https://github.com/your-username/drug-prediction-django.git
cd drug-prediction-django
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
Open your browser and go to:
http://127.0.0.1:8000/
If you want to retrain or improve the model:
# train_model.py
# Uses scikit-learn to train a model and saves it as 'model.pkl' using joblib
Add screenshots of your:
- π§Ύ Patient input form
- π Prediction result page
- π Admin panel view
drug-prediction/
βββ core/ # Django app
β βββ models.py # Patient model
β βββ views.py # Prediction logic
β βββ forms.py # Input form
β βββ templates/ # HTML templates
βββ static/ # CSS/JS assets
βββ model/ # Trained ML model (model.pkl)
βββ train_model.py # (Optional) Script to train and save model
βββ db.sqlite3
βββ manage.py
βββ requirements.txt
Input Field | Sample Value |
---|---|
Age | 35 |
Gender | Male |
Blood Pressure | High |
Cholesterol | High |
Na_to_K | 14.2 |
Predicted Drug: DrugX
To access the admin panel:
python manage.py createsuperuser
Then visit:
http://127.0.0.1:8000/admin
MIT License. Feel free to use, modify, and distribute this project.
- scikit-learn
- Django
- UCI Drug Dataset (if applicable)
- Bootstrap (for styling)