public class DMatrix extends Object
修饰符和类型 | 类和说明 |
---|---|
类 |
DMatrix.QuantileCut
用于存放分位数信息的类
|
静态类 |
DMatrix.SparseType
稀疏矩阵类型(CSR 或 CSC)
|
修饰符和类型 | 字段和说明 |
---|---|
protected long |
handle |
修饰符 | 构造器和说明 |
---|---|
|
DMatrix(BigDenseMatrix matrix)
从 BigDenseMatrix 创建 DMatrix
|
|
DMatrix(BigDenseMatrix matrix, float missing)
从密集矩阵创建 DMatrix
|
|
DMatrix(ColumnBatch columnBatch, float missing, int nthread)
从列数组接口创建普通 DMatrix
|
|
DMatrix(float[] data, int nrow, int ncol)
已废弃。
请使用
DMatrix(float[], int, int, float) 明确指定缺失值。 |
|
DMatrix(float[] data, int nrow, int ncol, float missing)
从密集矩阵创建 DMatrix
|
|
DMatrix(Iterator<LabeledPoint> iter, String cacheInfo)
从迭代器创建 DMatrix。
|
|
DMatrix(Iterator<LabeledPoint> iter, String cacheInfo, float missing)
从迭代器创建 DMatrix。
|
protected |
DMatrix(long handle)
用于 DMatrix 切片
|
|
DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st)
已废弃。
|
|
DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam)
从 CSR/CSC 格式的稀疏矩阵创建 DMatrix。
|
|
DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam, float missing, int nthread) |
|
DMatrix(String dataPath)
通过从 dataPath 加载 libsvm 文件创建 DMatrix
|
修饰符和类型 | 方法和说明 |
---|---|
void |
dispose() |
protected void |
finalize() |
float[] |
getBaseMargin()
获取 DMatrix 的基础边距。
|
String[] |
getFeatureNames()
获取特征名称
|
String[] |
getFeatureTypes()
获取特征类型
|
int[] |
getGroup()
获取 DMatrix 的组大小
|
long |
getHandle()
获取句柄
|
float[] |
getLabel()
获取标签值
|
DMatrix.QuantileCut |
getQuantileCut()
获取分位数切割信息。
|
float[] |
getWeight()
获取 DMatrix 的权重
|
long |
nonMissingNum()
获取 DMatrix 的非缺失值数量。
|
long |
rowNum()
获取 DMatrix 的行数
|
void |
saveBinary(String filePath)
将 DMatrix 保存到 filePath
|
void |
setBaseMargin(Column column)
从数组接口设置 DMatrix 的基础边距
|
void |
setBaseMargin(float[] baseMargin)
设置基础边距(初始预测)。
|
void |
setBaseMargin(float[][] baseMargin)
设置基础边距(初始预测)。
|
void |
setFeatureNames(String[] values)
设置特征名称
|
void |
setFeatureTypes(String[] values)
设置特征类型
|
void |
setGroup(int[] group)
设置 DMatrix 的组大小(用于排序)
|
void |
setLabel(Column column)
从数组接口设置 DMatrix 的标签
|
void |
setLabel(float[] labels)
设置 DMatrix 的标签
|
void |
setQueryId(Column column)
从数组接口设置 DMatrix 的查询 ID
|
void |
setQueryId(int[] qid)
设置查询 ID(用于排序)
|
void |
setWeight(Column column)
从数组接口设置 DMatrix 的权重
|
void |
setWeight(float[] weights)
设置每个实例的权重
|
DMatrix |
slice(int[] rowIndex)
切片 DMatrix 并返回一个仅包含 `rowIndex` 的新 DMatrix。
|
public DMatrix(Iterator<LabeledPoint> iter, String cacheInfo) throws XGBoostError
iter
- 提供数据的mini-batch数据迭代器。cacheInfo
- 缓存路径信息,用于外部内存设置,可以为 null。XGBoostError
public DMatrix(Iterator<LabeledPoint> iter, String cacheInfo, float missing) throws XGBoostError
iter
- 提供数据的mini-batch数据迭代器。cacheInfo
- 缓存路径信息,用于外部内存设置,可以为 null。missing
- 缺失值XGBoostError
public DMatrix(String dataPath) throws XGBoostError
dataPath
- 数据路径。XGBoostError
@Deprecated public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st) throws XGBoostError
headers
- 矩阵的行索引。indices
- 非零元素的索引。data
- 数据内容。st
- 稀疏类型。XGBoostError
public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam) throws XGBoostError
headers
- 矩阵的行索引。indices
- 非零元素的索引。data
- 数据内容。st
- 稀疏类型。shapeParam
- 当 st 是 CSR 时,指定列数,否则视为行数XGBoostError
public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam, float missing, int nthread) throws XGBoostError
XGBoostError
@Deprecated public DMatrix(float[] data, int nrow, int ncol) throws XGBoostError
DMatrix(float[], int, int, float)
明确指定缺失值。data
- 数据值nrow
- 行数ncol
- 列数XGBoostError
- 原生错误public DMatrix(BigDenseMatrix matrix) throws XGBoostError
matrix
- BigDenseMatrix 实例XGBoostError
- 原生错误public DMatrix(float[] data, int nrow, int ncol, float missing) throws XGBoostError
data
- 数据值nrow
- 行数ncol
- 列数missing
- 表示缺失值的指定值XGBoostError
public DMatrix(BigDenseMatrix matrix, float missing) throws XGBoostError
matrix
- BigDenseMatrix 实例missing
- 表示缺失值的指定值XGBoostError
protected DMatrix(long handle)
public DMatrix(ColumnBatch columnBatch, float missing, int nthread) throws XGBoostError
columnBatch
- 提供特征列数组接口的 XGBoost ColumnBatchmissing
- 缺失值nthread
- 线程数XGBoostError
public void setQueryId(Column column) throws XGBoostError
column
- 提供查询 ID 列数组接口的 XGBoost ColumnXGBoostError
- 原生错误public String[] getFeatureNames() throws XGBoostError
XGBoostError
public void setFeatureNames(String[] values) throws XGBoostError
values
- 要设置的特征名称XGBoostError
public String[] getFeatureTypes() throws XGBoostError
XGBoostError
public void setFeatureTypes(String[] values) throws XGBoostError
values
- 要设置的特征类型XGBoostError
public int[] getGroup() throws XGBoostError
XGBoostError
- 原生错误public void setGroup(int[] group) throws XGBoostError
group
- 作为数组的组大小XGBoostError
- 原生错误public void setQueryId(int[] qid) throws XGBoostError
qid
- 查询 IDXGBoostError
- 原生错误public float[] getLabel() throws XGBoostError
XGBoostError
- 原生错误public void setLabel(Column column) throws XGBoostError
column
- 提供标签列数组接口的 XGBoost ColumnXGBoostError
- 原生错误public void setLabel(float[] labels) throws XGBoostError
labels
- 标签XGBoostError
- 原生错误public float[] getWeight() throws XGBoostError
XGBoostError
- 原生错误public void setWeight(Column column) throws XGBoostError
column
- 提供权重列数组接口的 XGBoost ColumnXGBoostError
- 原生错误public void setWeight(float[] weights) throws XGBoostError
weights
- 权重XGBoostError
- 原生错误public float[] getBaseMargin() throws XGBoostError
XGBoostError
public void setBaseMargin(Column column) throws XGBoostError
column
- 提供基础边距列数组接口的 XGBoost ColumnXGBoostError
- 原生错误public void setBaseMargin(float[] baseMargin) throws XGBoostError
边距必须与此矩阵的行数具有相同数量的元素。
XGBoostError
public void setBaseMargin(float[][] baseMargin) throws XGBoostError
XGBoostError
public DMatrix slice(int[] rowIndex) throws XGBoostError
rowIndex
- 行索引XGBoostError
- 原生错误public long rowNum() throws XGBoostError
XGBoostError
- 原生错误public long nonMissingNum() throws XGBoostError
XGBoostError
- 原生错误public void saveBinary(String filePath)
public long getHandle()
public void dispose()
public DMatrix.QuantileCut getQuantileCut() throws XGBoostError
XGBoostError
版权所有 © 2025。保留所有权利。