Profiling Your Data
Background - Why Profile?
Often models are trained on retrospective data, which is typically highly available and clean. When models are deployed, realtime production data is never as clean or available. The Feature Availabilty Profiler can expose some of these problems.
Let's say that we developed and trained a predictive machine learning model on retrospective data from an inpatient unit. We may be trying to identfy patients at risk for a certain outcome during their stay in the hospital.
Let's presume that our model is performing well with an ROC AUC of 0.83.
Things appear to be going smoothly, so we push our model out to production to make predictions on current patient data. We check back in on our model and find that the in the wild ROC AUC has fallen to 0.67.
What's happening here? It is likely we might be experiencing some data leakage. This means that in our retrospective training data we might have had a table like this:
Let's imagine that our model used height, weight, age, gender, red blood count and hematocrit as features.
However, realtime data is never this clean and available. If we were to look at records of patients who are currently in hospital, we might see something like this:
Here we see a few patients (id 1 & 2) have been inpatients for a few days and have had CBC labs done. However if we look at patients 3-5 we see that they have not been admits as long and are missing some labs. Patient 5 was admitted a few hours ago and we don't even have access to his age yet.
When we run the predictive model on these patients with missing values the model has less information about each patient and will therefore make a less accurate prediction.
As we help users with healthcare.ai we keep seeing this problem. So, we built a tool to help uncover this problem. We call it the Feature Availability Profiler.
Using the Feature Availability Profiler
The availability profiler assumes that your data has two date/time columns. One is the patient's admit time. The other is the timestamp when the data was last saved to the database. Both date fields are needed for caluculating how long a patient has been in the unit. If you do not have the second date, you could add a column with the current time to the dataframe.
- Load your data into a datarame.
- Pass your dataframe into the profiler as such:
featureAvailabilityProfiler(dataframe, startDateColumn='AdmitDTS', lastLoadColumnName='LastLoadDTS')
You will then see a graph like the one below that shows you each feature (i.e., column) and its percentage of availability as time goes on.