# Deploying the prediction model under missing values for test data

I have successfully built a logistic regression prediction model based on data set that is complete and clean, i.e., there is no missing values and the data is consistent. Now, for deploying the model and testing it for online use, there is missing values in the inputs, i.e., not all inputs are available to predict the target value.

Is there a standard way to deal with this?

I can think of three ways to deal with the problem:

1. Treat "missing value" as another feature: Imagine you have a feature like "date of graduation". One possible (likely?) reason why this value is missing might be that the person did not graduate. So you could build a model which as a binary feature "graduation date is available" and the actual graduation date as another feature.
2. Predict the missing values: If data is missing because of your lack of knowledge of it (in contrast to the first point), then you might think about trying to predict the missing value. You could also add a feature which encodes the certainty of the predicted value being correct.
3. Skip the feature: If it is missing very often and if it doesn't add much value to your prediction, you might simply want to remove it.

In statistics coping with missing values is often done by imputation: https://en.wikipedia.org/wiki/Imputation_(statistics)

and whole books have been written about it. Suggest you start reading.

One method, multiple imputation, works by creating a number of new complete data items by replacing the missing value with some values sampled from a distribution. You then predict from these new data items, and that gives you a set of predictions and variances from which you can compute a pooled prediction and variance. This variance will be larger than that from a complete item because of the variance introduced by the sampling. The increase will depend on how influential the missing variable is to the model and what distribution you put on the missing item. For example, if you have missing age, and your data should be from a population between 16 and 60, you'd sample age from the population distribution a number of times, do the predictions, and pool them according to the multiple imputation methodology.

Of course you have to know if your missing data are missing at random, or perhaps biased missing (maybe more women over 40 don't give their age). Lots of interesting complications that will only come to light if you have a careful think about your data.

Anyway, as I say, whole books. And you should probably try the statistics stack exchange site too. Its not really data science much.

• "whole books have been written about it" - this is not very helpful. If you know that there are many books about it, you should recommend or at least mention one or two. Oct 19 '16 at 18:38
Missing values need to be treated, you can remove missing if are very
small < 10% or you have large dataset. Some  statistical software like SAS will
exclude missing values if is not imputed/treated.


Also you can't predict anything with NA: usually missing or coded data can be meaningful or mindless so you need to find out what you need to do with the missing data.

In Conclusion: missing data should be fixed because in case if is coded than you will have wrong predictions or statistical software will drop from dataset/model automatically. Assuming that you already build this logistic model than you know how you treated the data for model building and next step if figure out if you prepare the data to include imputed missing data for model or drop from your dataset/input pipeline.

So that it is close as possible to the real data, go back an rebuild your logistic regression model and simulate the missing values you are finding in the real data. After all, the model is supposed to represent the real circumstance. This approach has a few advantages over the imputing approaches. The foremost is that you can accurately gauge which and how much missing data your model can stand up to.