ramhiser / sparsediscrim

Sparse and Regularized Discriminant Analysis in R
Other
15 stars 5 forks source link

DLDA Fails if One Variable Selected #41

Closed DarioS closed 7 years ago

DarioS commented 7 years ago

If feature selection is done before training and prediction in the rare situation the selection step returns only 1 feature, dlda fails.

Error in colMeans(x[i, ]) : 
  'x' must be an array of at least two dimensions

This (and perhaps other matrix and data frame subsetting) could be changed to the format x[i, , drop = FALSE] to ensure endomorphism. It took me a while to realise why the cross-validation loop I made was sometimes crashing after many successful preceding classifications.

ramhiser commented 7 years ago

@DarioS thanks for opening an issue to let me know. I can't get to this issue today but will by this weekend. PRs welcome.

ramhiser commented 7 years ago

@DarioS can you give me a reproducible example so that I know specifically what type x is in your example when dlda is called?

ramhiser commented 7 years ago

eh, i guess it doesn't matter as much. it's immediately coerced to as.matrix(x).

ramhiser commented 7 years ago

@DarioS everything should be fixed. please let me know if any other problems pop up.