def as_dmatrix(self):
path = self.dmatrix_cache_path
# xgb is not try/except friendly here
if os.path.exists(path):
dm = xgb.DMatrix(path, feature_names=self.feature_names,
feature_types=(self.feature_types if FTYPES else None)
)
else:
logging.info('Cache miss on dmatrix. Building and caching.')
dm = self._as_dmatrix()
dm.save_binary(path)
# We add on weights (if any) after the fact, to avoid proliferation of big
# serialized dmatrix files.
if self.weight_mode != 'none':
weights = self.get_weights()
dm.set_weight(weights)
return dm
dataset.py 文件源码
python
阅读 42
收藏 0
点赞 0
评论 0
评论列表
文章目录