Medial Code Documentation
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes
ml.dmlc.xgboost4j.java.DMatrix Class Reference

DMatrix for xgboost. More...

Inheritance diagram for ml.dmlc.xgboost4j.java.DMatrix:
ml.dmlc.xgboost4j.java.QuantileDMatrix

Data Structures

enum  SparseType
 sparse matrix type (CSR or CSC)
 

Public Member Functions

 DMatrix (Iterator< LabeledPoint > iter, String cacheInfo) throws XGBoostError
 Create DMatrix from iterator.
 
 DMatrix (String dataPath) throws XGBoostError
 Create DMatrix by loading libsvm file from dataPath.
 
 DMatrix (long[] headers, int[] indices, float[] data, DMatrix.SparseType st) throws XGBoostError
 Create DMatrix from Sparse matrix in CSR/CSC format.
 
 DMatrix (long[] headers, int[] indices, float[] data, DMatrix.SparseType st, int shapeParam) throws XGBoostError
 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) throws XGBoostError
 
 DMatrix (float[] data, int nrow, int ncol) throws XGBoostError
 create DMatrix from dense matrix
 
 DMatrix (BigDenseMatrix matrix) throws XGBoostError
 create DMatrix from a BigDenseMatrix
 
 DMatrix (float[] data, int nrow, int ncol, float missing) throws XGBoostError
 create DMatrix from dense matrix
 
 DMatrix (BigDenseMatrix matrix, float missing) throws XGBoostError
 create DMatrix from dense matrix
 
 DMatrix (ColumnBatch columnBatch, float missing, int nthread) throws XGBoostError
 Create the normal DMatrix from column array interface.
 
void setLabel (Column column) throws XGBoostError
 Set label of DMatrix from cuda array interface.
 
void setWeight (Column column) throws XGBoostError
 Set weight of DMatrix from cuda array interface.
 
void setBaseMargin (Column column) throws XGBoostError
 Set base margin of DMatrix from cuda array interface.
 
void setFeatureNames (String[] values) throws XGBoostError
 Set feature names.
 
String[] getFeatureNames () throws XGBoostError
 Get feature names.
 
void setFeatureTypes (String[] values) throws XGBoostError
 Set feature types.
 
String[] getFeatureTypes () throws XGBoostError
 Get feature types.
 
void setLabel (float[] labels) throws XGBoostError
 set label of dmatrix
 
void setWeight (float[] weights) throws XGBoostError
 set weight of each instance
 
void setBaseMargin (float[] baseMargin) throws XGBoostError
 Set base margin (initial prediction).
 
void setBaseMargin (float[][] baseMargin) throws XGBoostError
 Set base margin (initial prediction).
 
void setGroup (int[] group) throws XGBoostError
 Set group sizes of DMatrix (used for ranking)
 
int[] getGroup () throws XGBoostError
 Get group sizes of DMatrix.
 
float[] getLabel () throws XGBoostError
 get label values
 
float[] getWeight () throws XGBoostError
 get weight of the DMatrix
 
float[] getBaseMargin () throws XGBoostError
 Get base margin of the DMatrix.
 
DMatrix slice (int[] rowIndex) throws XGBoostError
 Slice the DMatrix and return a new DMatrix that only contains rowIndex.
 
long rowNum () throws XGBoostError
 get the row number of DMatrix
 
long nonMissingNum () throws XGBoostError
 Get the number of non-missing values of DMatrix.
 
void saveBinary (String filePath)
 save DMatrix to filePath
 
long getHandle ()
 Get the handle.
 
synchronized void dispose ()
 

Protected Member Functions

 DMatrix (long handle)
 used for DMatrix slice
 
void finalize ()
 

Protected Attributes

long handle = 0
 

Detailed Description

DMatrix for xgboost.

Author
hzx

Constructor & Destructor Documentation

