Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSparse Matrix in caret #474
Comments
Some of that model code was written a decade ago; if a model now allows for a sparse matrix, let me know or do a PR. Thanks, Max |
|
Thanks Max. One that comes to mind is Ranger. I think it can take a sparse matrix for x but from what I can tell from fit method in caret it gets converted to data frame. I 'm not quite sure but I think nnet can also accept a matrix but it gets converted to data frame in caret. XGBoost and glmnet are ones that I'm using right now and both support sparse matrix. FR |
|
I take that back I don't think ranger supports matrix. |
|
The In Test away! |
|
Thank you for speedy response. I noticed line 56 in glmnet.R may not be correct. It says 'x <- as.matri(x)' and should be x <- as. matrix(x). FR |
|
Thanks |
|
I think one more change is needed:
should be
|
|
I'm not sure.
It needs to be a matrix of some sort and I interpret the above to mean either "matrix" or "sparseMatrix" |
|
I am trying to use a I've tried to fix it in my local branch: The first issue is at the line I've change the code to set The second problem - if x is
I've replaced it to:
Now it works but I have a warning from the main train.default function :
May be you have any idea what's wrong? |
|
Sorry for the delay. I think that it is the Also, I just fixed a few things in the devel version related to sparse matrices so try reinstall thing that too. There are some inherent limitations to some of these sparse classes. A lot of existing code needs a data frame or matrix (say for prepreocessing or subsampling) and there are not methods for these sparse matrix classes to accommodate them. |
|
Setting |
It is possible to use sparse matrix with caret? All the code that I've seen in caret uses as.matrix(x) which converts it to a dense matrix (as it was pointed out to me on stack overflow). This sort of defeats the purpose of using a sparse matrix.
TIA,
FR