Giter Site home page Giter Site logo

Error when setting row.idx about biglasso HOT 7 OPEN

pbreheny avatar pbreheny commented on May 27, 2024
Error when setting row.idx

from biglasso.

Comments (7)

privefl avatar privefl commented on May 27, 2024

What is size, X, y, ...?

from biglasso.

dbstern avatar dbstern commented on May 27, 2024

Sorry, I forgot the line
size = length(y)

Not sure if this answers your question but

str(x)
Formal class 'big.matrix' [package "bigmemory"] with 1 slot
..@ address:
str(y)
logi [1:21989] FALSE TRUE FALSE FALSE FALSE FALSE ...

from biglasso.

privefl avatar privefl commented on May 27, 2024

I mean, could you provide a reproducible example with some example data so that we can run your code and see the error.

from biglasso.

dbstern avatar dbstern commented on May 27, 2024

x <- as.big.matrix(matrix(rnorm(n= 21989,2790), nrow = 21989))
y <- sample(c(0,1), size = 21989, replace = T)
train <- sample(c(T,F), length(y), c(.5,.5), replace = TRUE)
fit <- cv.biglasso(X = x, y = y, row.idx = which(train), penalty = "lasso", family = "binomial", nfolds = 10)
Error in [<-(*tmp*, cv.ind == i, 1:res$nl, value = res$loss) :
(subscript) logical subscript too long

from biglasso.

privefl avatar privefl commented on May 27, 2024

If we run the code step by step after using debugonce(cv.biglasso), we see a first problem where cv.ind is defining folds for the whole sample size, instead of only the indices of training set.

Specifying cv.ind = sample(rep_len(1:10, sum(train))) returns another error.

from biglasso.

dbstern avatar dbstern commented on May 27, 2024

I used deepcopy to workaround this bug, but this was taking too much memory and the server would sometimes crashes. When I use deepcopy on a big.matrix, a corresponding file is created at "dev/shm" (I tried changing the backingfile to my external hd but wasn't successful).

I found that the bigstatsr package makes it easier to deal with these problems (althought I'm not sure if what I'm doing is ok). The code is now something like this:

exthd_path <- "."
file <- file.path(exthd_path,"test.txt")
x <- as.big.matrix(matrix(rnorm(n= 21989,2790), nrow = 21989))
write.big.matrix(x, filename = file, row.names = FALSE, col.names = T, sep = " ")
rm(x); gc()

y <- sample(c(0,1), size = 21989, replace = T)
train <- sample(c(T,F), length(y), c(.5,.5), replace = TRUE)
x <- big_read(file, select = 1)
xtrain <- big_copy(x, ind.row = which(train), backingfile = paste0(bigstatsr::sub_bk(x$bk),"-train"))
fit <- cv.biglasso(X = xtrain$bm(), y = y[train], penalty = "lasso", family = "binomial", nfolds = 10)
unlink(xtrain$bk); rm(xtrain)
unlink(c(x$bk,x$rds)); rm(x)

from biglasso.

privefl avatar privefl commented on May 27, 2024

I think you can directly use big_copy() when x is a big.matrix.

from biglasso.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.