dataset.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:instacart-basket-prediction 作者: colinmorris 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号