Class LGBMDataset

java.lang.Object
io.github.metarank.lightgbm4j.LGBMDataset
All Implemented Interfaces:
AutoCloseable

public class LGBMDataset extends Object implements AutoCloseable
  • Field Details

  • Method Details

    • createFromFile

      public static LGBMDataset createFromFile(String fileName, String parameters, LGBMDataset reference) throws LGBMException
      Load dataset from file (like LightGBM CLI version does).
      Parameters:
      fileName - The name of the file
      parameters - Additional parameters
      Returns:
      Throws:
      LGBMException
    • createFromMat

      public static LGBMDataset createFromMat(float[] data, int rows, int cols, boolean isRowMajor, String parameters, LGBMDataset reference) throws LGBMException
      Create dataset from dense float[] matrix.
      Parameters:
      data - input matrix
      rows - number of rows
      cols - number of cols
      isRowMajor - is a row-major encoding used?
      parameters - extra parameters
      Returns:
      Throws:
      LGBMException
    • createFromMat

      public static LGBMDataset createFromMat(double[] data, int rows, int cols, boolean isRowMajor, String parameters, LGBMDataset reference) throws LGBMException
      Create dataset from dense double[] matrix.
      Parameters:
      data - input matrix
      rows - number of rows
      cols - number of cols
      isRowMajor - is a row-major encoding used?
      parameters - extra parameters
      reference - to align bin mappers with other dataset
      Returns:
      Throws:
      LGBMException
    • getNumData

      public int getNumData() throws LGBMException
      Get number of data points.
      Returns:
      number of data points
      Throws:
      LGBMException
    • getNumFeatures

      public int getNumFeatures() throws LGBMException
      Get number of features.
      Returns:
      number of features
      Throws:
      LGBMException
    • setFeatureNames

      public void setFeatureNames(String[] featureNames) throws LGBMException
      Set feature names
      Parameters:
      featureNames - a list of names.
      Throws:
      LGBMException
    • dumpText

      public void dumpText(String fileName) throws LGBMException
      Dumps dataset into a file for debugging.
      Parameters:
      fileName -
      Throws:
      LGBMException
    • setField

      public void setField(String fieldName, double[] data) throws LGBMException
      Sets a double field. label and weight fields can only be float[]
      Parameters:
      fieldName -
      data -
      Throws:
      LGBMException
    • setField

      public void setField(String fieldName, int[] data) throws LGBMException
      Sets an int field. It can only accept the group field.
      Parameters:
      fieldName -
      data -
      Throws:
      LGBMException
    • setField

      public void setField(String fieldName, float[] data) throws LGBMException
      Sets a double field. label and weight fields can only be float[]
      Parameters:
      fieldName -
      data -
      Throws:
      LGBMException
    • getFeatureNames

      public String[] getFeatureNames() throws LGBMException
      Gets feature names from dataset, if dataset supports it.
      Returns:
      list of feature names
      Throws:
      LGBMException
    • getFieldFloat

      public float[] getFieldFloat(String field) throws LGBMException
      Get float[] field from the dataset.
      Parameters:
      field - Field name
      Returns:
      Throws:
      LGBMException
    • getFieldInt

      public int[] getFieldInt(String field) throws LGBMException
      Get int[] field from the dataset.
      Parameters:
      field - Field name
      Returns:
      Throws:
      LGBMException
    • close

      public void close() throws LGBMException
      Deallocate all native memory for the LightGBM dataset.
      Specified by:
      close in interface AutoCloseable
      Throws:
      LGBMException