# Dimensionality reduction of vectors with null values

I have vectors of same length where each entry can have the value 0, 1 or null.

V = {[0,1,1,1,null,0], [null,1,0,null,0,1], ...}

How can I perform a dimensionality reduction of these vectors into a lower dimensional space (in this case 2d)?

• The simplest solution is to replace the null values by an outlier like -1. The dimensionality reduction will work well, but it will consider the null as closer to 0 than 1. If you want to separate null values even more, you can replace them by more extreme values like 10 or -10. Aug 3, 2021 at 23:01

## 2 Answers

You have several options:

• Drop rows that have null values.

• Impute the null values.

• Pick a dimensionality reduction algorithm that can handle null values. One example is NIPALS (Nonlinear Iterative Partial Least Squares) algorithm. That algorithm is discussed in "Multivariate Analysis of Quality: An Introduction" by Martens and Martens

This is a data wrangling problem where you will need to experiment and it's even better if you know your data.

• If you suspect that the null means 0 but the user just omitted it then replace it for zero.
• If you can work with negative numbers replace the nulls with -1 as Nicolas mentioned unless -1 is a value that your numbers reach naturally.
• If these nulls mean something important for your dataset you can create another column B where column A is null.
• Another thing I can think of is that if you have categorical values, then you can one-hot-encode these columns.