DMatrix

public class DMatrix

An opaque data matrix class. The actual object is stored in the C++ object handle.

Author

Hyunsu Cho

Constructors

DMatrix

public DMatrix(float[] data, int[] col_ind, long[] row_ptr, long num_row, long num_col)

Create a data matrix representing a 2D sparse matrix

Parameters
  • data – nonzero (non-missing) entries, float32 type

  • col_ind – corresponding column indices, should be of same length as data

  • row_ptr – offsets to define each instance, should be of length [num_row]+1

  • num_row – number of rows (data points) in the matrix

  • num_col – number of columns (features) in the matrix

Throws
  • TreeliteError – error during matrix construction

DMatrix

public DMatrix(double[] data, int[] col_ind, long[] row_ptr, long num_row, long num_col)

DMatrix

public DMatrix(float[] data, float missing_value, long num_row, long num_col)

Create a data matrix representing a 2D dense matrix

Parameters
  • data – array of entries, should be of length [num_row]*[num_col] and of float32 type

  • missing_value – floating-point value representing a missing value; usually set of Float.NaN.

  • num_row – number of rows (data instances) in the matrix

  • num_col – number of columns (features) in the matrix

Throws
  • TreeliteError – error during matrix construction

DMatrix

public DMatrix(double[] data, double missing_value, long num_row, long num_col)

Create a data matrix representing a 2D dense matrix (float64 type)

Parameters
  • data – array of entries, should be of length [num_row]*[num_col] and of float64 type

  • missing_value – floating-point value representing a missing value; usually set of Double.NaN.

  • num_row – number of rows (data instances) in the matrix

  • num_col – number of columns (features) in the matrix

Throws
  • TreeliteError – error during matrix construction

Methods

dispose

public synchronized void dispose()

Destructor, to be called when the object is garbage collected

finalize

protected void finalize()

getHandle

public long getHandle()

Get the underlying native handle

Returns

Integer representing memory address

getNumCol

public long getNumCol()

Get the number of columns in the matrix

Returns

Number of columns in the matrix

getNumElements

public long getNumElements()

Get the number of elements in the matrix

Returns

Number of elements in the matrix

getNumRow

public long getNumRow()

Get the number of rows in the matrix

Returns

Number of rows in the matrix