0
votes

I am trying to find varImp for the following model,

Linear Discriminant Analysis

50 samples 25 predictors 2 classes: 'L', 'Lpo'

No pre-processing Resampling: Leave-One-Out Cross-Validation Summary of sample sizes: 49, 49, 49, 49, 49, 49, ... Addtional sampling using SMOTE

Resampling results:

ROC Sens Spec
0.9433345 0.9439082 0.8942777

caret::varImp(result$models[[2]], scale = TRUE)

Is there an easy fix for this error:

Error in y - mean(y, rm.na = TRUE): non-numeric argument to binary operator
Traceback:

1. caret::varImp(result$models[[2]], scale = TRUE)
2. varImp.train(result$models[[2]], scale = TRUE)
3. filterVarImp(x_dat, y_dat, nonpara = nonpara, ...)
4. apply(x, 2, testFunc, y = y)
5. FUN(newX[, i], ...)

My error

1
its hard to help you without knowing what result$models[[2]] is. It would be much easier if you posted a reproducible example with an inbuilt data set.missuse
I did provide result$models[[2]] in the quotation box starting from Linear Discriminant Analysis. Is that not enough? Thank you so much for even replying by the way, this has been quite a pressing issue for me that I have spent countless hours on.Zyad Shehadeh
Unfortunately it is not. You need to provide code how you created the object, preferably with an inbuilt data set.missuse
Hm ok, I am not sure I am able to share too much as that is above my paygrade to decide. But I will see what I can add to my post in the meantime.Zyad Shehadeh
just use an inbuilt data set like Iris or Sonar and post a minimal example that reproduces the error.missuse

1 Answers

0
votes

As said in the comment by @Zyad Shehadeh and @missuse you have to dput some data or reproduce your error with an in-built dataset. When I tried to reproduce your situation (that you didn't explain very well), with the iris dataset, all it works: I assume that you are running a classification (due to the method="lda") with an imbalance dataset (due to the additional sampling SMOTE). I simulate this kind of data with iris:

library(caret)

data("iris")
#eliminate a level in the Species column and reduce the observation for Species="versicolor" from 50 to 10 to imbalance the outcome 
iris <- iris[-c(1:90),]
iris$Species <- factor(iris$Species,levels = unique(iris$Species))
cn <- trainControl(method = "LOOCV",sampling="smote",classProbs = T,summaryFunction = 
twoClassSummary)
fit <- train(Species~.,data = iris,trControl=cn,method="lda",metric="ROC")

caret::varImp(fit, scale = TRUE)

And all it works, so the problem is somehow related to your data and not to the code