imputing missing data with softImpute in R

862 Views Asked by At

I'm trying to impute missing values but I have problem dealing with categorical variables. The command softImpute calculate the missing values but they also turn categorical variables, which is inadequate for the analysis. For the missing values I did the following

>softImp = softImpute(as.matrix(train), rank.max = 60)
>data.comp = softImp$u %*% diag(softImp$d) %*% t(softImp$v)
>data.comp=data.frame(data.comp)

However when I look at categorical variables they are in decimal points

> head(data.comp$X91)
[1] 0.6037109 0.6263665 0.5373208 0.6092270 0.8796817 0.8643236

which is originally

> head(train[c(91)])
  H0001600
1        0
2        0
3        1
4        1
5        0
6        1

Is there a certain way to impute missing values for categorical variables? I Any other suggestions dealing with missing values in categorical variables would also help a lot.

0

There are 0 best solutions below