1
$\begingroup$

I have a data frame with a large number of NA values. I do not wish to leave out all these rows as that would reduce the size of my training set drastically.

I filled out these missing values in a couple of ways, such as

  1. Filling the NA values in a column with the majority value in that column
  2. Filling the NA values with a random label from that column.

However, I would like to try out something which uses cluster analysis. Is there an R package which allows this? Two things which I can implement are as follows

  1. Finding the k nearest neighbour and filling up the missing/NA value as the majority of the k neighbours. However, this could be difficult because running the knn itself required that the rows don't have NA values, in the first place.
  2. Finding the jaccard similarity based on other columns in the row, and filling up the missing/NA value with the corresponding value from the jaccard similar row.

Finding jaccard match

library(stringdist) df[which.min(Reduce(`+`,Map(stringdist,df, newdata, method='jaccard'))),]

Please suggest me a package/library in R which will help me fill out the missing/NA values using cluster analysis.

$\endgroup$
  • $\begingroup$ I use the mice package in these cases. $\endgroup$ – mace Apr 1 '15 at 21:54
1
$\begingroup$

You can also use the k nearest by jaccard?

It's not as if you are bound to use Euclidean.

Either way, kNN is not clustering. I'd use kNN.

If you look at clustering algorithms, you'll notice that most cannot deal with NA values well either...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.