Class LGBMDataset
java.lang.Object
io.github.metarank.lightgbm4j.LGBMDataset
- All Implemented Interfaces:
AutoCloseable
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Deallocate all native memory for the LightGBM dataset.static LGBMDatasetcreateFromFile(String fileName, String parameters, LGBMDataset reference) Load dataset from file (like LightGBM CLI version does).static LGBMDatasetcreateFromMat(double[] data, int rows, int cols, boolean isRowMajor, String parameters, LGBMDataset reference) Create dataset from dense double[] matrix.static LGBMDatasetcreateFromMat(float[] data, int rows, int cols, boolean isRowMajor, String parameters, LGBMDataset reference) Create dataset from dense float[] matrix.voidDumps dataset into a file for debugging.String[]Gets feature names from dataset, if dataset supports it.float[]getFieldFloat(String field) Get float[] field from the dataset.int[]getFieldInt(String field) Get int[] field from the dataset.intGet number of data points.intGet number of features.voidsetFeatureNames(String[] featureNames) Set feature namesvoidSets a double field.voidSets a double field.voidSets an int field.
-
Field Details
-
handle
-
-
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 fileparameters- 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 matrixrows- number of rowscols- number of colsisRowMajor- 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 matrixrows- number of rowscols- number of colsisRowMajor- is a row-major encoding used?parameters- extra parametersreference- to align bin mappers with other dataset- Returns:
- Throws:
LGBMException
-
getNumData
Get number of data points.- Returns:
- number of data points
- Throws:
LGBMException
-
getNumFeatures
Get number of features.- Returns:
- number of features
- Throws:
LGBMException
-
setFeatureNames
Set feature names- Parameters:
featureNames- a list of names.- Throws:
LGBMException
-
dumpText
Dumps dataset into a file for debugging.- Parameters:
fileName-- Throws:
LGBMException
-
setField
Sets a double field. label and weight fields can only be float[]- Parameters:
fieldName-data-- Throws:
LGBMException
-
setField
Sets an int field. It can only accept the group field.- Parameters:
fieldName-data-- Throws:
LGBMException
-
setField
Sets a double field. label and weight fields can only be float[]- Parameters:
fieldName-data-- Throws:
LGBMException
-
getFeatureNames
Gets feature names from dataset, if dataset supports it.- Returns:
- list of feature names
- Throws:
LGBMException
-
getFieldFloat
Get float[] field from the dataset.- Parameters:
field- Field name- Returns:
- Throws:
LGBMException
-
getFieldInt
Get int[] field from the dataset.- Parameters:
field- Field name- Returns:
- Throws:
LGBMException
-
close
Deallocate all native memory for the LightGBM dataset.- Specified by:
closein interfaceAutoCloseable- Throws:
LGBMException
-