Cost Weight Prediction in Healthcare
Urs Hurni
Published
SQL (PostgreSQL), Python (Pandas, NumPy, Scikit-learn, Matplotlib, Seaborn), Docker, Cron
End-to-end ML pipeline to predict Cost Weight values in healthcare, from data gathering to production deployment with PowerBI integration.
Hide Details
This project was part of my internship at Swisscoding SA. The problem was that CW is a value that is not immediately available. It has to wait for the ‘coders’ to write the grouper so the CW can be deduced. This posed problem as the company wanted to have an immediate view of that state of their clients, instead of waiting sometimes month before having this data.
I was asked to find a way to accurately predict Cost Weight (which is a multiplicator used in healthcare to assess revenu for clinics and hospitals). I build a project from data gathering to the implementation in powerbi so from raw to production.
I first started by analysing what data could be used and if there was sufficient data of it via SQL queries. Then I started building a data class that was aimed at gathering data via SQL alchemy from the previously made queries, from an sql server, and preprocess it (duplicates, missing values, mean/median fill, encoding of categorical variables, log transformation to skewed numeric features, data engineering, …) to have a usable dataset.
Then I build a memory efficient scikit-learn pipeline that produce a traditional ML pipeline, train/test/validation split, training, cross validation, metrics output. The pipeline was dynamic in the sense that it accepted different parameter like the size of the sample, different models (linear, linear lasso or ridge, ensemble trees like xgboost, catboost, random forest, lightgbm, svm), different variable sets, …
Then metrics like MAE and RMSE where outputed and visualize into an efficient log file and visualization where available to interpret the different models with a comparison with two baseline models.
To put that into production, i build a short pipeline that used only the selected model and outputed a dataset of the value into the company’s server. Docker was used for the production from image building to containerization and CRON automation was used so that the it automatically fetched the new data that was coming in each day to predict the CW if missing.
Finally, I updated the working powerbi dashboard so that those predicted value were loaded and blended seamlessly into the actual table and views via a simple ‘on/off’ toggle. Now the company was able to have a actual up-to-date view of the state of the CW if wanted or come back to the previous state were some CW were missing.
No Github or Links - Confidential :)