Maxim Haytovich Maxim Haytovich - 1 year ago 369
R Question

R boruta package - (list) object cannot be coerced to type 'double'

I am trying to run a boruta feature selection on my data set.

The code is below:

df<-read.csv('F:/DataAnalyticsClub/DACaseComp/DatasetDist/Datasets/BestFile.csv',stringsAsFactors=FALSE )
df[] <- 0
df[df == ""] <- 0
X<-df[ , -which(names(df) %in% c("PREVSALEDATE","PREVSALEDATE2","ClassLabel", "PARID", "PROPERTYUNIT", "PriceDiff1", "PriceDiff2", "DateDiff1", "DateDiff2", "SALEDATE"))]


X[factorCols] <- lapply(X[factorCols], factor)


So you see that I have a data set of different features, some of them are string features, so I convert them to factors. The rest is numeric. I test my assumptions:
enter image description here
And once I run the Boruta I get

Error in data.matrix(data.selected) :
(list) object cannot be coerced to type 'double'

I am not sure why. All of my columns are Factors or varoius numeric types. What can be wrong?

After googling a bit I found that some people recommend to do the as.matrix() conversion, but in such case:

> boruta.train<-Boruta(as.matrix(X),as.matrix(Y))
Error: Variable none not found. Ranger will EXIT now.
Error in ranger::ranger(data = x, = "shadow.Boruta.decision", :
User interrupt or internal error.

Answer Source

Ok, after playing around with that I managed to identify the problem. Boruta requires Y (target) to be of the list type, not dataframe or anything else.

So just creating Y like this:


Solves the problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download