Predicting Hospital Length of Stay using SQL Server R Services

May 9, 2017

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

Last week, my Microsoft colleagues Bharath Sankaranarayan and Carl Saroufim presented a live webinar showing how you can predict a patient's length of stay at a hospital using SQL Server R Services. The recorded webinar is available for on-demand viewing now. (Registration is required to view.)

The webinar is based on the Machine Learning Solution Template Predicting Length of Stay in Hospitals, which we covered here on the blog back in March. The solution is based on an instance of the Data Science Virtual Machine, which makes it easy to try it yourself. Just click the "Deploy" button to create your own instance in Azure with all of the data and scripts preloaded.

In the webinar, you'll learn how to use patient admission and clinical data to predict how long a patient is likely to remain in the hospital. The data is included as a flat file in the VM, and contains the columns shown below. (Note: while the Solution is based on a real-world deployment, these data are simulated.)

Hospital variables

The webinar will take you through the process of using Microsoft R Server (included in the VM) to import the data and upload it to SQL Server. You'll then apply R functions to the data in SQL Server to explore the summary data, clean the data and impute missing values, and create new columns for analysis. You'll then train Random Forest and Gradient Boosted Tree models to generate predictions, storing the final model back in SQL Server.

These predictions are used by hospital managers and ward staff to manage patient populations. The predictions are part of a PowerBI dashboard, which you can see and interact with by clicking the "Try It Now" button on the Solution page.

The detailed abstract for the webinar is below, and you can launch the on-demand viewing using the link at the bottom of this post.

Being able to accurately estimate how long a patient is likely to need a bed is important for running an efficient hospital and delivering effective healthcare. To help the administration manage hospital resources, the Hospital Length of Stay solution estimates the number of days the patient is expected to stay before discharge. The solution shows how easy it is to develop with SQL Server with R Services and demonstrates how you can leverage Microsoft R Server in the health care domain.

With this Microsoft R Server Solution, we will demonstrate the short time to value and show how easy it is to build solutions by using these templates. These solutions are fully customizable and extensible and you can experience this with a few clicks and a Azure Subscription. Both the solutions leverage Cortana Intelligence Suite patterns and the Data Science VM.

Microsoft webinars: Predicting Hospital Length of Stay using SQL Server with R Services

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


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)