简体   繁体   中英

stratified sampling R: java.lang.OutOfMemoryError: Java heap space

I want to use this function here is the code on github to sample my dataset in 2 parts 90% traning data set ( for example) and 10% (the rest) are the test ( for example tried this code :


library(XLConnect)
library(readxl)
library(xlsx)
library(readxl)
ybi <- read_excel("D:/ii.xls")
#View(ybi)
test= stratified(ybi, 8, .1)

 no= (test$ID_unit) # to get indices of the testdataset samples
 train = ybi [-no,] # the indices for training data 


 write.xlsx(train,"D:/mm.xlsx",sheetName = "Newdata")

in fact my data have 8 attributes and 65534 row. I have selected by the code above just 10% based on the 8 eigth attribute which is the class it gives me without any problm the test set but not the training data ther error is on the figure (joined) error

how to fix it!

It looks like you JVM has no enough memory allocated for the heap.

As a quick fix, export system variable _JAVA_OPTIONS

export _JAVA_OPTIONS="-Xmx8G -Xms1G -Xcheck:jni"

you can also use:

options(java.parameters = "-Xmx8G")

and set -Xmx to a value that will make R happy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM