diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BasicWalkThrough.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BasicWalkThrough.java index 86ba49c48..0c6529d2c 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BasicWalkThrough.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BasicWalkThrough.java @@ -31,7 +31,7 @@ import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.demo.util.DataLoader; import org.dmlc.xgboost4j.demo.util.Params; import org.dmlc.xgboost4j.util.Trainer; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * a simple example of java wrapper for xgboost @@ -53,7 +53,7 @@ public class BasicWalkThrough { } - public static void main(String[] args) throws UnsupportedEncodingException, IOException, XgboostError { + public static void main(String[] args) throws UnsupportedEncodingException, IOException, XGBoostError { // load file from text file, also binary buffer generated by xgboost4j DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test"); diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BoostFromPrediction.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BoostFromPrediction.java index 1113eef68..a81da0c59 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BoostFromPrediction.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/BoostFromPrediction.java @@ -23,14 +23,14 @@ import org.dmlc.xgboost4j.Booster; import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.demo.util.Params; import org.dmlc.xgboost4j.util.Trainer; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * example for start from a initial base prediction * @author hzx */ public class BoostFromPrediction { - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { System.out.println("start running example to start from a initial prediction"); // load file from text file, also binary buffer generated by xgboost4j diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CrossValidation.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CrossValidation.java index ec5716700..6dcf917da 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CrossValidation.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CrossValidation.java @@ -19,14 +19,14 @@ import java.io.IOException; import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.util.Trainer; import org.dmlc.xgboost4j.demo.util.Params; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * an example of cross validation * @author hzx */ public class CrossValidation { - public static void main(String[] args) throws IOException, XgboostError { + public static void main(String[] args) throws IOException, XGBoostError { //load train mat DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CustomObjective.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CustomObjective.java index 4aaa053e0..2b8c44ecd 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CustomObjective.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/CustomObjective.java @@ -27,7 +27,7 @@ import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.IObjective; import org.dmlc.xgboost4j.demo.util.Params; import org.dmlc.xgboost4j.util.Trainer; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * an example user define objective and eval @@ -74,7 +74,7 @@ public class CustomObjective { float[] labels; try { labels = dtrain.getLabel(); - } catch (XgboostError ex) { + } catch (XGBoostError ex) { logger.error(ex); return null; } @@ -122,7 +122,7 @@ public class CustomObjective { float[] labels; try { labels = dmat.getLabel(); - } catch (XgboostError ex) { + } catch (XGBoostError ex) { logger.error(ex); return -1f; } @@ -140,7 +140,7 @@ public class CustomObjective { } } - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { //load train mat (svmlight format) DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); //load valid mat (svmlight format) diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/ExternalMemory.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/ExternalMemory.java index e74e3e858..b0a9d27dc 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/ExternalMemory.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/ExternalMemory.java @@ -23,14 +23,14 @@ import org.dmlc.xgboost4j.Booster; import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.demo.util.Params; import org.dmlc.xgboost4j.util.Trainer; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * simple example for using external memory version * @author hzx */ public class ExternalMemory { - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { //this is the only difference, add a # followed by a cache prefix name //several cache file with the prefix will be generated //currently only support convert from libsvm file diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/GeneralizedLinearModel.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/GeneralizedLinearModel.java index db3cd0e59..7d3d717bd 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/GeneralizedLinearModel.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/GeneralizedLinearModel.java @@ -24,7 +24,7 @@ import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.demo.util.CustomEval; import org.dmlc.xgboost4j.demo.util.Params; import org.dmlc.xgboost4j.util.Trainer; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * this is an example of fit generalized linear model in xgboost @@ -32,7 +32,7 @@ import org.dmlc.xgboost4j.util.XgboostError; * @author hzx */ public class GeneralizedLinearModel { - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { // load file from text file, also binary buffer generated by xgboost4j DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test"); diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictFirstNtree.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictFirstNtree.java index 6bcf67f86..2bbd1fd6c 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictFirstNtree.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictFirstNtree.java @@ -25,14 +25,14 @@ import org.dmlc.xgboost4j.util.Trainer; import org.dmlc.xgboost4j.demo.util.CustomEval; import org.dmlc.xgboost4j.demo.util.Params; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * predict first ntree * @author hzx */ public class PredictFirstNtree { - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { // load file from text file, also binary buffer generated by xgboost4j DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test"); diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictLeafIndices.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictLeafIndices.java index 61026a6b8..ede103aeb 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictLeafIndices.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/PredictLeafIndices.java @@ -24,14 +24,14 @@ import org.dmlc.xgboost4j.Booster; import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.util.Trainer; import org.dmlc.xgboost4j.demo.util.Params; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * predict leaf indices * @author hzx */ public class PredictLeafIndices { - public static void main(String[] args) throws XgboostError { + public static void main(String[] args) throws XGBoostError { // load file from text file, also binary buffer generated by xgboost4j DMatrix trainMat = new DMatrix("../../demo/data/agaricus.txt.train"); DMatrix testMat = new DMatrix("../../demo/data/agaricus.txt.test"); diff --git a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/util/CustomEval.java b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/util/CustomEval.java index 116c06ddf..5f25278d5 100644 --- a/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/util/CustomEval.java +++ b/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/util/CustomEval.java @@ -19,7 +19,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dmlc.xgboost4j.DMatrix; import org.dmlc.xgboost4j.IEvaluation; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; /** * a util evaluation class for examples @@ -41,7 +41,7 @@ public class CustomEval implements IEvaluation { float[] labels; try { labels = dmat.getLabel(); - } catch (XgboostError ex) { + } catch (XGBoostError ex) { logger.error(ex); return -1f; } diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java index 0f296241b..51fee441e 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/Booster.java @@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory; import org.dmlc.xgboost4j.util.Initializer; import org.dmlc.xgboost4j.util.ErrorHandle; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; import org.dmlc.xgboost4j.wrapper.XgboostJNI; @@ -59,9 +59,9 @@ public final class Booster { * init Booster from dMatrixs * @param params parameters * @param dMatrixs DMatrix array - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public Booster(Iterable> params, DMatrix[] dMatrixs) throws XgboostError { + public Booster(Iterable> params, DMatrix[] dMatrixs) throws XGBoostError { init(dMatrixs); setParam("seed","0"); setParams(params); @@ -73,9 +73,9 @@ public final class Booster { * load model from modelPath * @param params parameters * @param modelPath booster modelPath (model generated by booster.saveModel) - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public Booster(Iterable> params, String modelPath) throws XgboostError { + public Booster(Iterable> params, String modelPath) throws XGBoostError { long[] out = new long[1]; init(null); loadModel(modelPath); @@ -86,7 +86,7 @@ public final class Booster { - private void init(DMatrix[] dMatrixs) throws XgboostError { + private void init(DMatrix[] dMatrixs) throws XGBoostError { long[] handles = null; if(dMatrixs != null) { handles = dMatrixs2handles(dMatrixs); @@ -101,18 +101,18 @@ public final class Booster { * set parameter * @param key param name * @param value param value - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public final void setParam(String key, String value) throws XgboostError { + public final void setParam(String key, String value) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGBoosterSetParam(handle, key, value)); } /** * set parameters * @param params parameters key-value map - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void setParams(Iterable> params) throws XgboostError { + public void setParams(Iterable> params) throws XGBoostError { if(params!=null) { for(Map.Entry entry : params) { setParam(entry.getKey(), entry.getValue().toString()); @@ -125,9 +125,9 @@ public final class Booster { * Update (one iteration) * @param dtrain training data * @param iter current iteration number - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void update(DMatrix dtrain, int iter) throws XgboostError { + public void update(DMatrix dtrain, int iter) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGBoosterUpdateOneIter(handle, iter, dtrain.getHandle())); } @@ -136,9 +136,9 @@ public final class Booster { * @param dtrain training data * @param iter current iteration number * @param obj customized objective class - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void update(DMatrix dtrain, int iter, IObjective obj) throws XgboostError { + public void update(DMatrix dtrain, int iter, IObjective obj) throws XGBoostError { float[][] predicts = predict(dtrain, true); List gradients = obj.getGradient(predicts, dtrain); boost(dtrain, gradients.get(0), gradients.get(1)); @@ -149,9 +149,9 @@ public final class Booster { * @param dtrain training data * @param grad first order of gradient * @param hess seconde order of gradient - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void boost(DMatrix dtrain, float[] grad, float[] hess) throws XgboostError { + public void boost(DMatrix dtrain, float[] grad, float[] hess) throws XGBoostError { if(grad.length != hess.length) { throw new AssertionError(String.format("grad/hess length mismatch %s / %s", grad.length, hess.length)); } @@ -164,9 +164,9 @@ public final class Booster { * @param evalNames name for eval dmatrixs, used for check results * @param iter current eval iteration * @return eval information - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter) throws XgboostError { + public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter) throws XGBoostError { long[] handles = dMatrixs2handles(evalMatrixs); String[] evalInfo = new String[1]; ErrorHandle.checkCall(XgboostJNI.XGBoosterEvalOneIter(handle, iter, handles, evalNames, evalInfo)); @@ -180,9 +180,9 @@ public final class Booster { * @param iter * @param eval * @return eval information - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter, IEvaluation eval) throws XgboostError { + public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter, IEvaluation eval) throws XGBoostError { String evalInfo = ""; for(int i=0; i getFeatureScore() throws XgboostError { + public Map getFeatureScore() throws XGBoostError { String[] modelInfos = getDumpInfo(false); Map featureScore = new HashMap<>(); for(String tree : modelInfos) { @@ -431,9 +431,9 @@ public final class Booster { * get importance of each feature * @param featureMap file to save dumped model info * @return featureMap key: feature index, value: feature importance score - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public Map getFeatureScore(String featureMap) throws XgboostError { + public Map getFeatureScore(String featureMap) throws XGBoostError { String[] modelInfos = getDumpInfo(featureMap, false); Map featureScore = new HashMap<>(); for(String tree : modelInfos) { diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java index b056cad09..61db98a6d 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/DMatrix.java @@ -19,7 +19,7 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dmlc.xgboost4j.util.ErrorHandle; -import org.dmlc.xgboost4j.util.XgboostError; +import org.dmlc.xgboost4j.util.XGBoostError; import org.dmlc.xgboost4j.util.Initializer; import org.dmlc.xgboost4j.wrapper.XgboostJNI; @@ -52,9 +52,9 @@ public class DMatrix { /** * init DMatrix from file (svmlight format) * @param dataPath - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public DMatrix(String dataPath) throws XgboostError { + public DMatrix(String dataPath) throws XGBoostError { long[] out = new long[1]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromFile(dataPath, 1, out)); handle = out[0]; @@ -66,9 +66,9 @@ public class DMatrix { * @param indices Indices (colIndexs for CSR or rowIndexs for CSC) * @param data non zero values (sequence by row for CSR or by col for CSC) * @param st sparse matrix type (CSR or CSC) - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public DMatrix(long[] headers, int[] indices, float[] data, SparseType st) throws XgboostError { + public DMatrix(long[] headers, int[] indices, float[] data, SparseType st) throws XGBoostError { long[] out = new long[1]; if(st == SparseType.CSR) { ErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromCSR(headers, indices, data, out)); @@ -87,9 +87,9 @@ public class DMatrix { * @param data data values * @param nrow number of rows * @param ncol number of columns - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public DMatrix(float[] data, int nrow, int ncol) throws XgboostError { + public DMatrix(float[] data, int nrow, int ncol) throws XGBoostError { long[] out = new long[1]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromMat(data, nrow, ncol, 0.0f, out)); handle = out[0]; @@ -109,16 +109,16 @@ public class DMatrix { * set label of dmatrix * @param labels */ - public void setLabel(float[] labels) throws XgboostError { + public void setLabel(float[] labels) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "label", labels)); } /** * set weight of each instance * @param weights - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void setWeight(float[] weights) throws XgboostError { + public void setWeight(float[] weights) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "weight", weights)); } @@ -126,9 +126,9 @@ public class DMatrix { * if specified, xgboost will start from this init margin * can be used to specify initial prediction to boost from * @param baseMargin - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void setBaseMargin(float[] baseMargin) throws XgboostError { + public void setBaseMargin(float[] baseMargin) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "base_margin", baseMargin)); } @@ -136,9 +136,9 @@ public class DMatrix { * if specified, xgboost will start from this init margin * can be used to specify initial prediction to boost from * @param baseMargin - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void setBaseMargin(float[][] baseMargin) throws XgboostError { + public void setBaseMargin(float[][] baseMargin) throws XGBoostError { float[] flattenMargin = flatten(baseMargin); setBaseMargin(flattenMargin); } @@ -146,19 +146,19 @@ public class DMatrix { /** * Set group sizes of DMatrix (used for ranking) * @param group - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void setGroup(int[] group) throws XgboostError { + public void setGroup(int[] group) throws XGBoostError { ErrorHandle.checkCall(XgboostJNI.XGDMatrixSetGroup(handle, group)); } - private float[] getFloatInfo(String field) throws XgboostError { + private float[] getFloatInfo(String field) throws XGBoostError { float[][] infos = new float[1][]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixGetFloatInfo(handle, field, infos)); return infos[0]; } - private int[] getIntInfo(String field) throws XgboostError { + private int[] getIntInfo(String field) throws XGBoostError { int[][] infos = new int[1][]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixGetUIntInfo(handle, field, infos)); return infos[0]; @@ -167,27 +167,27 @@ public class DMatrix { /** * get label values * @return label - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public float[] getLabel() throws XgboostError { + public float[] getLabel() throws XGBoostError { return getFloatInfo("label"); } /** * get weight of the DMatrix * @return weights - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public float[] getWeight() throws XgboostError { + public float[] getWeight() throws XGBoostError { return getFloatInfo("weight"); } /** * get base margin of the DMatrix * @return base margin - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public float[] getBaseMargin() throws XgboostError { + public float[] getBaseMargin() throws XGBoostError { return getFloatInfo("base_margin"); } @@ -195,9 +195,9 @@ public class DMatrix { * Slice the DMatrix and return a new DMatrix that only contains `rowIndex`. * @param rowIndex * @return sliced new DMatrix - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public DMatrix slice(int[] rowIndex) throws XgboostError { + public DMatrix slice(int[] rowIndex) throws XGBoostError { long[] out = new long[1]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixSliceDMatrix(handle, rowIndex, out)); long sHandle = out[0]; @@ -208,9 +208,9 @@ public class DMatrix { /** * get the row number of DMatrix * @return number of rows - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public long rowNum() throws XgboostError { + public long rowNum() throws XGBoostError { long[] rowNum = new long[1]; ErrorHandle.checkCall(XgboostJNI.XGDMatrixNumRow(handle,rowNum)); return rowNum[0]; diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/CVPack.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/CVPack.java index 33be48b53..a9b932f0d 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/CVPack.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/CVPack.java @@ -37,9 +37,9 @@ public class CVPack { * @param dtrain train data * @param dtest test data * @param params parameters - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public CVPack(DMatrix dtrain, DMatrix dtest, Iterable> params) throws XgboostError { + public CVPack(DMatrix dtrain, DMatrix dtest, Iterable> params) throws XGBoostError { dmats = new DMatrix[] {dtrain, dtest}; booster = new Booster(params, dmats); names = new String[] {"train", "test"}; @@ -50,9 +50,9 @@ public class CVPack { /** * update one iteration * @param iter iteration num - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void update(int iter) throws XgboostError { + public void update(int iter) throws XGBoostError { booster.update(dtrain, iter); } @@ -60,9 +60,9 @@ public class CVPack { * update one iteration * @param iter iteration num * @param obj customized objective - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public void update(int iter, IObjective obj) throws XgboostError { + public void update(int iter, IObjective obj) throws XGBoostError { booster.update(dtrain, iter, obj); } @@ -70,9 +70,9 @@ public class CVPack { * evaluation * @param iter iteration num * @return - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public String eval(int iter) throws XgboostError { + public String eval(int iter) throws XGBoostError { return booster.evalSet(dmats, names, iter); } @@ -81,9 +81,9 @@ public class CVPack { * @param iter iteration num * @param eval customized eval * @return - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public String eval(int iter, IEvaluation eval) throws XgboostError { + public String eval(int iter, IEvaluation eval) throws XGBoostError { return booster.evalSet(dmats, names, iter, eval); } } diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/ErrorHandle.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/ErrorHandle.java index 5093eb1db..688cd2719 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/ErrorHandle.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/ErrorHandle.java @@ -40,11 +40,11 @@ public class ErrorHandle { /** * check the return value of C API * @param ret return valud of xgboostJNI C API call - * @throws org.dmlc.xgboost4j.util.XgboostError + * @throws org.dmlc.xgboost4j.util.XGBoostError */ - public static void checkCall(int ret) throws XgboostError { + public static void checkCall(int ret) throws XGBoostError { if(ret != 0) { - throw new XgboostError(XgboostJNI.XGBGetLastError()); + throw new XGBoostError(XgboostJNI.XGBGetLastError()); } } } diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/Trainer.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/Trainer.java index a81963da7..e5ac8502a 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/Trainer.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/Trainer.java @@ -47,7 +47,7 @@ public class Trainer { * @return trained booster */ public static Booster train(Iterable> params, DMatrix dtrain, int round, - Iterable> watchs, IObjective obj, IEvaluation eval) throws XgboostError { + Iterable> watchs, IObjective obj, IEvaluation eval) throws XGBoostError { //collect eval matrixs String[] evalNames; @@ -112,7 +112,7 @@ public class Trainer { * @param eval customized evaluation (set to null if not used) * @return evaluation history */ - public static String[] crossValiation(Iterable> params, DMatrix data, int round, int nfold, String[] metrics, IObjective obj, IEvaluation eval) throws XgboostError { + public static String[] crossValiation(Iterable> params, DMatrix data, int round, int nfold, String[] metrics, IObjective obj, IEvaluation eval) throws XGBoostError { CVPack[] cvPacks = makeNFold(data, nfold, params, metrics); String[] evalHist = new String[round]; String[] results = new String[cvPacks.length]; @@ -149,7 +149,7 @@ public class Trainer { * @param evalMetrics Evaluation metrics * @return CV package array */ - public static CVPack[] makeNFold(DMatrix data, int nfold, Iterable> params, String[] evalMetrics) throws XgboostError { + public static CVPack[] makeNFold(DMatrix data, int nfold, Iterable> params, String[] evalMetrics) throws XGBoostError { List samples = genRandPermutationNums(0, (int) data.rowNum()); int step = samples.size()/nfold; int[] testSlice = new int[step]; diff --git a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XgboostError.java b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XGBoostError.java similarity index 88% rename from java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XgboostError.java rename to java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XGBoostError.java index 8dabcee4b..dc7a9a0b2 100644 --- a/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XgboostError.java +++ b/java/xgboost4j/src/main/java/org/dmlc/xgboost4j/util/XGBoostError.java @@ -19,8 +19,8 @@ package org.dmlc.xgboost4j.util; * custom error class for xgboost * @author hzx */ -public class XgboostError extends Exception{ - public XgboostError(String message) { +public class XGBoostError extends Exception{ + public XGBoostError(String message) { super(message); } }