XGBoost:将 dmatrix 转换为 numpy.array [英] XGBoost: Convert dmatrix into a numpy.array

查看:81
本文介绍了XGBoost:将 dmatrix 转换为 numpy.array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查 DMatrix 对象.文档提到获取行数的方法和列以及每行的切片:

I'd like to inspect the DMatrix object. The documentation mentions the methods to get the number of rows and columns and also the slice at each row:

dmatrix.slice(index)

但我想使用 numpy 进行更复杂的转换.有没有一种简单的方法可以将 DMatrix 转换为 numpy 数组?

But I'd like to do more complex transformations using numpy. Is there a simple way to convert the DMatrix to a numpy array?

推荐答案

DMatrix 是一条单行道!获得 DMatrix 后,您无法将其内容作为 numpy.ndarraypandas.DataFrame 取回.

DMatrix is a one-way street! Once you get DMatrix, you cannot get back its content as numpy.ndarray or pandas.DataFrame.

[更新] 一个库仅用于将 XGBoost 的 DMatrix 格式转换为 numpy.array 的特定任务:https://github.com/aporia-ai/dmatrix2np

[Update] A library is implemented only for the particular task of convert XGBoost's DMatrix format to numpy.array: https://github.com/aporia-ai/dmatrix2np

这篇关于XGBoost:将 dmatrix 转换为 numpy.array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