简体   繁体   中英

Is it possible to slim down a GBM model, in R?

Is it possible to remove data from GBM fitted model? I am aware of the keep.data option. However, I'd like to be able to keep data during processing but then slim it down. Also, if I want to keep just a single tree for future predictions (let's say after fitting 1000 trees, I decided that 500 trees works the best in my case, so I'd like to keep only this tree. Is there a safe way to remove excess data from the fitted model without compromising the ability to predict new data?

I think the only really helpful way to do this is to remove the excess trees as you suggest.

If I run the following on the gbm example, I get that the trees make up 80% of the object size, and the data 10%. So deleting the excess trees could save a lot of space.

library(pryr)
bit <- unlist(lapply(gbm1,object_size))
round(bit/sum(bit),3)

You might also try compressing the object, which reduces it's size significantly.

memCompress(serialize(gbm1, NULL), "bzip2")
unserialize(memDecompress(gbm1, type = "bzip2"))

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