Package ml.dmlc.xgboost4j.java
Class DMatrix
java.lang.Object
ml.dmlc.xgboost4j.java.DMatrix
DMatrix for xgboost.
- Author:
- hzx
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA class to hold the quantile informationstatic enumsparse matrix type (CSR or CSC) -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDMatrix(float[] data, int nrow, int ncol) Deprecated.DMatrix(float[] data, int nrow, int ncol, float missing) create DMatrix from dense matrixprotectedDMatrix(long handle) used for DMatrix sliceDMatrix(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) Create DMatrix by loading libsvm file from dataPathDMatrix(Iterator<LabeledPoint> iter, String cacheInfo) Create DMatrix from iterator.DMatrix(Iterator<LabeledPoint> iter, String cacheInfo, float missing) Create DMatrix from iterator.DMatrix(ColumnBatch columnBatch, float missing, int nthread) Create the normal DMatrix from column array interfaceDMatrix(BigDenseMatrix matrix) create DMatrix from a BigDenseMatrixDMatrix(BigDenseMatrix matrix, float missing) create DMatrix from dense matrix -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()protected voidfinalize()float[]Get base margin of the DMatrix.String[]Get feature namesString[]Get feature typesint[]getGroup()Get group sizes of DMatrixlongGet the handlefloat[]getLabel()get label valuesGet the Quantile Cut.float[]get weight of the DMatrixlongGet the number of non-missing values of DMatrix.longrowNum()get the row number of DMatrixvoidsaveBinary(String filePath) save DMatrix to filePathvoidsetBaseMargin(float[] baseMargin) Set base margin (initial prediction).voidsetBaseMargin(float[][] baseMargin) Set base margin (initial prediction).voidsetBaseMargin(Column column) Set base margin of DMatrix from array interfacevoidsetFeatureNames(String[] values) Set feature namesvoidsetFeatureTypes(String[] values) Set feature typesvoidsetGroup(int[] group) Set group sizes of DMatrix (used for ranking)voidsetLabel(float[] labels) set label of dmatrixvoidSet label of DMatrix from array interfacevoidsetQueryId(int[] qid) Set query ids (used for ranking)voidsetQueryId(Column column) Set query id of DMatrix from array interfacevoidsetWeight(float[] weights) set weight of each instancevoidSet weight of DMatrix from array interfaceslice(int[] rowIndex) Slice the DMatrix and return a new DMatrix that only contains `rowIndex`.
-
Field Details
-
handle
protected long handle
-
-
Constructor Details
-
DMatrix
Create DMatrix from iterator.- Parameters:
iter- The data iterator of mini batch to provide the data.cacheInfo- Cache path information, used for external memory setting, can be null.- Throws:
XGBoostError
-
DMatrix
Create DMatrix from iterator.- Parameters:
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 value- Throws:
XGBoostError
-
DMatrix
Create DMatrix by loading libsvm file from dataPath- Parameters:
dataPath- The path to the data.- Throws:
XGBoostError
-
DMatrix
@Deprecated public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st) throws XGBoostError Deprecated.Create DMatrix from Sparse matrix in CSR/CSC format.- Parameters:
headers- The row index of the matrix.indices- The indices of presenting entries.data- The data content.st- Type of sparsity.- Throws:
XGBoostError
-
DMatrix
public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam) throws XGBoostError Create DMatrix from Sparse matrix in CSR/CSC format.- Parameters:
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 number- Throws:
XGBoostError
-
DMatrix
public DMatrix(long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam, float missing, int nthread) throws XGBoostError - Throws:
XGBoostError
-
DMatrix
Deprecated.Please specify the missing value explicitly usingDMatrix(float[],int,int,float)create DMatrix from dense matrix- Parameters:
data- data valuesnrow- number of rowsncol- number of columns- Throws:
XGBoostError- native error
-
DMatrix
create DMatrix from a BigDenseMatrix- Parameters:
matrix- instance of BigDenseMatrix- Throws:
XGBoostError- native error
-
DMatrix
create DMatrix from dense matrix- Parameters:
data- data valuesnrow- number of rowsncol- number of columnsmissing- the specified value to represent the missing value- Throws:
XGBoostError
-
DMatrix
create DMatrix from dense matrix- Parameters:
matrix- instance of BigDenseMatrixmissing- the specified value to represent the missing value- Throws:
XGBoostError
-
DMatrix
protected DMatrix(long handle) used for DMatrix slice -
DMatrix
Create the normal DMatrix from column array interface- Parameters:
columnBatch- the XGBoost ColumnBatch to provide the array interface of feature columnsmissing- missing valuenthread- threads number- Throws:
XGBoostError
-
-
Method Details
-
setQueryId
Set query id of DMatrix from array interface- Parameters:
column- the XGBoost Column to provide the array interface of query id column- Throws:
XGBoostError- native error
-
getFeatureNames
Get feature names- Returns:
- an array of feature names to be returned
- Throws:
XGBoostError
-
setFeatureNames
Set feature names- Parameters:
values- feature names to be set- Throws:
XGBoostError
-
getFeatureTypes
Get feature types- Returns:
- an array of feature types to be returned
- Throws:
XGBoostError
-
setFeatureTypes
Set feature types- Parameters:
values- feature types to be set- Throws:
XGBoostError
-
getGroup
Get group sizes of DMatrix- Returns:
- group size as array
- Throws:
XGBoostError- native error
-
setGroup
Set group sizes of DMatrix (used for ranking)- Parameters:
group- group size as array- Throws:
XGBoostError- native error
-
setQueryId
Set query ids (used for ranking)- Parameters:
qid- the query ids- Throws:
XGBoostError- native error
-
getLabel
get label values- Returns:
- label
- Throws:
XGBoostError- native error
-
setLabel
Set label of DMatrix from array interface- Parameters:
column- the XGBoost Column to provide the array interface of label column- Throws:
XGBoostError- native error
-
setLabel
set label of dmatrix- Parameters:
labels- labels- Throws:
XGBoostError- native error
-
getWeight
get weight of the DMatrix- Returns:
- weights
- Throws:
XGBoostError- native error
-
setWeight
Set weight of DMatrix from array interface- Parameters:
column- the XGBoost Column to provide the array interface of weight column- Throws:
XGBoostError- native error
-
setWeight
set weight of each instance- Parameters:
weights- weights- Throws:
XGBoostError- native error
-
getBaseMargin
Get base margin of the DMatrix.- Throws:
XGBoostError
-
setBaseMargin
Set base margin of DMatrix from array interface- Parameters:
column- the XGBoost Column to provide the array interface of base margin column- Throws:
XGBoostError- native error
-
setBaseMargin
Set base margin (initial prediction).The margin must have the same number of elements as the number of rows in this matrix.
- Throws:
XGBoostError
-
setBaseMargin
Set base margin (initial prediction).- Throws:
XGBoostError
-
slice
Slice the DMatrix and return a new DMatrix that only contains `rowIndex`.- Parameters:
rowIndex- row index- Returns:
- sliced new DMatrix
- Throws:
XGBoostError- native error
-
rowNum
get the row number of DMatrix- Returns:
- number of rows
- Throws:
XGBoostError- native error
-
nonMissingNum
Get the number of non-missing values of DMatrix.- Returns:
- The number of non-missing values
- Throws:
XGBoostError- native error
-
saveBinary
save DMatrix to filePath -
getHandle
public long getHandle()Get the handle -
finalize
protected void finalize() -
dispose
public void dispose() -
getQuantileCut
Get the Quantile Cut.- Returns:
- QuantileCut
- Throws:
XGBoostError
-
DMatrix(float[],int,int,float)