◆ DMatrix() [1/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( Iterator< LabeledPoint >  iter,
String  cacheInfo 
) throws XGBoostError
inline

Create DMatrix from iterator.

Parameters
iterThe data iterator of mini batch to provide the data.
cacheInfoCache path information, used for external memory setting, can be null.
Exceptions
XGBoostError

◆ DMatrix() [2/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( String  dataPath) throws XGBoostError
inline

Create DMatrix by loading libsvm file from dataPath.

Parameters
dataPathThe path to the data.
Exceptions
XGBoostError

◆ DMatrix() [3/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( long[]  headers,
int[]  indices,
float[]  data,
DMatrix.SparseType  st 
) throws XGBoostError
inline

Create DMatrix from Sparse matrix in CSR/CSC format.

Parameters
headersThe row index of the matrix.
indicesThe indices of presenting entries.
dataThe data content.
stType of sparsity.
Exceptions
XGBoostError

◆ DMatrix() [4/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( long[]  headers,
int[]  indices,
float[]  data,
DMatrix.SparseType  st,
int  shapeParam 
) throws XGBoostError
inline

Create DMatrix from Sparse matrix in CSR/CSC format.

Parameters
headersThe row index of the matrix.
indicesThe indices of presenting entries.
dataThe data content.
stType of sparsity.
shapeParamwhen st is CSR, it specifies the column number, otherwise it is taken as row number
Exceptions
XGBoostError

◆ DMatrix() [5/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( float[]  data,
int  nrow,
int  ncol 
) throws XGBoostError
inline

create DMatrix from dense matrix

Parameters
datadata values
nrownumber of rows
ncolnumber of columns
Exceptions
XGBoostErrornative error
Deprecated:
Please specify the missing value explicitly using DMatrix(float[], int, int, float)

◆ DMatrix() [6/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( BigDenseMatrix  matrix) throws XGBoostError
inline

create DMatrix from a BigDenseMatrix

Parameters
matrixinstance of BigDenseMatrix
Exceptions
XGBoostErrornative error

◆ DMatrix() [7/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( float[]  data,
int  nrow,
int  ncol,
float  missing 
) throws XGBoostError
inline

create DMatrix from dense matrix

Parameters
datadata values
nrownumber of rows
ncolnumber of columns
missingthe specified value to represent the missing value

◆ DMatrix() [8/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( BigDenseMatrix  matrix,
float  missing 
) throws XGBoostError
inline

create DMatrix from dense matrix

Parameters
matrixinstance of BigDenseMatrix
missingthe specified value to represent the missing value

◆ DMatrix() [9/9]

ml.dmlc.xgboost4j.java.DMatrix.DMatrix ( ColumnBatch  columnBatch,
float  missing,
int  nthread 
) throws XGBoostError
inline

Create the normal DMatrix from column array interface.

Parameters
columnBatchthe XGBoost ColumnBatch to provide the cuda array interface of feature columns
missingmissing value
nthreadthreads number
Exceptions
XGBoostError

Member Function Documentation

◆ getFeatureNames()

String[] ml.dmlc.xgboost4j.java.DMatrix.getFeatureNames ( ) throws XGBoostError
inline

Get feature names.

Returns
an array of feature names to be returned
Exceptions
XGBoostError

◆ getFeatureTypes()

String[] ml.dmlc.xgboost4j.java.DMatrix.getFeatureTypes ( ) throws XGBoostError
inline

Get feature types.

Returns
an array of feature types to be returned
Exceptions
XGBoostError

◆ getGroup()

int[] ml.dmlc.xgboost4j.java.DMatrix.getGroup ( ) throws XGBoostError
inline

Get group sizes of DMatrix.

Exceptions
XGBoostErrornative error
Returns
group size as array

◆ getLabel()

float[] ml.dmlc.xgboost4j.java.DMatrix.getLabel ( ) throws XGBoostError
inline

get label values

Returns
label
Exceptions
XGBoostErrornative error

◆ getWeight()

float[] ml.dmlc.xgboost4j.java.DMatrix.getWeight ( ) throws XGBoostError
inline

get weight of the DMatrix

Returns
weights
Exceptions
XGBoostErrornative error

◆ nonMissingNum()

long ml.dmlc.xgboost4j.java.DMatrix.nonMissingNum ( ) throws XGBoostError
inline

Get the number of non-missing values of DMatrix.

Returns
The number of non-missing values
Exceptions
XGBoostErrornative error

◆ rowNum()

long ml.dmlc.xgboost4j.java.DMatrix.rowNum ( ) throws XGBoostError
inline

get the row number of DMatrix

Returns
number of rows
Exceptions
XGBoostErrornative error

◆ setBaseMargin() [1/3]

void ml.dmlc.xgboost4j.java.DMatrix.setBaseMargin ( Column  column) throws XGBoostError
inline

Set base margin of DMatrix from cuda array interface.

Parameters
columnthe XGBoost Column to provide the cuda array interface of base margin column
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setBaseMargin() [2/3]

void ml.dmlc.xgboost4j.java.DMatrix.setBaseMargin ( float[]  baseMargin) throws XGBoostError
inline

Set base margin (initial prediction).

The margin must have the same number of elements as the number of rows in this matrix.

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setBaseMargin() [3/3]

void ml.dmlc.xgboost4j.java.DMatrix.setBaseMargin ( float  baseMargin[][]) throws XGBoostError
inline

Set base margin (initial prediction).

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setFeatureNames()

void ml.dmlc.xgboost4j.java.DMatrix.setFeatureNames ( String[]  values) throws XGBoostError
inline

Set feature names.

Parameters
valuesfeature names to be set
Exceptions
XGBoostError

◆ setFeatureTypes()

void ml.dmlc.xgboost4j.java.DMatrix.setFeatureTypes ( String[]  values) throws XGBoostError
inline

Set feature types.

Parameters
valuesfeature types to be set
Exceptions
XGBoostError

◆ setGroup()

void ml.dmlc.xgboost4j.java.DMatrix.setGroup ( int[]  group) throws XGBoostError
inline

Set group sizes of DMatrix (used for ranking)

Parameters
groupgroup size as array
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setLabel() [1/2]

void ml.dmlc.xgboost4j.java.DMatrix.setLabel ( Column  column) throws XGBoostError
inline

Set label of DMatrix from cuda array interface.

Parameters
columnthe XGBoost Column to provide the cuda array interface of label column
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setLabel() [2/2]

void ml.dmlc.xgboost4j.java.DMatrix.setLabel ( float[]  labels) throws XGBoostError
inline

set label of dmatrix

Parameters
labelslabels
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setWeight() [1/2]

void ml.dmlc.xgboost4j.java.DMatrix.setWeight ( Column  column) throws XGBoostError
inline

Set weight of DMatrix from cuda array interface.

Parameters
columnthe XGBoost Column to provide the cuda array interface of weight column
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ setWeight() [2/2]

void ml.dmlc.xgboost4j.java.DMatrix.setWeight ( float[]  weights) throws XGBoostError
inline

set weight of each instance

Parameters
weightsweights
Exceptions
XGBoostErrornative error

Reimplemented in ml.dmlc.xgboost4j.java.QuantileDMatrix.

◆ slice()

DMatrix ml.dmlc.xgboost4j.java.DMatrix.slice ( int[]  rowIndex) throws XGBoostError
inline

Slice the DMatrix and return a new DMatrix that only contains rowIndex.

Parameters
rowIndexrow index
Returns
sliced new DMatrix
Exceptions
XGBoostErrornative error

The documentation for this class was generated from the following file: