Predicting the length of a hospital stay, with R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I haven't been admitted to hospital many times in my life, but every time the only thing I really cared about was: when am I going to get out? It's also a question that weighs heavily on hospital managers: by knowing ahead of time how long each patient's stay is likely to be, they can better manage facilities and staff, and know whether the hospital is likely to reach maximum capacity in the near future.

To help hospital administrators better predict how long patients are likely to stay, Microsoft has published the Predicting Length of Stay in Hospitals solution on the Cortana Intelligence Gallery. Clicking on “deploy” creates an instance of the Data Science Virtual Machine with simulated patient data in SQL Server, and a model implemented with R Services to predict the length of stay. The predictions are then presented as a Power BI dashboard to a Care Line Manager or a Chief Medical Information Officer as shown below. (Click the Try It Now button on this page to interact with the dashboard.)

Care line mgr

The underlying model is a Random Forest implemented with rxDForest in the RevoScaleR package. (The data science process behind training the model is described here, and the R code is available in this Github repository). The model is trained using simulated patient lab and diagnosis data, and observed lengths of stay. For hospitals that want to build a similar model using real data, the Predicting Hospital Length of Stay solution page provides detailed background on configuring a similar service in a cloud-based architecture or installed in a private data center

For more details on the solution, take a look at this MSDN blog post, visit the Cortana Intelligence Gallery, or browse the detailed solution page linked below.

GitHub (Microsoft): Predicting Hospital Length of Stay


To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)