Getting Started with XGBoost4J
This tutorial introduces Java API for XGBoost.
Data Interface
Like the XGBoost python module, XGBoost4J uses DMatrix to handle data. LIBSVM txt format file, sparse matrix in CSR/CSC format, and dense matrix are supported.
The first step is to import DMatrix:
import ml.dmlc.xgboost4j.java.DMatrix;Use DMatrix constructor to load data from a libsvm text format file:
DMatrix dmat = new DMatrix("train.svm.txt");