A machine learning web app built with scikit-learn and Streamlit that predicts personalized therapeutic doses of Warfarin (a common blood thinner) based on clinical, demographic, and lifestyle data.
Warfarin is one of the most widely prescribed anticoagulant medications, and is used to prevent blood clots in patients with conditions such as
- Atrial fibrillation (irregular heartbeat)
- Deep vein thrombosis
- Pulmonary embolism
- Mechanical heart valves
However, Warfarin has a very narrow therupeutic window. The correct dose for one patient can cause serious bleeding in another, or be completely ineffective, leading to life-threatening clots. Traditional Warfarin dosing methods use standard clinical guidelines or harmful trial-and-error adjustments. However, machine learning offers the potential to personalize dosing using patterns learned from large patient datasets.
This app uses a trained Random Forest Regressor to provide data-driven dose estimates, helping show how AI can assist with peronalized medicine. It uses more than 29 patient features, preprocessing with scaling, encoding, and imputation, and saves/loads the movel using joblib. A graphical user interface is provided to the user through streamlit
- Intelligent preprocessing: handles missing data, encodes categorical values, scales numerics
- Predicts Warfarin dose in mg/week
- Built-in model training & evaluation (MAE, RMSE, R²)
- Easy-to-use Streamlit interface for clinicians or patients
git clone https://github.com/cybergeist0/personalized-warfarin.git
cd personalized-warfarinpython -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txt# Ensure `warfarin_data.xls` is in the `data/` folder
python3 ./main.py # On Windows: python main.py
streamlit run app.py