public class DMatrix extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
DMatrix.QuantileCut
A class to hold the quantile information
|
static class |
DMatrix.SparseType
sparse matrix type (CSR or CSC)
|
| Modifier and Type | Field and Description |
|---|---|
protected long |
handle |
| Modifier | Constructor and Description |
|---|---|
|
DMatrix(BigDenseMatrix matrix)
create DMatrix from a BigDenseMatrix
|
|
DMatrix(BigDenseMatrix matrix,
float missing)
create DMatrix from dense matrix
|
|
DMatrix(ColumnBatch columnBatch,
float missing,
int nthread)
Create the normal DMatrix from column array interface
|
|
DMatrix(float[] data,
int nrow,
int ncol)
Deprecated.
Please specify the missing value explicitly using
DMatrix(float[], int, int, float) |
|
DMatrix(float[] data,
int nrow,
int ncol,
float missing)
create DMatrix from dense matrix
|
|
DMatrix(Iterator<LabeledPoint> iter,
String cacheInfo)
Create DMatrix from iterator.
|
|
DMatrix(Iterator<LabeledPoint> iter,
String cacheInfo,
float missing)
Create DMatrix from iterator.
|
protected |
DMatrix(long handle)
used for DMatrix slice
|
|
DMatrix(long[] headers,
int[] indices,
float[] data,
DMatrix.SparseType st)
Deprecated.
|
|
DMatrix(long[] headers,
int[] indices,
float[] data,
DMatrix.SparseType st,
int shapeParam)
Create DMatrix from Sparse matrix in CSR/CSC format.
|
|
DMatrix(long[] headers,
int[] indices,
float[] data,
DMatrix.SparseType st,
int shapeParam,
float missing,
int nthread) |
|
DMatrix(String dataPath)
Create DMatrix by loading libsvm file from dataPath
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose() |
protected void |
finalize() |
float[] |
getBaseMargin()
Get base margin of the DMatrix.
|
String[] |
getFeatureNames()
Get feature names
|
String[] |
getFeatureTypes()
Get feature types
|
int[] |
getGroup()
Get group sizes of DMatrix
|
long |
getHandle()
Get the handle
|
float[] |
getLabel()
get label values
|
DMatrix.QuantileCut |
getQuantileCut()
Get the Quantile Cut.
|
float[] |
getWeight()
get weight of the DMatrix
|
long |
nonMissingNum()
Get the number of non-missing values of DMatrix.
|
long |
rowNum()
get the row number of DMatrix
|
void |
saveBinary(String filePath)
save DMatrix to filePath
|
void |
setBaseMargin(Column column)
Set base margin of DMatrix from array interface
|
void |
setBaseMargin(float[] baseMargin)
Set base margin (initial prediction).
|
void |
setBaseMargin(float[][] baseMargin)
Set base margin (initial prediction).
|
void |
setFeatureNames(String[] values)
Set feature names
|
void |
setFeatureTypes(String[] values)
Set feature types
|
void |
setGroup(int[] group)
Set group sizes of DMatrix (used for ranking)
|
void |
setLabel(Column column)
Set label of DMatrix from array interface
|
void |
setLabel(float[] labels)
set label of dmatrix
|
void |
setQueryId(Column column)
Set query id of DMatrix from array interface
|
void |
setQueryId(int[] qid)
Set query ids (used for ranking)
|
void |
setWeight(Column column)
Set weight of DMatrix from array interface
|
void |
setWeight(float[] weights)
set weight of each instance
|
DMatrix |
slice(int[] rowIndex)
Slice the DMatrix and return a new DMatrix that only contains `rowIndex`.
|
public DMatrix(Iterator<LabeledPoint> iter, String cacheInfo) throws XGBoostError
iter - The data iterator of mini batch to provide the data.cacheInfo - Cache path information, used for external memory setting, can be null.XGBoostErrorpublic DMatrix(Iterator<LabeledPoint> iter, String cacheInfo, float missing) throws XGBoostError
iter - The data iterator of mini batch to provide the data.cacheInfo - Cache path information, used for external memory setting, can be null.missing - the missing valueXGBoostErrorpublic DMatrix(String dataPath) throws XGBoostError
dataPath - The path to the data.XGBoostError@Deprecated public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st) throws XGBoostError
headers - The row index of the matrix.indices - The indices of presenting entries.data - The data content.st - Type of sparsity.XGBoostErrorpublic DMatrix(long[] headers,
int[] indices,
float[] data,
DMatrix.SparseType st,
int shapeParam)
throws XGBoostError
headers - The row index of the matrix.indices - The indices of presenting entries.data - The data content.st - Type of sparsity.shapeParam - when st is CSR, it specifies the column number, otherwise it is taken as
row numberXGBoostErrorpublic 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 - data valuesnrow - number of rowsncol - number of columnsXGBoostError - native errorpublic DMatrix(BigDenseMatrix matrix) throws XGBoostError
matrix - instance of BigDenseMatrixXGBoostError - native errorpublic DMatrix(float[] data,
int nrow,
int ncol,
float missing)
throws XGBoostError
data - data valuesnrow - number of rowsncol - number of columnsmissing - the specified value to represent the missing valueXGBoostErrorpublic DMatrix(BigDenseMatrix matrix, float missing) throws XGBoostError
matrix - instance of BigDenseMatrixmissing - the specified value to represent the missing valueXGBoostErrorprotected DMatrix(long handle)
public DMatrix(ColumnBatch columnBatch, float missing, int nthread) throws XGBoostError
columnBatch - the XGBoost ColumnBatch to provide the array interface
of feature columnsmissing - missing valuenthread - threads numberXGBoostErrorpublic void setQueryId(Column column) throws XGBoostError
column - the XGBoost Column to provide the array interface
of query id columnXGBoostError - native errorpublic String[] getFeatureNames() throws XGBoostError
XGBoostErrorpublic void setFeatureNames(String[] values) throws XGBoostError
values - feature names to be setXGBoostErrorpublic String[] getFeatureTypes() throws XGBoostError
XGBoostErrorpublic void setFeatureTypes(String[] values) throws XGBoostError
values - feature types to be setXGBoostErrorpublic int[] getGroup()
throws XGBoostError
XGBoostError - native errorpublic void setGroup(int[] group)
throws XGBoostError
group - group size as arrayXGBoostError - native errorpublic void setQueryId(int[] qid)
throws XGBoostError
qid - the query idsXGBoostError - native errorpublic float[] getLabel()
throws XGBoostError
XGBoostError - native errorpublic void setLabel(Column column) throws XGBoostError
column - the XGBoost Column to provide the array interface
of label columnXGBoostError - native errorpublic void setLabel(float[] labels)
throws XGBoostError
labels - labelsXGBoostError - native errorpublic float[] getWeight()
throws XGBoostError
XGBoostError - native errorpublic void setWeight(Column column) throws XGBoostError
column - the XGBoost Column to provide the array interface
of weight columnXGBoostError - native errorpublic void setWeight(float[] weights)
throws XGBoostError
weights - weightsXGBoostError - native errorpublic float[] getBaseMargin()
throws XGBoostError
XGBoostErrorpublic void setBaseMargin(Column column) throws XGBoostError
column - the XGBoost Column to provide the array interface
of base margin columnXGBoostError - native errorpublic void setBaseMargin(float[] baseMargin)
throws XGBoostError
The margin must have the same number of elements as the number of rows in this matrix.
XGBoostErrorpublic void setBaseMargin(float[][] baseMargin)
throws XGBoostError
XGBoostErrorpublic DMatrix slice(int[] rowIndex) throws XGBoostError
rowIndex - row indexXGBoostError - native errorpublic long rowNum()
throws XGBoostError
XGBoostError - native errorpublic long nonMissingNum()
throws XGBoostError
XGBoostError - native errorpublic void saveBinary(String filePath)
public long getHandle()
public void dispose()
public DMatrix.QuantileCut getQuantileCut() throws XGBoostError
XGBoostErrorCopyright © 2026. All rights reserved.