ecpolley / SuperLearner

Current version of the SuperLearner R package
272 stars 72 forks source link

SuperLearner fails if it has polymars method and input train data have type of dataframe #104

Closed stolzkc closed 6 years ago

stolzkc commented 6 years ago

I use this list of methods: c("SL.glmnet", "SL.gam", "SL.randomForest", "SL.polymars", "SL.knn")

And call SL something like

SuperLearner(Y=Y,X=X,SL.library=methods, family=binomial(), method=c("method.NNLS"), verbose=TRUE))

Where type of X is data.frame. The problem is: glmnet is required X to be a data.frame. polymars required X to be data.matrix

You can create and launch single learner for each of them (glmnet and polymars) to see what's going on.

ecpolley commented 6 years ago

Do you have a small example showing the error? SL.glmnet should work with either a matrix of a data.frame. If you have X as a data.frame, then the SL.glmnet code will convert it to a matrix using model.matrix, you might need something similar with SL.polymars. My first guess is your data.frame includes some numeric and character variables, is that correct?

stolzkc commented 6 years ago

Thank you for your answer. It turns out it was incorrect dataframe. I didn't find what exactly is wrong. It's all works after writing dataframe to csv and read from it. Moreover, comparison of pre-written and post-written frames gives me no difference. I need to look more. I'll keep you posted. Thanks again!

stolzkc commented 6 years ago

Changing read_csv to standard read.csv to load train set solved the problem.