Missing Data and Normalization?

Kevin2: <p>Hi,</p>
<p>I’d need expertise for the following problem… thanks a lot, your help is very appreciated!</p>
<p>I am dealing with a dataset for which:</p>
<ul>
<li>Samples have 10 continuous features: x = (x1, x2, …, x10)</li>
<li>certain samples often have a missing (continuous) feature x1, that ranges say from 0 to 100.</li>
</ul>
<p>Namely,</p>
<ul>
<li>When it is missing, I give it a default null value : x1 = 0, and I have a categorical feature x11 = 0</li>
<li>When x1 is not missing, it usually is within the range x1 = 0 - 100;   and I have x11 = 1 to indicate x1 is present.</li>
</ul>
<p>When I try to have a shallow torch MLP learn the identity mapping MLP(x) → x1 (I make sure to only penalize the samples which have x1), I notice that learning goes smoothly usually, EXCEPT if I use batch normalization.</p>
<p>I can’t remove the samples for which x11 = 0 due to future work with these (the problem is slightly more complex, I am actually dealing with a graph and each of those samples are nodes within a graph…)</p>
<p>My guess is that the fact that x1 is missing for a lot of samples results in batches have very varying mean and variances, causing the BN’s running mean and variance to be unable to stabilize, and ultimately causing the MLP to be unable to learn the simple mapping above. I tried training it on a fixed batch to test the hypothesis,</p>
<p>Is there a way to keep the normalization while also keeping the samples which have missing x1 in the training set ? Should I encode the fact x1 is missing for some samples in some other way ?</p>
<p>For those who are interested in the bigher</p>
<p>Thanks !</p>
<p>EDIT:  I will be using <a href="https://arxiv.org/abs/2111.12128" class="inline-onebox" rel="noopener nofollow ugc">[2111.12128] On the Unreasonable Effectiveness of Feature propagation in Learning on Graphs with Missing Node Features</a> to propagate info to missing nodes for my problem… still, for the non-graph problem exposed above, I find intriguing the fact that batch norm applied to a whole batch breaks convergence when the loss doesn’t use all samples (but only the ones with non-missing x1).</p>

nwn: <p>Hello,<br>
I think: <a href="https://stackoverflow.com/questions/47143521/where-to-apply-batch-normalization-on-standard-cnns" class="inline-onebox" rel="noopener nofollow ugc">python - Where to apply batch normalization on standard CNNs - Stack Overflow</a>  might help you with when to apply batch normalization or reading about what happens if certain values are close to 0.<br>
Considering your handling of missing values, I would propose the “standard” approach of dealing with missing values:</p>
<ol>
<li>Identify the number of missing values</li>
<li>Decide whether to keep the feature and impute it or to kick it out.</li>
</ol>
<p>The simplest approach would be to use mean imputation. In addition, if you decide to impute mssing values or to kick it out I would refrain from using a categorical variable to show that a feature is missing. After you have applied this preprocessing pipeline you can try to train your model with BN again and monitor its convergence. If it still doesn’t work, simply don’t use it.</p>