簡體   English   中英

R-GBM | 數據使訓練好的 GBM 模型非常繁重

[英]R - GBM | Data making trained GBM model very heavy

我們正在使用 GBM 模型來訓練大約 15GB 的海量數據。 訓練后的模型大小變得巨大~17GB。 在經過訓練的模型中,我們看到與樹木和其他模型細節一起保存的數據,約占模型總大小的 96%。

訓練模型中是否有任何數據用途,特別是用於預測目的。 我們正在保存模型並在預測時重新加載模型,這需要很長時間。

如果您在 R 中使用gbm庫,則使用gbm.fit並設置keep.data = FALSE

label = as.numeric(iris$Species=="setosa")
trn = sample(nrow(iris),100)
fit = gbm.fit(x=iris[trn,-5],y=label[trn],shrinkage =0.1,keep.data = FALSE)

這失敗了,因為沒有數據:

predict(fit,n.trees = 10,type="response")
Error in reconstructGBMdata(object) : 
  Cannot reconstruct data from gbm object. gbm() was called with keep.data=FALSE

你可以做:

predict(fit,iris[,-5],10,type="response")
predict(fit,iris[-trn,-5],10,type="response")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM