feature_nnds <- function(x) {
  d <- as.matrix(x)
  nnds <- sapply(1:nrow(d), function(i) min(d[i,][-i]))
  list(nnds_min=min(nnds),
       nnds_mean=mean(nnds),
       nnds_median=median(nnds),
       nnds_max=max(nnds),
       nnds_sd=sd(nnds),
       nnds_varcoef=sd(nnds)/mean(nnds)
       )
}
