public class DMatrix extends Object
| 修饰符和类型 | 类和描述 |
|---|---|
类 |
DMatrix.QuantileCut
用于保存分位数信息的类
|
静态类 |
DMatrix.SparseType
稀疏矩阵类型(CSR 或 CSC)
|
| 修饰符和类型 | 字段和说明 |
|---|---|
受保护的 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() |
受保护的 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 - 提供数据的迷你批次数据迭代器。cacheInfo - 缓存路径信息,用于外部内存设置,可为空。XGBoostErrorpublic DMatrix(Iterator<LabeledPoint> iter, String cacheInfo, float missing) throws XGBoostError
iter - 提供数据的迷你批次数据迭代器。cacheInfo - 缓存路径信息,用于外部内存设置,可为空。missing - 缺失值XGBoostErrorpublic 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 - 稀疏类型。XGBoostErrorpublic DMatrix(long[] headers,
int[] indices,
float[] data,
DMatrix.SparseType st,
int shapeParam)
throws XGBoostError
headers - 矩阵的行索引。indices - 表示条目的索引。data - 数据内容。st - 稀疏类型。shapeParam - 当 st 为 CSR 时,它指定列数,否则它被视为行数XGBoostErrorpublic 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 - 表示缺失值的指定值XGBoostErrorpublic DMatrix(BigDenseMatrix matrix, float missing) throws XGBoostError
matrix - BigDenseMatrix 的实例missing - 表示缺失值的指定值XGBoostErrorprotected DMatrix(long handle)
public DMatrix(ColumnBatch columnBatch, float missing, int nthread) throws XGBoostError
columnBatch - 提供特征列数组接口的 XGBoost ColumnBatchmissing - 缺失值nthread - 线程数XGBoostErrorpublic void setQueryId(Column column) throws XGBoostError
column - 提供查询 ID 列数组接口的 XGBoost ColumnXGBoostError - 原生错误public String[] getFeatureNames() throws XGBoostError
XGBoostErrorpublic void setFeatureNames(String[] values) throws XGBoostError
values - 要设置的特征名称XGBoostErrorpublic String[] getFeatureTypes() throws XGBoostError
XGBoostErrorpublic void setFeatureTypes(String[] values) throws XGBoostError
values - 要设置的特征类型XGBoostErrorpublic 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
XGBoostErrorpublic void setBaseMargin(Column column) throws XGBoostError
column - 提供基本边距列数组接口的 XGBoost ColumnXGBoostError - 原生错误public void setBaseMargin(float[] baseMargin)
throws XGBoostError
边距必须与此矩阵的行数具有相同数量的元素。
XGBoostErrorpublic void setBaseMargin(float[][] baseMargin)
throws XGBoostError
XGBoostErrorpublic 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. 保留所有权利。