From 1540773340e62565528d14bc02f4b9b1e9c6316a Mon Sep 17 00:00:00 2001 From: CodingCat Date: Tue, 22 Dec 2015 03:29:20 -0600 Subject: [PATCH 1/7] sketch of xgboost-spark chooseBestBooster shall be in Boosters remove tracker.py rename XGBoost remove cross-validation --- jvm-packages/pom.xml | 7 +- jvm-packages/scalastyle-config.xml | 4 +- jvm-packages/xgboost4j-demo/pom.xml | 4 +- .../dmlc/xgboost4j/demo/CrossValidation.java | 3 +- jvm-packages/xgboost4j/pom.xml | 2 +- .../java/ml/dmlc/xgboost4j/IObjective.java | 3 +- .../main/java/ml/dmlc/xgboost4j/XGBoost.java | 2 +- .../ml/dmlc/xgboost4j/scala/XGBoost.scala | 4 +- .../ml/dmlc/xgboost4j/BoosterImplTest.java | 2 +- .../scala/ScalaBoosterImplSuite.scala | 2 +- jvm-packages/xgboost4jspark/pom.xml | 24 +++++++ .../dmlc/xgboost4j/scala/DMatrixBuilder.scala | 32 +++++++++ .../dmlc/xgboost4j/scala/spark/Boosters.scala | 47 +++++++++++++ .../dmlc/xgboost4j/scala/spark/XGBoost.scala | 66 +++++++++++++++++++ 14 files changed, 187 insertions(+), 15 deletions(-) create mode 100644 jvm-packages/xgboost4jspark/pom.xml create mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala create mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala create mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala diff --git a/jvm-packages/pom.xml b/jvm-packages/pom.xml index 8228d6712..7ef0f2b58 100644 --- a/jvm-packages/pom.xml +++ b/jvm-packages/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.dmlc + ml.dmlc xgboostjvm 0.1 pom @@ -14,12 +14,13 @@ 1.7 1.7 3.3.9 - 2.11.7 - 2.11 + 2.10.5 + 2.10 xgboost4j xgboost4j-demo + xgboost4jspark diff --git a/jvm-packages/scalastyle-config.xml b/jvm-packages/scalastyle-config.xml index 204b72a20..fd4d22e9a 100644 --- a/jvm-packages/scalastyle-config.xml +++ b/jvm-packages/scalastyle-config.xml @@ -188,8 +188,8 @@ This file is divided into 3 sections: java,scala,3rdParty,spark javax?\..* scala\..* - (?!org\.apache\.spark\.).* - org\.apache\.spark\..* + (?!ml\.dmlc\.xgboost4j\.).* + ml.dmlc.xgboost4j.* diff --git a/jvm-packages/xgboost4j-demo/pom.xml b/jvm-packages/xgboost4j-demo/pom.xml index d8e679b78..4873a4f6d 100644 --- a/jvm-packages/xgboost4j-demo/pom.xml +++ b/jvm-packages/xgboost4j-demo/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.dmlc + ml.dmlc xgboostjvm 0.1 @@ -13,7 +13,7 @@ jar - org.dmlc + ml.dmlc xgboost4j 0.1 diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java index 115b1dc5b..c3e913fd2 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java @@ -49,6 +49,7 @@ public class CrossValidation { //set additional eval_metrics String[] metrics = null; - String[] evalHist = XGBoost.crossValiation(params, trainMat, round, nfold, metrics, null, null); + String[] evalHist = XGBoost.crossValidation(params, trainMat, round, nfold, metrics, null, + null); } } diff --git a/jvm-packages/xgboost4j/pom.xml b/jvm-packages/xgboost4j/pom.xml index fc6b45ccd..51fe13777 100644 --- a/jvm-packages/xgboost4j/pom.xml +++ b/jvm-packages/xgboost4j/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.dmlc + ml.dmlc xgboostjvm 0.1 diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java index 97ef9aed4..c95b18ff6 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java @@ -15,6 +15,7 @@ */ package ml.dmlc.xgboost4j; +import java.io.Serializable; import java.util.List; /** @@ -22,7 +23,7 @@ import java.util.List; * * @author hzx */ -public interface IObjective { +public interface IObjective extends Serializable { /** * user define objective function, return gradient and second order gradient * diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java index 839b006c4..293ce6728 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java @@ -143,7 +143,7 @@ public class XGBoost { * @return evaluation history * @throws XGBoostError native error */ - public static String[] crossValiation( + public static String[] crossValidation( Map params, DMatrix data, int round, diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala index e32bd46a7..8e15f8174 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala @@ -35,7 +35,7 @@ object XGBoost { new ScalaBoosterImpl(xgboostInJava) } - def crossValiation( + def crossValidation( params: Map[String, AnyRef], data: DMatrix, round: Int, @@ -43,7 +43,7 @@ object XGBoost { metrics: Array[String] = null, obj: ObjectiveTrait = null, eval: EvalTrait = null): Array[String] = { - JXGBoost.crossValiation(params.asJava, data.jDMatrix, round, nfold, metrics, obj, eval) + JXGBoost.crossValidation(params.asJava, data.jDMatrix, round, nfold, metrics, obj, eval) } def initBoostModel(params: Map[String, AnyRef], dMatrixs: Array[DMatrix]): Booster = { diff --git a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java index 8f0f3a97e..4a0dd8e16 100644 --- a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java +++ b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java @@ -130,6 +130,6 @@ public class BoosterImplTest { //do 5-fold cross validation int round = 2; int nfold = 5; - String[] evalHist = XGBoost.crossValiation(param, trainMat, round, nfold, null, null, null); + String[] evalHist = XGBoost.crossValidation(param, trainMat, round, nfold, null, null, null); } } diff --git a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala index e911ec985..ab805a70c 100644 --- a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala +++ b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala @@ -85,6 +85,6 @@ class ScalaBoosterImplSuite extends FunSuite { "objective" -> "binary:logistic", "gamma" -> "1.0", "eval_metric" -> "error").toMap val round = 2 val nfold = 5 - XGBoost.crossValiation(params, trainMat, round, nfold, null, null, null) + XGBoost.crossValidation(params, trainMat, round, nfold, null, null, null) } } diff --git a/jvm-packages/xgboost4jspark/pom.xml b/jvm-packages/xgboost4jspark/pom.xml new file mode 100644 index 000000000..b74adfb91 --- /dev/null +++ b/jvm-packages/xgboost4jspark/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + ml.dmlc + xgboostjvm + 0.1 + + xgboost4jspark + + + ml.dmlc + xgboost4j + 0.1 + + + org.apache.spark + spark-core_2.10 + 1.6.0 + + + \ No newline at end of file diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala new file mode 100644 index 000000000..04884ebcf --- /dev/null +++ b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala @@ -0,0 +1,32 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala + +import java.io.DataInputStream + +private[xgboost4j] object DMatrixBuilder extends Serializable { + + def buildDMatrixfromBinaryData(inStream: DataInputStream): DMatrix = { + // TODO: currently it is random statement for making compiler happy + new DMatrix(new Array[Float](1), 1, 1) + } + + def buildDMatrixfromBinaryData(binaryArray: Array[Byte]): DMatrix = { + // TODO: currently it is random statement for making compiler happy + new DMatrix(new Array[Float](1), 1, 1) + } +} diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala new file mode 100644 index 000000000..1fec5a9db --- /dev/null +++ b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala @@ -0,0 +1,47 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala.spark + +import ml.dmlc.xgboost4j.scala.Booster +import org.apache.spark.rdd.RDD + +class Boosters(boosters: RDD[Booster]) { + + def save(path: String): Unit = { + + } + + def chooseBestBooster(boosters: RDD[Booster]): Booster = { + // TODO: + null + } + +} + +object Boosters { + + implicit def boosterRDDToBoosters(boosterRDD: RDD[Booster]): Boosters = { + new Boosters(boosterRDD) + } + + // load booster from path + def apply(path: String): RDD[Booster] = { + // TODO + null + } +} + diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala new file mode 100644 index 000000000..6e276cc9d --- /dev/null +++ b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala @@ -0,0 +1,66 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala.spark + +import scala.collection.immutable.HashMap +import scala.collection.mutable.ListBuffer + +import com.typesafe.config.Config +import ml.dmlc.xgboost4j.scala.{XGBoost => SXGBoost, DMatrixBuilder, Booster, ObjectiveTrait, EvalTrait} +import org.apache.spark.SparkContext +import org.apache.spark.rdd.RDD + +object XGBoost { + + private var _sc: Option[SparkContext] = None + + private def buildSparkContext(config: Config): SparkContext = { + if (_sc.isEmpty) { + // TODO:build SparkContext with the user configuration (cores per task, and cores per executor + // (or total cores) + // NOTE: currently Spark has limited support of configuration of core number in executors + } + _sc.get + } + + def train(config: Config, obj: ObjectiveTrait = null, eval: EvalTrait = null): RDD[Booster] = { + val sc = buildSparkContext(config) + val filePath = config.getString("inputPath") // configuration entry name to be fixed + val numWorkers = config.getInt("numWorkers") + val round = config.getInt("round") + // TODO: build configuration map from config + val xgBoostConfigMap = new HashMap[String, AnyRef]() + sc.binaryFiles(filePath, numWorkers).mapPartitions { + trainingFiles => + val boosters = new ListBuffer[Booster] + // we assume one file per DMatrix + for ((_, fileInStream) <- trainingFiles) { + // TODO: + // step1: build DMatrix from fileInStream.toArray (which returns a Array[Byte]) or + // from a fileInStream.open() (which returns a DataInputStream) + val dMatrix = DMatrixBuilder.buildDMatrixfromBinaryData(fileInStream.toArray()) + // step2: build a Booster + // TODO: how to build watches list??? + boosters += SXGBoost.train(xgBoostConfigMap, dMatrix, round, watches = null, obj, eval) + } + // TODO + boosters.iterator + } + } + + +} From b2d705ffb044c968c4bf693b0380cb60faf0a935 Mon Sep 17 00:00:00 2001 From: CodingCat Date: Fri, 4 Mar 2016 23:26:45 -0500 Subject: [PATCH 2/7] framework of xgboost-spark iterator return java iterator and recover test --- dmlc-core | 2 +- jvm-packages/pom.xml | 2 +- .../pom.xml | 2 +- .../xgboost4j/scala/spark/DataUtils.scala | 74 +++++++++++++++++++ .../dmlc/xgboost4j/scala/spark/XGBoost.scala | 55 ++++++++++++++ .../xgboost4j/scala/spark/XGBoostModel.scala | 37 ++++++++++ .../main/java/ml/dmlc/xgboost4j/DMatrix.java | 2 +- .../java/ml/dmlc/xgboost4j/DataBatch.java | 15 +++- .../ml/dmlc/xgboost4j/JavaBoosterImpl.java | 3 +- .../java/ml/dmlc/xgboost4j/XgboostJNI.java | 3 +- .../ml/dmlc/xgboost4j/scala/DMatrix.scala | 8 +- .../dmlc/xgboost4j/scala/DMatrixBuilder.scala | 32 -------- .../dmlc/xgboost4j/scala/spark/Boosters.scala | 47 ------------ .../dmlc/xgboost4j/scala/spark/XGBoost.scala | 66 ----------------- rabit | 2 +- 15 files changed, 194 insertions(+), 156 deletions(-) rename jvm-packages/{xgboost4jspark => xgboost4j-spark}/pom.xml (93%) create mode 100644 jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala create mode 100644 jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala create mode 100644 jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala delete mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala delete mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala delete mode 100644 jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala diff --git a/dmlc-core b/dmlc-core index 3f6ff43d3..71360023d 160000 --- a/dmlc-core +++ b/dmlc-core @@ -1 +1 @@ -Subproject commit 3f6ff43d3976d5b6d5001608b0e3e526ecde098f +Subproject commit 71360023dba458bdc9f1bc6f4309c1a107cb83a0 diff --git a/jvm-packages/pom.xml b/jvm-packages/pom.xml index 7ef0f2b58..cfc409ddb 100644 --- a/jvm-packages/pom.xml +++ b/jvm-packages/pom.xml @@ -20,7 +20,7 @@ xgboost4j xgboost4j-demo - xgboost4jspark + xgboost4j-spark diff --git a/jvm-packages/xgboost4jspark/pom.xml b/jvm-packages/xgboost4j-spark/pom.xml similarity index 93% rename from jvm-packages/xgboost4jspark/pom.xml rename to jvm-packages/xgboost4j-spark/pom.xml index b74adfb91..d847ca2f4 100644 --- a/jvm-packages/xgboost4jspark/pom.xml +++ b/jvm-packages/xgboost4j-spark/pom.xml @@ -17,7 +17,7 @@ org.apache.spark - spark-core_2.10 + spark-mllib_2.10 1.6.0 diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala new file mode 100644 index 000000000..fd336a9c2 --- /dev/null +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala @@ -0,0 +1,74 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala.spark + +import java.util.{Iterator => JIterator} + +import scala.collection.mutable.ListBuffer +import scala.collection.JavaConverters._ + +import ml.dmlc.xgboost4j.DataBatch +import org.apache.spark.mllib.linalg.{SparseVector, DenseVector, Vector} +import org.apache.spark.mllib.regression.LabeledPoint + +private[spark] object DataUtils extends Serializable { + + private def fetchUpdateFromSparseVector(sparseFeature: SparseVector): (List[Int], List[Float]) = { + (sparseFeature.indices.toList, sparseFeature.values.map(_.toFloat).toList) + } + + private def fetchUpdateFromVector(feature: Vector) = feature match { + case denseFeature: DenseVector => + fetchUpdateFromSparseVector(denseFeature.toSparse) + case sparseFeature: SparseVector => + fetchUpdateFromSparseVector(sparseFeature) + } + + def fromLabeledPointsToSparseMatrix(points: Iterator[LabeledPoint]): JIterator[DataBatch] = { + // TODO: support weight + var samplePos = 0 + // TODO: change hard value + val loadingBatchSize = 100 + val rowOffset = new ListBuffer[Long] + val label = new ListBuffer[Float] + val featureIndices = new ListBuffer[Int] + val featureValues = new ListBuffer[Float] + val dataBatches = new ListBuffer[DataBatch] + for (point <- points) { + val (nonZeroIndices, nonZeroValues) = fetchUpdateFromVector(point.features) + rowOffset(samplePos) = rowOffset.size + label(samplePos) = point.label.toFloat + for (i <- nonZeroIndices.indices) { + featureIndices += nonZeroIndices(i) + featureValues += nonZeroValues(i) + } + samplePos += 1 + if (samplePos % loadingBatchSize == 0) { + // create a data batch + dataBatches += new DataBatch( + rowOffset.toArray.clone(), + null, label.toArray.clone(), featureIndices.toArray.clone(), + featureValues.toArray.clone()) + rowOffset.clear() + label.clear() + featureIndices.clear() + featureValues.clear() + } + } + dataBatches.iterator.asJava + } +} diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala new file mode 100644 index 000000000..96a6210a7 --- /dev/null +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala @@ -0,0 +1,55 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala.spark + +import scala.collection.immutable.HashMap +import scala.collection.JavaConverters._ + +import com.typesafe.config.Config +import ml.dmlc.xgboost4j.{DMatrix => JDMatrix} +import ml.dmlc.xgboost4j.scala.{XGBoost => SXGBoost, _} +import org.apache.spark.SparkContext +import org.apache.spark.mllib.regression.LabeledPoint +import org.apache.spark.rdd.RDD + +object XGBoost { + + private var _sc: Option[SparkContext] = None + + implicit def convertBoosterToXGBoostModel(booster: Booster): XGBoostModel = { + new XGBoostModel(booster) + } + + def train(config: Config, trainingData: RDD[LabeledPoint], obj: ObjectiveTrait = null, + eval: EvalTrait = null): XGBoostModel = { + val sc = trainingData.sparkContext + val dataUtilsBroadcast = sc.broadcast(DataUtils) + val filePath = config.getString("inputPath") // configuration entry name to be fixed + val numWorkers = config.getInt("numWorkers") + val round = config.getInt("round") + // TODO: build configuration map from config + val xgBoostConfigMap = new HashMap[String, AnyRef]() + val boosters = trainingData.repartition(numWorkers).mapPartitions { + trainingSamples => + val dataBatches = dataUtilsBroadcast.value.fromLabeledPointsToSparseMatrix(trainingSamples) + val dMatrix = new DMatrix(new JDMatrix(dataBatches, null)) + Iterator(SXGBoost.train(xgBoostConfigMap, dMatrix, round, watches = null, obj, eval)) + } + // TODO: how to choose best model + boosters.first() + } +} diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala new file mode 100644 index 000000000..849ad6168 --- /dev/null +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala @@ -0,0 +1,37 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.scala.spark + +import scala.collection.JavaConverters._ + +import ml.dmlc.xgboost4j.{DMatrix => JDMatrix} +import ml.dmlc.xgboost4j.scala.{DMatrix, Booster} +import org.apache.spark.mllib.regression.LabeledPoint +import org.apache.spark.rdd.RDD + +class XGBoostModel(booster: Booster) extends Serializable { + + def predict(testSet: RDD[LabeledPoint]): RDD[Array[Array[Float]]] = { + val broadcastBooster = testSet.sparkContext.broadcast(booster) + val dataUtils = testSet.sparkContext.broadcast(DataUtils) + testSet.mapPartitions { testSamples => + val dataBatches = dataUtils.value.fromLabeledPointsToSparseMatrix(testSamples) + val dMatrix = new DMatrix(new JDMatrix(dataBatches, null)) + Iterator(broadcastBooster.value.predict(dMatrix)) + } + } +} diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java index e2b3ecc47..99f55055e 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java @@ -28,7 +28,7 @@ import org.apache.commons.logging.LogFactory; */ public class DMatrix { private static final Log logger = LogFactory.getLog(DMatrix.class); - private long handle = 0; + protected long handle = 0; //load native library static { diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java index 2e48b02f5..3fd2427b8 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java @@ -4,8 +4,6 @@ package ml.dmlc.xgboost4j; * A mini-batch of data that can be converted to DMatrix. * The data is in sparse matrix CSR format. * - * Usually this object is not needed. - * * This class is used to support advanced creation of DMatrix from Iterator of DataBatch, */ public class DataBatch { @@ -19,6 +17,19 @@ public class DataBatch { int[] featureIndex = null; /** value of each non-missing entry in the sparse matrix */ float[] featureValue = null; + + public DataBatch() {} + + public DataBatch(long[] rowOffset, float[] weight, float[] label, int[] featureIndex, + float[] featureValue) { + this.rowOffset = rowOffset; + this.weight = weight; + this.label = label; + this.featureIndex = featureIndex; + this.featureValue = featureValue; + } + + /** * Get number of rows in the data batch. * @return Number of rows in the data batch. diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java index ae265a36d..2820f51b6 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java @@ -491,8 +491,7 @@ class JavaBoosterImpl implements Booster { } // making Booster serializable - private void writeObject(java.io.ObjectOutputStream out) - throws IOException { + private void writeObject(java.io.ObjectOutputStream out) throws IOException { try { out.writeObject(this.toByteArray()); } catch (XGBoostError ex) { diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java index 160396df0..922f8bc8e 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java @@ -27,7 +27,8 @@ class XgboostJNI { public final static native int XGDMatrixCreateFromFile(String fname, int silent, long[] out); - public final static native int XGDMatrixCreateFromDataIter(java.util.Iterator iter, String cache_info, long[] out); + final static native int XGDMatrixCreateFromDataIter(java.util.Iterator iter, + String cache_info, long[] out); public final static native int XGDMatrixCreateFromCSR(long[] indptr, int[] indices, float[] data, long[] out); diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala index 634aef190..8f3d73e2b 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala @@ -16,7 +16,9 @@ package ml.dmlc.xgboost4j.scala -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix, XGBoostError} +import _root_.scala.collection.JavaConverters._ + +import ml.dmlc.xgboost4j.{DMatrix => JDMatrix, DataBatch, XGBoostError} class DMatrix private[scala](private[scala] val jDMatrix: JDMatrix) { @@ -43,6 +45,10 @@ class DMatrix private[scala](private[scala] val jDMatrix: JDMatrix) { this(new JDMatrix(headers, indices, data, st)) } + private[xgboost4j] def this(dataBatch: DataBatch) { + this(new JDMatrix(List(dataBatch).asJava.iterator, null)) + } + /** * create DMatrix from dense matrix * diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala deleted file mode 100644 index 04884ebcf..000000000 --- a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrixBuilder.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (c) 2014 by Contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package ml.dmlc.xgboost4j.scala - -import java.io.DataInputStream - -private[xgboost4j] object DMatrixBuilder extends Serializable { - - def buildDMatrixfromBinaryData(inStream: DataInputStream): DMatrix = { - // TODO: currently it is random statement for making compiler happy - new DMatrix(new Array[Float](1), 1, 1) - } - - def buildDMatrixfromBinaryData(binaryArray: Array[Byte]): DMatrix = { - // TODO: currently it is random statement for making compiler happy - new DMatrix(new Array[Float](1), 1, 1) - } -} diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala deleted file mode 100644 index 1fec5a9db..000000000 --- a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/Boosters.scala +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (c) 2014 by Contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package ml.dmlc.xgboost4j.scala.spark - -import ml.dmlc.xgboost4j.scala.Booster -import org.apache.spark.rdd.RDD - -class Boosters(boosters: RDD[Booster]) { - - def save(path: String): Unit = { - - } - - def chooseBestBooster(boosters: RDD[Booster]): Booster = { - // TODO: - null - } - -} - -object Boosters { - - implicit def boosterRDDToBoosters(boosterRDD: RDD[Booster]): Boosters = { - new Boosters(boosterRDD) - } - - // load booster from path - def apply(path: String): RDD[Booster] = { - // TODO - null - } -} - diff --git a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala b/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala deleted file mode 100644 index 6e276cc9d..000000000 --- a/jvm-packages/xgboost4jspark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (c) 2014 by Contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package ml.dmlc.xgboost4j.scala.spark - -import scala.collection.immutable.HashMap -import scala.collection.mutable.ListBuffer - -import com.typesafe.config.Config -import ml.dmlc.xgboost4j.scala.{XGBoost => SXGBoost, DMatrixBuilder, Booster, ObjectiveTrait, EvalTrait} -import org.apache.spark.SparkContext -import org.apache.spark.rdd.RDD - -object XGBoost { - - private var _sc: Option[SparkContext] = None - - private def buildSparkContext(config: Config): SparkContext = { - if (_sc.isEmpty) { - // TODO:build SparkContext with the user configuration (cores per task, and cores per executor - // (or total cores) - // NOTE: currently Spark has limited support of configuration of core number in executors - } - _sc.get - } - - def train(config: Config, obj: ObjectiveTrait = null, eval: EvalTrait = null): RDD[Booster] = { - val sc = buildSparkContext(config) - val filePath = config.getString("inputPath") // configuration entry name to be fixed - val numWorkers = config.getInt("numWorkers") - val round = config.getInt("round") - // TODO: build configuration map from config - val xgBoostConfigMap = new HashMap[String, AnyRef]() - sc.binaryFiles(filePath, numWorkers).mapPartitions { - trainingFiles => - val boosters = new ListBuffer[Booster] - // we assume one file per DMatrix - for ((_, fileInStream) <- trainingFiles) { - // TODO: - // step1: build DMatrix from fileInStream.toArray (which returns a Array[Byte]) or - // from a fileInStream.open() (which returns a DataInputStream) - val dMatrix = DMatrixBuilder.buildDMatrixfromBinaryData(fileInStream.toArray()) - // step2: build a Booster - // TODO: how to build watches list??? - boosters += SXGBoost.train(xgBoostConfigMap, dMatrix, round, watches = null, obj, eval) - } - // TODO - boosters.iterator - } - } - - -} diff --git a/rabit b/rabit index be50e7b63..1392e9f3d 160000 --- a/rabit +++ b/rabit @@ -1 +1 @@ -Subproject commit be50e7b63224b9fb7ff94ce34df9f8752ef83043 +Subproject commit 1392e9f3da59bd5602ddebee944dd8fb5c6507b0 From 2cec10c46f93f60a692873021c93ee6ed8044d6b Mon Sep 17 00:00:00 2001 From: CodingCat Date: Sat, 5 Mar 2016 00:37:16 -0500 Subject: [PATCH 3/7] try to get more memory from Travis --- .travis.yml | 1 + jvm-packages/pom.xml | 1 + jvm-packages/xgboost4j-demo/pom.xml | 11 +++++++++++ jvm-packages/xgboost4j-spark/pom.xml | 11 +++++++++++ jvm-packages/xgboost4j/pom.xml | 7 +++++++ 5 files changed, 31 insertions(+) diff --git a/.travis.yml b/.travis.yml index c0faccb06..3eafab2a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,7 @@ addons: before_install: - source dmlc-core/scripts/travis/travis_setup_env.sh - export PYTHONPATH=${PYTHONPATH}:${PWD}/python-package + - echo "MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=512m'" > ~/.mavenrc install: - source tests/travis/setup.sh diff --git a/jvm-packages/pom.xml b/jvm-packages/pom.xml index cfc409ddb..ce9883059 100644 --- a/jvm-packages/pom.xml +++ b/jvm-packages/pom.xml @@ -101,6 +101,7 @@ jar-with-dependencies + true diff --git a/jvm-packages/xgboost4j-demo/pom.xml b/jvm-packages/xgboost4j-demo/pom.xml index 4873a4f6d..bef184adb 100644 --- a/jvm-packages/xgboost4j-demo/pom.xml +++ b/jvm-packages/xgboost4j-demo/pom.xml @@ -11,6 +11,17 @@ xgboost4j-demo 0.1 jar + + + + org.apache.maven.plugins + maven-assembly-plugin + + false + + + + ml.dmlc diff --git a/jvm-packages/xgboost4j-spark/pom.xml b/jvm-packages/xgboost4j-spark/pom.xml index d847ca2f4..cb7290654 100644 --- a/jvm-packages/xgboost4j-spark/pom.xml +++ b/jvm-packages/xgboost4j-spark/pom.xml @@ -9,6 +9,17 @@ 0.1 xgboost4jspark + + + + org.apache.maven.plugins + maven-assembly-plugin + + false + + + + ml.dmlc diff --git a/jvm-packages/xgboost4j/pom.xml b/jvm-packages/xgboost4j/pom.xml index 51fe13777..4ab4414a1 100644 --- a/jvm-packages/xgboost4j/pom.xml +++ b/jvm-packages/xgboost4j/pom.xml @@ -22,6 +22,13 @@ true + + org.apache.maven.plugins + maven-assembly-plugin + + false + + org.scalatest scalatest-maven-plugin From 81dbf564a475919ebd7a2bcf75ce00162c15e741 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 5 Mar 2016 09:38:43 -0800 Subject: [PATCH 4/7] [Flink] Check --- jvm-packages/test_distributed.sh | 4 +- jvm-packages/xgboost4j-flink/pom.xml | 47 ++++++++++++ .../scala/ml/dmlc/xgboost4j/flink/Test.scala | 71 +++++++++++++++++++ .../java/ml/dmlc/xgboost4j/RabitTracker.java | 12 ++-- 4 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 jvm-packages/xgboost4j-flink/pom.xml create mode 100644 jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala diff --git a/jvm-packages/test_distributed.sh b/jvm-packages/test_distributed.sh index c9a5b21be..b17f6a3b3 100755 --- a/jvm-packages/test_distributed.sh +++ b/jvm-packages/test_distributed.sh @@ -1,5 +1,5 @@ #!/bin/bash # Simple script to test distributed version, to be deleted later. -cd xgboost4j-demo -java -XX:OnError="gdb - %p" -cp target/xgboost4j-demo-0.1-jar-with-dependencies.jar ml.dmlc.xgboost4j.demo.DistTrain 4 +cd xgboost4j-flink +flink run -c ml.dmlc.xgboost4j.flink.Test -p 4 target/xgboost4j-flink-0.1-jar-with-dependencies.jar cd .. diff --git a/jvm-packages/xgboost4j-flink/pom.xml b/jvm-packages/xgboost4j-flink/pom.xml new file mode 100644 index 000000000..9c7b55427 --- /dev/null +++ b/jvm-packages/xgboost4j-flink/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + org.dmlc + xgboostjvm + 0.1 + + xgboost4j-flink + 0.1 + jar + + + org.dmlc + xgboost4j + 0.1 + + + org.apache.commons + commons-lang3 + 3.4 + + + org.apache.flink + flink-java_2.11 + 0.10.2 + + + org.apache.flink + flink-scala_2.11 + 0.10.2 + + + org.apache.flink + flink-clients_2.11 + 0.10.2 + + + org.apache.flink + flink-ml_2.11 + 0.10.2 + + + + \ No newline at end of file diff --git a/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala new file mode 100644 index 000000000..65de48277 --- /dev/null +++ b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala @@ -0,0 +1,71 @@ +/* + Copyright (c) 2014 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package ml.dmlc.xgboost4j.flink + +import ml.dmlc.xgboost4j.Rabit +import ml.dmlc.xgboost4j.RabitTracker +import ml.dmlc.xgboost4j.scala.Booster +import ml.dmlc.xgboost4j.scala.DMatrix +import ml.dmlc.xgboost4j.scala.XGBoost +import org.apache.commons.logging.Log +import org.apache.commons.logging.LogFactory +import org.apache.flink.api.common.functions.RichMapPartitionFunction +import org.apache.flink.api.scala._ +import org.apache.flink.api.scala.DataSet +import org.apache.flink.api.scala.ExecutionEnvironment +import org.apache.flink.ml.common.LabeledVector +import org.apache.flink.ml.MLUtils +import org.apache.flink.util.Collector + +class ScalaMapFunction(workerEnvs: java.util.Map[String, String]) + extends RichMapPartitionFunction[LabeledVector, Booster] { + val log = LogFactory.getLog(this.getClass) + def mapPartition(it : java.lang.Iterable[LabeledVector], collector: Collector[Booster]): Unit = { + workerEnvs.put("DMLC_TASK_ID", this.getRuntimeContext.getTaskName) + log.info("start with env" + workerEnvs.toString) + Rabit.init(workerEnvs) + + val trainMat = new DMatrix("/home/tqchen/github/xgboost/demo/data/agaricus.txt.train") + + val paramMap = List("eta" -> "1", "max_depth" -> "2", "silent" -> "1", + "objective" -> "binary:logistic").toMap + val watches = List("train" -> trainMat).toMap + val round = 2 + val booster = XGBoost.train(paramMap, trainMat, round, watches, null, null) + Rabit.shutdown() + collector.collect(booster) + } +} + + + +object Test { + val log = LogFactory.getLog(this.getClass) + def main(args: Array[String]) { + val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment + val data = MLUtils.readLibSVM(env, "/home/tqchen/github/xgboost/demo/data/agaricus.txt.train") + val tracker = new RabitTracker(data.getExecutionEnvironment.getParallelism) + log.info("start with parallelism" + data.getExecutionEnvironment.getParallelism) + assert(data.getExecutionEnvironment.getParallelism >= 1) + tracker.start() + + val res = data.mapPartition(new ScalaMapFunction(tracker.getWorkerEnvs)).reduce((x, y) => x) + val model = res.collect() + log.info(model) + } +} + diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java index 99adcb7e5..e6f1c8a24 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java @@ -21,7 +21,7 @@ public class RabitTracker { // environment variable to be pased. private Map envs = new HashMap(); // number of workers to be submitted. - private int num_workers; + private int numWorkers; private AtomicReference trackerProcess = new AtomicReference(); static { @@ -63,8 +63,12 @@ public class RabitTracker { } - public RabitTracker(int num_workers) { - this.num_workers = num_workers; + public RabitTracker(int numWorkers) + throws XGBoostError { + if (numWorkers < 1) { + throw new XGBoostError("numWorkers must be greater equal to one"); + } + this.numWorkers = numWorkers; } /** @@ -100,7 +104,7 @@ public class RabitTracker { private boolean startTrackerProcess() { try { trackerProcess.set(Runtime.getRuntime().exec("python " + tracker_py + - " --num-workers=" + String.valueOf(num_workers))); + " --log-level=DEBUG --num-workers=" + String.valueOf(numWorkers))); loadEnvs(trackerProcess.get().getInputStream()); return true; } catch (IOException ioe) { From ae969a0e69dfcc9bd6891c779c8c745ea01ef907 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 5 Mar 2016 09:53:46 -0800 Subject: [PATCH 5/7] [refactor] move java package to namespace java --- jvm-packages/checkstyle-suppressions.xml | 2 +- .../xgboost4j/{ => java}/demo/BasicWalkThrough.java | 12 ++++++------ .../{ => java}/demo/BoostFromPrediction.java | 10 +++++----- .../xgboost4j/{ => java}/demo/CrossValidation.java | 8 ++++---- .../xgboost4j/{ => java}/demo/CustomObjective.java | 5 ++--- .../ml/dmlc/xgboost4j/{ => java}/demo/DistTrain.java | 5 ++--- .../xgboost4j/{ => java}/demo/ExternalMemory.java | 10 +++++----- .../{ => java}/demo/GeneralizedLinearModel.java | 12 ++++++------ .../xgboost4j/{ => java}/demo/PredictFirstNtree.java | 12 ++++++------ .../{ => java}/demo/PredictLeafIndices.java | 10 +++++----- .../xgboost4j/{ => java}/demo/util/CustomEval.java | 8 ++++---- .../xgboost4j/{ => java}/demo/util/DataLoader.java | 2 +- .../main/scala/ml/dmlc/xgboost4j/flink/Test.scala | 3 +-- .../java/ml/dmlc/xgboost4j/{ => java}/Booster.java | 2 +- .../java/ml/dmlc/xgboost4j/{ => java}/DMatrix.java | 2 +- .../java/ml/dmlc/xgboost4j/{ => java}/DataBatch.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/IEvaluation.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/IObjective.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/JNIErrorHandle.java | 2 +- .../dmlc/xgboost4j/{ => java}/JavaBoosterImpl.java | 2 +- .../dmlc/xgboost4j/{ => java}/NativeLibLoader.java | 2 +- .../java/ml/dmlc/xgboost4j/{ => java}/Rabit.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/RabitTracker.java | 2 +- .../java/ml/dmlc/xgboost4j/{ => java}/XGBoost.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/XGBoostError.java | 2 +- .../ml/dmlc/xgboost4j/{ => java}/XgboostJNI.java | 2 +- .../main/scala/ml/dmlc/xgboost4j/scala/Booster.scala | 4 +--- .../main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala | 6 +++--- .../scala/ml/dmlc/xgboost4j/scala/EvalTrait.scala | 5 +++-- .../ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala | 6 +++--- .../ml/dmlc/xgboost4j/scala/ScalaBoosterImpl.scala | 5 ++--- .../main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala | 2 -- .../dmlc/xgboost4j/{ => java}/BoosterImplTest.java | 3 ++- .../ml/dmlc/xgboost4j/{ => java}/DMatrixTest.java | 5 ++++- .../scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala | 1 - .../dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala | 2 +- 36 files changed, 80 insertions(+), 84 deletions(-) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/BasicWalkThrough.java (93%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/BoostFromPrediction.java (90%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/CrossValidation.java (90%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/CustomObjective.java (98%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/DistTrain.java (97%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/ExternalMemory.java (90%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/GeneralizedLinearModel.java (90%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/PredictFirstNtree.java (88%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/PredictLeafIndices.java (90%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/util/CustomEval.java (89%) rename jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/{ => java}/demo/util/DataLoader.java (98%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/Booster.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/DMatrix.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/DataBatch.java (97%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/IEvaluation.java (96%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/IObjective.java (97%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/JNIErrorHandle.java (97%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/JavaBoosterImpl.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/NativeLibLoader.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/Rabit.java (98%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/RabitTracker.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/XGBoost.java (99%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/XGBoostError.java (95%) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/{ => java}/XgboostJNI.java (99%) rename jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/{ => java}/BoosterImplTest.java (98%) rename jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/{ => java}/DMatrixTest.java (96%) diff --git a/jvm-packages/checkstyle-suppressions.xml b/jvm-packages/checkstyle-suppressions.xml index 21550e139..da60508fc 100644 --- a/jvm-packages/checkstyle-suppressions.xml +++ b/jvm-packages/checkstyle-suppressions.xml @@ -29,5 +29,5 @@ + files="xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java"/> diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BasicWalkThrough.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BasicWalkThrough.java similarity index 93% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BasicWalkThrough.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BasicWalkThrough.java index af5dd8a86..b0de7d0e0 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BasicWalkThrough.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BasicWalkThrough.java @@ -13,18 +13,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; -import ml.dmlc.xgboost4j.demo.util.DataLoader; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; +import ml.dmlc.xgboost4j.java.demo.util.DataLoader; /** * a simple example of java wrapper for xgboost diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BoostFromPrediction.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BoostFromPrediction.java similarity index 90% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BoostFromPrediction.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BoostFromPrediction.java index 335efc2d7..5076892cb 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/BoostFromPrediction.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/BoostFromPrediction.java @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; /** * example for start from a initial base prediction diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CrossValidation.java similarity index 90% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CrossValidation.java index c3e913fd2..8f467c8d3 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CrossValidation.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CrossValidation.java @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.io.IOException; import java.util.HashMap; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; /** * an example of cross validation diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CustomObjective.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java similarity index 98% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CustomObjective.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java index 1b7dd056b..8da76b08d 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/CustomObjective.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java @@ -13,17 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import ml.dmlc.xgboost4j.java.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import ml.dmlc.xgboost4j.*; - /** * an example user define objective and eval * NOTE: when you do customized loss function, the default prediction value is margin diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/DistTrain.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java similarity index 97% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/DistTrain.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java index fdbbc6599..fdc2c1cd8 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/DistTrain.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java @@ -1,14 +1,13 @@ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import ml.dmlc.xgboost4j.java.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import ml.dmlc.xgboost4j.*; - /** * Distributed training example, used to quick test distributed training. diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/ExternalMemory.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/ExternalMemory.java similarity index 90% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/ExternalMemory.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/ExternalMemory.java index 095382953..e73eb058d 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/ExternalMemory.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/ExternalMemory.java @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; /** * simple example for using external memory version diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/GeneralizedLinearModel.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/GeneralizedLinearModel.java similarity index 90% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/GeneralizedLinearModel.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/GeneralizedLinearModel.java index e2e36e351..4ec2fc1a2 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/GeneralizedLinearModel.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/GeneralizedLinearModel.java @@ -13,15 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; -import ml.dmlc.xgboost4j.demo.util.CustomEval; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; +import ml.dmlc.xgboost4j.java.demo.util.CustomEval; /** * this is an example of fit generalized linear model in xgboost diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictFirstNtree.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictFirstNtree.java similarity index 88% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictFirstNtree.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictFirstNtree.java index defa437d3..67a965d64 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictFirstNtree.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictFirstNtree.java @@ -13,15 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; -import ml.dmlc.xgboost4j.demo.util.CustomEval; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; +import ml.dmlc.xgboost4j.java.demo.util.CustomEval; /** * predict first ntree diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictLeafIndices.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictLeafIndices.java similarity index 90% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictLeafIndices.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictLeafIndices.java index d18987292..420f38111 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/PredictLeafIndices.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/PredictLeafIndices.java @@ -13,15 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo; +package ml.dmlc.xgboost4j.java.demo; import java.util.Arrays; import java.util.HashMap; -import ml.dmlc.xgboost4j.Booster; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.XGBoost; -import ml.dmlc.xgboost4j.XGBoostError; +import ml.dmlc.xgboost4j.java.Booster; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.XGBoost; +import ml.dmlc.xgboost4j.java.XGBoostError; /** * predict leaf indices diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/CustomEval.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/CustomEval.java similarity index 89% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/CustomEval.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/CustomEval.java index 93650abd5..b698bf410 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/CustomEval.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/CustomEval.java @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo.util; +package ml.dmlc.xgboost4j.java.demo.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import ml.dmlc.xgboost4j.DMatrix; -import ml.dmlc.xgboost4j.IEvaluation; -import ml.dmlc.xgboost4j.XGBoostError; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.IEvaluation; +import ml.dmlc.xgboost4j.java.XGBoostError; /** * a util evaluation class for examples diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/DataLoader.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/DataLoader.java similarity index 98% rename from jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/DataLoader.java rename to jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/DataLoader.java index 818d61451..5aa456fad 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/demo/util/DataLoader.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/util/DataLoader.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j.demo.util; +package ml.dmlc.xgboost4j.java.demo.util; import java.io.*; import java.util.ArrayList; diff --git a/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala index 65de48277..15ecd7308 100644 --- a/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala +++ b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala @@ -16,8 +16,7 @@ package ml.dmlc.xgboost4j.flink -import ml.dmlc.xgboost4j.Rabit -import ml.dmlc.xgboost4j.RabitTracker +import ml.dmlc.xgboost4j.java.{RabitTracker, Rabit} import ml.dmlc.xgboost4j.scala.Booster import ml.dmlc.xgboost4j.scala.DMatrix import ml.dmlc.xgboost4j.scala.XGBoost diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Booster.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Booster.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Booster.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Booster.java index 0707cff2d..e6e427900 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Booster.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Booster.java @@ -1,4 +1,4 @@ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.IOException; import java.io.Serializable; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java index 99f55055e..d8e1aaf4d 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DMatrix.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.IOException; import java.util.Iterator; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DataBatch.java similarity index 97% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DataBatch.java index 3fd2427b8..b4bbbe690 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/DataBatch.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DataBatch.java @@ -1,4 +1,4 @@ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; /** * A mini-batch of data that can be converted to DMatrix. diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IEvaluation.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IEvaluation.java similarity index 96% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IEvaluation.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IEvaluation.java index 079cd057e..9c28fb0fd 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IEvaluation.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IEvaluation.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; /** * interface for customized evaluation diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IObjective.java similarity index 97% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IObjective.java index c95b18ff6..3ee1d5008 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/IObjective.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/IObjective.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.Serializable; import java.util.List; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JNIErrorHandle.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java similarity index 97% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JNIErrorHandle.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java index d3c63d0ee..7bd64c149 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JNIErrorHandle.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.IOException; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java index 2820f51b6..7e2ade607 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/JavaBoosterImpl.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.*; import java.util.HashMap; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/NativeLibLoader.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/NativeLibLoader.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/NativeLibLoader.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/NativeLibLoader.java index 796eb28aa..199b9ae42 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/NativeLibLoader.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/NativeLibLoader.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.*; import java.lang.reflect.Field; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Rabit.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java similarity index 98% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Rabit.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java index c209a2f5a..ce4be04c5 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/Rabit.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java @@ -1,4 +1,4 @@ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.io.IOException; import java.util.Map; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/RabitTracker.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/RabitTracker.java index e6f1c8a24..762cff7bf 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/RabitTracker.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/RabitTracker.java @@ -1,4 +1,4 @@ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java index 293ce6728..44b7425a2 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoost.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoost.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.util.*; diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoostError.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostError.java similarity index 95% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoostError.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostError.java index 1f62b22fc..7da5c176d 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XGBoostError.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostError.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; /** * custom error class for xgboost diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java similarity index 99% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java index 922f8bc8e..9f6a15a9c 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/XgboostJNI.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; /** diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/Booster.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/Booster.scala index 524a5aa92..88032a61a 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/Booster.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/Booster.scala @@ -18,11 +18,9 @@ package ml.dmlc.xgboost4j.scala import java.io.IOException +import ml.dmlc.xgboost4j.java.XGBoostError import scala.collection.mutable -import ml.dmlc.xgboost4j.XGBoostError - - trait Booster extends Serializable { diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala index 8f3d73e2b..4ee8d04fe 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala @@ -18,7 +18,7 @@ package ml.dmlc.xgboost4j.scala import _root_.scala.collection.JavaConverters._ -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix, DataBatch, XGBoostError} +import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix, DataBatch, XGBoostError} class DMatrix private[scala](private[scala] val jDMatrix: JDMatrix) { @@ -45,8 +45,8 @@ class DMatrix private[scala](private[scala] val jDMatrix: JDMatrix) { this(new JDMatrix(headers, indices, data, st)) } - private[xgboost4j] def this(dataBatch: DataBatch) { - this(new JDMatrix(List(dataBatch).asJava.iterator, null)) + private[xgboost4j] def this(dataBatches: Iterator[DataBatch]) { + this(new JDMatrix(dataBatches.asJava, null)) } /** diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/EvalTrait.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/EvalTrait.scala index 5f4e85683..388005edc 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/EvalTrait.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/EvalTrait.scala @@ -16,7 +16,8 @@ package ml.dmlc.xgboost4j.scala -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix, IEvaluation} +import ml.dmlc.xgboost4j.java +import ml.dmlc.xgboost4j.java.IEvaluation trait EvalTrait extends IEvaluation { @@ -36,7 +37,7 @@ trait EvalTrait extends IEvaluation { */ def eval(predicts: Array[Array[Float]], dmat: DMatrix): Float - private[scala] def eval(predicts: Array[Array[Float]], jdmat: JDMatrix): Float = { + private[scala] def eval(predicts: Array[Array[Float]], jdmat: java.DMatrix): Float = { eval(predicts, new DMatrix(jdmat)) } } diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala index 8f7bb86f0..1b563f96d 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala @@ -16,10 +16,10 @@ package ml.dmlc.xgboost4j.scala +import ml.dmlc.xgboost4j.java +import ml.dmlc.xgboost4j.java.IObjective import scala.collection.JavaConverters._ -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix, IObjective} - trait ObjectiveTrait extends IObjective { /** * user define objective function, return gradient and second order gradient @@ -30,7 +30,7 @@ trait ObjectiveTrait extends IObjective { */ def getGradient(predicts: Array[Array[Float]], dtrain: DMatrix): List[Array[Float]] - private[scala] def getGradient(predicts: Array[Array[Float]], dtrain: JDMatrix): + private[scala] def getGradient(predicts: Array[Array[Float]], dtrain: java.DMatrix): java.util.List[Array[Float]] = { getGradient(predicts, new DMatrix(dtrain)).asJava } diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImpl.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImpl.scala index fab3c1b19..bdb2fb34c 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImpl.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImpl.scala @@ -16,12 +16,11 @@ package ml.dmlc.xgboost4j.scala +import ml.dmlc.xgboost4j.java import scala.collection.JavaConverters._ import scala.collection.mutable -import ml.dmlc.xgboost4j.{Booster => JBooster} - -private[scala] class ScalaBoosterImpl private[xgboost4j](booster: JBooster) extends Booster { +private[scala] class ScalaBoosterImpl private[xgboost4j](booster: java.Booster) extends Booster { override def setParam(key: String, value: String): Unit = { booster.setParam(key, value) diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala index 8e15f8174..966784d18 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala @@ -18,8 +18,6 @@ package ml.dmlc.xgboost4j.scala import scala.collection.JavaConverters._ -import ml.dmlc.xgboost4j.{XGBoost => JXGBoost} - object XGBoost { def train( diff --git a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/BoosterImplTest.java similarity index 98% rename from jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java rename to jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/BoosterImplTest.java index 4a0dd8e16..1d81b5d6b 100644 --- a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/BoosterImplTest.java +++ b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/BoosterImplTest.java @@ -13,12 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; +import ml.dmlc.xgboost4j.java.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Test; diff --git a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/DMatrixTest.java b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/DMatrixTest.java similarity index 96% rename from jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/DMatrixTest.java rename to jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/DMatrixTest.java index 6c8206940..056291ddf 100644 --- a/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/DMatrixTest.java +++ b/jvm-packages/xgboost4j/src/test/java/ml/dmlc/xgboost4j/java/DMatrixTest.java @@ -13,12 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package ml.dmlc.xgboost4j; +package ml.dmlc.xgboost4j.java; import java.util.Arrays; import java.util.Random; import junit.framework.TestCase; +import ml.dmlc.xgboost4j.java.DMatrix; +import ml.dmlc.xgboost4j.java.DataBatch; +import ml.dmlc.xgboost4j.java.XGBoostError; import org.junit.Test; /** diff --git a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala index 64ec3e033..cf7494c98 100644 --- a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala +++ b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala @@ -20,7 +20,6 @@ import java.util.Arrays import scala.util.Random -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix} import org.scalatest.FunSuite class DMatrixSuite extends FunSuite { diff --git a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala index ab805a70c..520af35fd 100644 --- a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala +++ b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/ScalaBoosterImplSuite.scala @@ -16,7 +16,7 @@ package ml.dmlc.xgboost4j.scala -import ml.dmlc.xgboost4j.XGBoostError +import ml.dmlc.xgboost4j.java.XGBoostError import org.apache.commons.logging.LogFactory import org.scalatest.FunSuite From e8560c7909c1d0cd047a103975ff907ec163e881 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 5 Mar 2016 09:53:46 -0800 Subject: [PATCH 6/7] [refactor] move java package to namespace java --- jvm-packages/checkstyle-suppressions.xml | 2 +- .../xgboost4j/java/demo/CustomObjective.java | 3 +- .../dmlc/xgboost4j/java/demo/DistTrain.java | 2 +- .../scala/ml/dmlc/xgboost4j/flink/Test.scala | 5 +- .../java/ml/dmlc/xgboost4j/java/DMatrix.java | 30 ++-- .../dmlc/xgboost4j/java/JNIErrorHandle.java | 2 +- .../dmlc/xgboost4j/java/JavaBoosterImpl.java | 30 ++-- .../java/ml/dmlc/xgboost4j/java/Rabit.java | 14 +- .../ml/dmlc/xgboost4j/java/XgboostJNI.java | 2 +- .../ml/dmlc/xgboost4j/scala/DMatrix.scala | 1 - .../dmlc/xgboost4j/scala/ObjectiveTrait.scala | 7 +- .../ml/dmlc/xgboost4j/scala/XGBoost.scala | 1 + .../xgboost4j/src/native/xgboost4j.cpp | 140 ++++++++-------- jvm-packages/xgboost4j/src/native/xgboost4j.h | 154 +++++++++--------- .../dmlc/xgboost4j/scala/DMatrixSuite.scala | 1 + 15 files changed, 199 insertions(+), 195 deletions(-) diff --git a/jvm-packages/checkstyle-suppressions.xml b/jvm-packages/checkstyle-suppressions.xml index da60508fc..28aed4fab 100644 --- a/jvm-packages/checkstyle-suppressions.xml +++ b/jvm-packages/checkstyle-suppressions.xml @@ -29,5 +29,5 @@ + files="xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostJNI.java"/> diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java index 8da76b08d..fecc5f687 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/CustomObjective.java @@ -19,10 +19,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import ml.dmlc.xgboost4j.java.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import ml.dmlc.xgboost4j.java.*; + /** * an example user define objective and eval * NOTE: when you do customized loss function, the default prediction value is margin diff --git a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java index fdc2c1cd8..89c9bcdb0 100644 --- a/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java +++ b/jvm-packages/xgboost4j-demo/src/main/java/ml/dmlc/xgboost4j/java/demo/DistTrain.java @@ -4,10 +4,10 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -import ml.dmlc.xgboost4j.java.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import ml.dmlc.xgboost4j.java.*; /** * Distributed training example, used to quick test distributed training. diff --git a/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala index 15ecd7308..f4934fc2f 100644 --- a/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala +++ b/jvm-packages/xgboost4j-flink/src/main/scala/ml/dmlc/xgboost4j/flink/Test.scala @@ -16,7 +16,8 @@ package ml.dmlc.xgboost4j.flink -import ml.dmlc.xgboost4j.java.{RabitTracker, Rabit} +import ml.dmlc.xgboost4j.java.{Rabit,RabitTracker} + import ml.dmlc.xgboost4j.scala.Booster import ml.dmlc.xgboost4j.scala.DMatrix import ml.dmlc.xgboost4j.scala.XGBoost @@ -34,7 +35,7 @@ class ScalaMapFunction(workerEnvs: java.util.Map[String, String]) extends RichMapPartitionFunction[LabeledVector, Booster] { val log = LogFactory.getLog(this.getClass) def mapPartition(it : java.lang.Iterable[LabeledVector], collector: Collector[Booster]): Unit = { - workerEnvs.put("DMLC_TASK_ID", this.getRuntimeContext.getTaskName) + workerEnvs.put("DMLC_TASK_ID", String.valueOf(this.getRuntimeContext.getIndexOfThisSubtask)) log.info("start with env" + workerEnvs.toString) Rabit.init(workerEnvs) diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java index d8e1aaf4d..a5a9b4972 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/DMatrix.java @@ -65,7 +65,7 @@ public class DMatrix { logger.info(e.toString()); } long[] out = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromDataIter(iter, cache_info, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixCreateFromDataIter(iter, cache_info, out)); handle = out[0]; } @@ -80,7 +80,7 @@ public class DMatrix { throw new NullPointerException("dataPath: null"); } long[] out = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromFile(dataPath, 1, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixCreateFromFile(dataPath, 1, out)); handle = out[0]; } @@ -95,9 +95,9 @@ public class DMatrix { public DMatrix(long[] headers, int[] indices, float[] data, SparseType st) throws XGBoostError { long[] out = new long[1]; if (st == SparseType.CSR) { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromCSR(headers, indices, data, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixCreateFromCSR(headers, indices, data, out)); } else if (st == SparseType.CSC) { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromCSC(headers, indices, data, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixCreateFromCSC(headers, indices, data, out)); } else { throw new UnknownError("unknow sparsetype"); } @@ -114,7 +114,7 @@ public class DMatrix { */ public DMatrix(float[] data, int nrow, int ncol) throws XGBoostError { long[] out = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixCreateFromMat(data, nrow, ncol, 0.0f, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixCreateFromMat(data, nrow, ncol, 0.0f, out)); handle = out[0]; } @@ -133,7 +133,7 @@ public class DMatrix { * @throws XGBoostError native error */ public void setLabel(float[] labels) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "label", labels)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixSetFloatInfo(handle, "label", labels)); } /** @@ -143,7 +143,7 @@ public class DMatrix { * @throws XGBoostError native error */ public void setWeight(float[] weights) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "weight", weights)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixSetFloatInfo(handle, "weight", weights)); } /** @@ -154,7 +154,7 @@ public class DMatrix { * @throws XGBoostError native error */ public void setBaseMargin(float[] baseMargin) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixSetFloatInfo(handle, "base_margin", baseMargin)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixSetFloatInfo(handle, "base_margin", baseMargin)); } /** @@ -176,18 +176,18 @@ public class DMatrix { * @throws XGBoostError native error */ public void setGroup(int[] group) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixSetGroup(handle, group)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixSetGroup(handle, group)); } private float[] getFloatInfo(String field) throws XGBoostError { float[][] infos = new float[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixGetFloatInfo(handle, field, infos)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixGetFloatInfo(handle, field, infos)); return infos[0]; } private int[] getIntInfo(String field) throws XGBoostError { int[][] infos = new int[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixGetUIntInfo(handle, field, infos)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixGetUIntInfo(handle, field, infos)); return infos[0]; } @@ -230,7 +230,7 @@ public class DMatrix { */ public DMatrix slice(int[] rowIndex) throws XGBoostError { long[] out = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixSliceDMatrix(handle, rowIndex, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixSliceDMatrix(handle, rowIndex, out)); long sHandle = out[0]; DMatrix sMatrix = new DMatrix(sHandle); return sMatrix; @@ -244,7 +244,7 @@ public class DMatrix { */ public long rowNum() throws XGBoostError { long[] rowNum = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGDMatrixNumRow(handle, rowNum)); + JNIErrorHandle.checkCall(XGBoostJNI.XGDMatrixNumRow(handle, rowNum)); return rowNum[0]; } @@ -252,7 +252,7 @@ public class DMatrix { * save DMatrix to filePath */ public void saveBinary(String filePath) { - XgboostJNI.XGDMatrixSaveBinary(handle, filePath, 1); + XGBoostJNI.XGDMatrixSaveBinary(handle, filePath, 1); } /** @@ -285,7 +285,7 @@ public class DMatrix { public synchronized void dispose() { if (handle != 0) { - XgboostJNI.XGDMatrixFree(handle); + XGBoostJNI.XGDMatrixFree(handle); handle = 0; } } diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java index 7bd64c149..bb64ee56f 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JNIErrorHandle.java @@ -45,7 +45,7 @@ class JNIErrorHandle { */ static void checkCall(int ret) throws XGBoostError { if (ret != 0) { - throw new XGBoostError(XgboostJNI.XGBGetLastError()); + throw new XGBoostError(XGBoostJNI.XGBGetLastError()); } } diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java index 7e2ade607..37860dc6f 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/JavaBoosterImpl.java @@ -81,7 +81,7 @@ class JavaBoosterImpl implements Booster { handles = dmatrixsToHandles(dMatrixs); } long[] out = new long[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterCreate(handles, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterCreate(handles, out)); handle = out[0]; } @@ -94,7 +94,7 @@ class JavaBoosterImpl implements Booster { * @throws XGBoostError native error */ public final void setParam(String key, String value) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterSetParam(handle, key, value)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterSetParam(handle, key, value)); } /** @@ -120,7 +120,7 @@ class JavaBoosterImpl implements Booster { * @throws XGBoostError native error */ public void update(DMatrix dtrain, int iter) throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterUpdateOneIter(handle, iter, dtrain.getHandle())); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterUpdateOneIter(handle, iter, dtrain.getHandle())); } /** @@ -149,7 +149,7 @@ class JavaBoosterImpl implements Booster { throw new AssertionError(String.format("grad/hess length mismatch %s / %s", grad.length, hess.length)); } - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterBoostOneIter(handle, dtrain.getHandle(), grad, + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterBoostOneIter(handle, dtrain.getHandle(), grad, hess)); } @@ -165,7 +165,7 @@ class JavaBoosterImpl implements Booster { public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, int iter) throws XGBoostError { long[] handles = dmatrixsToHandles(evalMatrixs); String[] evalInfo = new String[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterEvalOneIter(handle, iter, handles, evalNames, + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterEvalOneIter(handle, iter, handles, evalNames, evalInfo)); return evalInfo[0]; } @@ -211,7 +211,7 @@ class JavaBoosterImpl implements Booster { optionMask = 2; } float[][] rawPredicts = new float[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterPredict(handle, data.getHandle(), optionMask, + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterPredict(handle, data.getHandle(), optionMask, treeLimit, rawPredicts)); int row = (int) data.rowNum(); int col = rawPredicts[0].length / row; @@ -284,11 +284,11 @@ class JavaBoosterImpl implements Booster { * @param modelPath model path */ public void saveModel(String modelPath) throws XGBoostError{ - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterSaveModel(handle, modelPath)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterSaveModel(handle, modelPath)); } private void loadModel(String modelPath) { - XgboostJNI.XGBoosterLoadModel(handle, modelPath); + XGBoostJNI.XGBoosterLoadModel(handle, modelPath); } /** @@ -304,7 +304,7 @@ class JavaBoosterImpl implements Booster { statsFlag = 1; } String[][] modelInfos = new String[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterDumpModel(handle, "", statsFlag, modelInfos)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterDumpModel(handle, "", statsFlag, modelInfos)); return modelInfos[0]; } @@ -322,7 +322,7 @@ class JavaBoosterImpl implements Booster { statsFlag = 1; } String[][] modelInfos = new String[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterDumpModel(handle, featureMap, statsFlag, + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterDumpModel(handle, featureMap, statsFlag, modelInfos)); return modelInfos[0]; } @@ -450,7 +450,7 @@ class JavaBoosterImpl implements Booster { */ public byte[] toByteArray() throws XGBoostError { byte[][] bytes = new byte[1][]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterGetModelRaw(this.handle, bytes)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterGetModelRaw(this.handle, bytes)); return bytes[0]; } @@ -463,7 +463,7 @@ class JavaBoosterImpl implements Booster { */ int loadRabitCheckpoint() throws XGBoostError { int[] out = new int[1]; - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterLoadRabitCheckpoint(this.handle, out)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterLoadRabitCheckpoint(this.handle, out)); return out[0]; } @@ -473,7 +473,7 @@ class JavaBoosterImpl implements Booster { * @throws XGBoostError */ void saveRabitCheckpoint() throws XGBoostError { - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterSaveRabitCheckpoint(this.handle)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterSaveRabitCheckpoint(this.handle)); } /** @@ -504,7 +504,7 @@ class JavaBoosterImpl implements Booster { try { this.init(null); byte[] bytes = (byte[])in.readObject(); - JNIErrorHandle.checkCall(XgboostJNI.XGBoosterLoadModelFromBuffer(this.handle, bytes)); + JNIErrorHandle.checkCall(XGBoostJNI.XGBoosterLoadModelFromBuffer(this.handle, bytes)); } catch (XGBoostError ex) { throw new IOException(ex.toString()); } @@ -518,7 +518,7 @@ class JavaBoosterImpl implements Booster { public synchronized void dispose() { if (handle != 0L) { - XgboostJNI.XGBoosterFree(handle); + XGBoostJNI.XGBoosterFree(handle); handle = 0; } } diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java index ce4be04c5..d8408d26c 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/Rabit.java @@ -23,7 +23,7 @@ public class Rabit { private static void checkCall(int ret) throws XGBoostError { if (ret != 0) { - throw new XGBoostError(XgboostJNI.XGBGetLastError()); + throw new XGBoostError(XGBoostJNI.XGBGetLastError()); } } @@ -38,7 +38,7 @@ public class Rabit { for (java.util.Map.Entry e : envs.entrySet()) { args[idx++] = e.getKey() + '=' + e.getValue(); } - checkCall(XgboostJNI.RabitInit(args)); + checkCall(XGBoostJNI.RabitInit(args)); } /** @@ -46,7 +46,7 @@ public class Rabit { * @throws XGBoostError */ public static void shutdown() throws XGBoostError { - checkCall(XgboostJNI.RabitFinalize()); + checkCall(XGBoostJNI.RabitFinalize()); } /** @@ -55,7 +55,7 @@ public class Rabit { * @throws XGBoostError */ public static void trackerPrint(String msg) throws XGBoostError { - checkCall(XgboostJNI.RabitTrackerPrint(msg)); + checkCall(XGBoostJNI.RabitTrackerPrint(msg)); } /** @@ -66,7 +66,7 @@ public class Rabit { */ public static int versionNumber() throws XGBoostError { int[] out = new int[1]; - checkCall(XgboostJNI.RabitVersionNumber(out)); + checkCall(XGBoostJNI.RabitVersionNumber(out)); return out[0]; } @@ -77,7 +77,7 @@ public class Rabit { */ public static int getRank() throws XGBoostError { int[] out = new int[1]; - checkCall(XgboostJNI.RabitGetRank(out)); + checkCall(XGBoostJNI.RabitGetRank(out)); return out[0]; } @@ -88,7 +88,7 @@ public class Rabit { */ public static int getWorldSize() throws XGBoostError { int[] out = new int[1]; - checkCall(XgboostJNI.RabitGetWorldSize(out)); + checkCall(XGBoostJNI.RabitGetWorldSize(out)); return out[0]; } } diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java index 9f6a15a9c..29ea29163 100644 --- a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java +++ b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java @@ -22,7 +22,7 @@ package ml.dmlc.xgboost4j.java; * * @author hzx */ -class XgboostJNI { +class XGBoostJNI { public final static native String XGBGetLastError(); public final static native int XGDMatrixCreateFromFile(String fname, int silent, long[] out); diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala index 4ee8d04fe..c62784c08 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/DMatrix.scala @@ -21,7 +21,6 @@ import _root_.scala.collection.JavaConverters._ import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix, DataBatch, XGBoostError} class DMatrix private[scala](private[scala] val jDMatrix: JDMatrix) { - /** * init DMatrix from file (svmlight format) * diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala index 1b563f96d..f6d7fd496 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/ObjectiveTrait.scala @@ -16,10 +16,11 @@ package ml.dmlc.xgboost4j.scala -import ml.dmlc.xgboost4j.java -import ml.dmlc.xgboost4j.java.IObjective import scala.collection.JavaConverters._ +import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix} +import ml.dmlc.xgboost4j.java.IObjective + trait ObjectiveTrait extends IObjective { /** * user define objective function, return gradient and second order gradient @@ -30,7 +31,7 @@ trait ObjectiveTrait extends IObjective { */ def getGradient(predicts: Array[Array[Float]], dtrain: DMatrix): List[Array[Float]] - private[scala] def getGradient(predicts: Array[Array[Float]], dtrain: java.DMatrix): + private[scala] def getGradient(predicts: Array[Array[Float]], dtrain: JDMatrix): java.util.List[Array[Float]] = { getGradient(predicts, new DMatrix(dtrain)).asJava } diff --git a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala index 966784d18..58ed51527 100644 --- a/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala +++ b/jvm-packages/xgboost4j/src/main/scala/ml/dmlc/xgboost4j/scala/XGBoost.scala @@ -16,6 +16,7 @@ package ml.dmlc.xgboost4j.scala +import ml.dmlc.xgboost4j.java.{XGBoost => JXGBoost} import scala.collection.JavaConverters._ object XGBoost { diff --git a/jvm-packages/xgboost4j/src/native/xgboost4j.cpp b/jvm-packages/xgboost4j/src/native/xgboost4j.cpp index 1c35c8311..9475bb248 100644 --- a/jvm-packages/xgboost4j/src/native/xgboost4j.cpp +++ b/jvm-packages/xgboost4j/src/native/xgboost4j.cpp @@ -134,11 +134,11 @@ XGB_EXTERN_C int XGBoost4jCallbackDataIterNext( } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBGetLastError * Signature: ()Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBGetLastError +JNIEXPORT jstring JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBGetLastError (JNIEnv *jenv, jclass jcls) { jstring jresult = 0; const char* result = XGBGetLastError(); @@ -149,11 +149,11 @@ JNIEXPORT jstring JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBGetLastError } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromDataIter * Signature: (Ljava/util/Iterator;Ljava/lang/String;[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromDataIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromDataIter (JNIEnv *jenv, jclass jcls, jobject jiter, jstring jcache_info, jlongArray jout) { DMatrixHandle result; const char* cache_info = nullptr; @@ -170,11 +170,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromData } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromFile * Signature: (Ljava/lang/String;I[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromFile +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromFile (JNIEnv *jenv, jclass jcls, jstring jfname, jint jsilent, jlongArray jout) { DMatrixHandle result; const char* fname = jenv->GetStringUTFChars(jfname, 0); @@ -187,11 +187,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromFile } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromCSR * Signature: ([J[J[F)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSR +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromCSR (JNIEnv *jenv, jclass jcls, jlongArray jindptr, jintArray jindices, jfloatArray jdata, jlongArray jout) { DMatrixHandle result; jlong* indptr = jenv->GetLongArrayElements(jindptr, 0); @@ -209,11 +209,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSR } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromCSC * Signature: ([J[J[F)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSC +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromCSC (JNIEnv *jenv, jclass jcls, jlongArray jindptr, jintArray jindices, jfloatArray jdata, jlongArray jout) { DMatrixHandle result; jlong* indptr = jenv->GetLongArrayElements(jindptr, NULL); @@ -233,11 +233,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSC } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromMat * Signature: ([FIIF)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromMat +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromMat (JNIEnv *jenv, jclass jcls, jfloatArray jdata, jint jnrow, jint jncol, jfloat jmiss, jlongArray jout) { DMatrixHandle result; jfloat* data = jenv->GetFloatArrayElements(jdata, 0); @@ -251,11 +251,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromMat } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSliceDMatrix * Signature: (J[I)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSliceDMatrix +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSliceDMatrix (JNIEnv *jenv, jclass jcls, jlong jhandle, jintArray jindexset, jlongArray jout) { DMatrixHandle result; DMatrixHandle handle = (DMatrixHandle) jhandle; @@ -272,11 +272,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSliceDMatrix } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixFree * Signature: (J)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixFree +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixFree (JNIEnv *jenv, jclass jcls, jlong jhandle) { DMatrixHandle handle = (DMatrixHandle) jhandle; int ret = XGDMatrixFree(handle); @@ -284,11 +284,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixFree } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSaveBinary * Signature: (JLjava/lang/String;I)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSaveBinary +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSaveBinary (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfname, jint jsilent) { DMatrixHandle handle = (DMatrixHandle) jhandle; const char* fname = jenv->GetStringUTFChars(jfname, 0); @@ -298,11 +298,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSaveBinary } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetFloatInfo * Signature: (JLjava/lang/String;[F)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetFloatInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetFloatInfo (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfield, jfloatArray jarray) { DMatrixHandle handle = (DMatrixHandle) jhandle; const char* field = jenv->GetStringUTFChars(jfield, 0); @@ -317,11 +317,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetFloatInfo } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetUIntInfo * Signature: (JLjava/lang/String;[I)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetUIntInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetUIntInfo (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfield, jintArray jarray) { DMatrixHandle handle = (DMatrixHandle) jhandle; const char* field = jenv->GetStringUTFChars(jfield, 0); @@ -336,11 +336,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetUIntInfo } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetGroup * Signature: (J[I)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetGroup +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetGroup (JNIEnv * jenv, jclass jcls, jlong jhandle, jintArray jarray) { DMatrixHandle handle = (DMatrixHandle) jhandle; jint* array = jenv->GetIntArrayElements(jarray, NULL); @@ -352,11 +352,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetGroup } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixGetFloatInfo * Signature: (JLjava/lang/String;)[F */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetFloatInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixGetFloatInfo (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfield, jobjectArray jout) { DMatrixHandle handle = (DMatrixHandle) jhandle; const char* field = jenv->GetStringUTFChars(jfield, 0); @@ -374,11 +374,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetFloatInfo } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixGetUIntInfo * Signature: (JLjava/lang/String;)[I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetUIntInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixGetUIntInfo (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfield, jobjectArray jout) { DMatrixHandle handle = (DMatrixHandle) jhandle; const char* field = jenv->GetStringUTFChars(jfield, 0); @@ -395,11 +395,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetUIntInfo } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixNumRow * Signature: (J)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixNumRow +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixNumRow (JNIEnv *jenv, jclass jcls, jlong jhandle, jlongArray jout) { DMatrixHandle handle = (DMatrixHandle) jhandle; bst_ulong result[1]; @@ -409,11 +409,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixNumRow } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterCreate * Signature: ([J)J */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterCreate +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterCreate (JNIEnv *jenv, jclass jcls, jlongArray jhandles, jlongArray jout) { std::vector handles; if (jhandles != nullptr) { @@ -431,11 +431,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterCreate } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterFree * Signature: (J)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterFree +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterFree (JNIEnv *jenv, jclass jcls, jlong jhandle) { BoosterHandle handle = (BoosterHandle) jhandle; return XGBoosterFree(handle); @@ -443,11 +443,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterFree /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSetParam * Signature: (JLjava/lang/String;Ljava/lang/String;)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSetParam +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSetParam (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jname, jstring jvalue) { BoosterHandle handle = (BoosterHandle) jhandle; const char* name = jenv->GetStringUTFChars(jname, 0); @@ -460,11 +460,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSetParam } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterUpdateOneIter * Signature: (JIJ)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterUpdateOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterUpdateOneIter (JNIEnv *jenv, jclass jcls, jlong jhandle, jint jiter, jlong jdtrain) { BoosterHandle handle = (BoosterHandle) jhandle; DMatrixHandle dtrain = (DMatrixHandle) jdtrain; @@ -472,11 +472,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterUpdateOneIter } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterBoostOneIter * Signature: (JJ[F[F)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterBoostOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterBoostOneIter (JNIEnv *jenv, jclass jcls, jlong jhandle, jlong jdtrain, jfloatArray jgrad, jfloatArray jhess) { BoosterHandle handle = (BoosterHandle) jhandle; DMatrixHandle dtrain = (DMatrixHandle) jdtrain; @@ -491,11 +491,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterBoostOneIter } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterEvalOneIter * Signature: (JI[J[Ljava/lang/String;)Ljava/lang/String; */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterEvalOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterEvalOneIter (JNIEnv *jenv, jclass jcls, jlong jhandle, jint jiter, jlongArray jdmats, jobjectArray jevnames, jobjectArray jout) { BoosterHandle handle = (BoosterHandle) jhandle; std::vector dmats; @@ -530,11 +530,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterEvalOneIter } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterPredict * Signature: (JJIJ)[F */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterPredict +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterPredict (JNIEnv *jenv, jclass jcls, jlong jhandle, jlong jdmat, jint joption_mask, jint jntree_limit, jobjectArray jout) { BoosterHandle handle = (BoosterHandle) jhandle; DMatrixHandle dmat = (DMatrixHandle) jdmat; @@ -550,11 +550,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterPredict } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadModel * Signature: (JLjava/lang/String;)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadModel (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfname) { BoosterHandle handle = (BoosterHandle) jhandle; const char* fname = jenv->GetStringUTFChars(jfname, 0); @@ -565,11 +565,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModel } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSaveModel * Signature: (JLjava/lang/String;)V */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSaveModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSaveModel (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfname) { BoosterHandle handle = (BoosterHandle) jhandle; const char* fname = jenv->GetStringUTFChars(jfname, 0); @@ -580,11 +580,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSaveModel } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadModelFromBuffer * Signature: (J[B)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModelFromBuffer +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadModelFromBuffer (JNIEnv *jenv, jclass jcls, jlong jhandle, jbyteArray jbytes) { BoosterHandle handle = (BoosterHandle) jhandle; jbyte* buffer = jenv->GetByteArrayElements(jbytes, 0); @@ -595,11 +595,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModelFromB } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterGetModelRaw * Signature: (J[[B)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterGetModelRaw +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterGetModelRaw (JNIEnv * jenv, jclass jcls, jlong jhandle, jobjectArray jout) { BoosterHandle handle = (BoosterHandle) jhandle; bst_ulong len = 0; @@ -615,11 +615,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterGetModelRaw } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterDumpModel * Signature: (JLjava/lang/String;I)[Ljava/lang/String; */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterDumpModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterDumpModel (JNIEnv *jenv, jclass jcls, jlong jhandle, jstring jfmap, jint jwith_stats, jobjectArray jout) { BoosterHandle handle = (BoosterHandle) jhandle; const char *fmap = jenv->GetStringUTFChars(jfmap, 0); @@ -640,11 +640,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterDumpModel } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadRabitCheckpoint * Signature: (J[I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadRabitCheckpoint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadRabitCheckpoint (JNIEnv *jenv , jclass jcls, jlong jhandle, jintArray jout) { BoosterHandle handle = (BoosterHandle) jhandle; int version; @@ -654,22 +654,22 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadRabitCheck } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSaveRabitCheckpoint * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSaveRabitCheckpoint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSaveRabitCheckpoint (JNIEnv *jenv, jclass jcls, jlong jhandle) { BoosterHandle handle = (BoosterHandle) jhandle; return XGBoosterSaveRabitCheckpoint(handle); } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitInit * Signature: ([Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitInit +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitInit (JNIEnv *jenv, jclass jcls, jobjectArray jargs) { std::vector args; std::vector argv; @@ -691,22 +691,22 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitInit } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitFinalize * Signature: ()I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitFinalize +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitFinalize (JNIEnv *jenv, jclass jcls) { RabitFinalize(); return 0; } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitTrackerPrint * Signature: (Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitTrackerPrint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitTrackerPrint (JNIEnv *jenv, jclass jcls, jstring jmsg) { std::string str(jenv->GetStringUTFChars(jmsg, 0), jenv->GetStringLength(jmsg)); @@ -715,11 +715,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitTrackerPrint } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitGetRank * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetRank +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitGetRank (JNIEnv *jenv, jclass jcls, jintArray jout) { int rank = RabitGetRank(); jenv->SetIntArrayRegion(jout, 0, 1, &rank); @@ -727,11 +727,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetRank } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitGetWorldSize * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetWorldSize +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitGetWorldSize (JNIEnv *jenv, jclass jcls, jintArray jout) { int out = RabitGetWorldSize(); jenv->SetIntArrayRegion(jout, 0, 1, &out); @@ -739,11 +739,11 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetWorldSize } /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitVersionNumber * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitVersionNumber +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitVersionNumber (JNIEnv *jenv, jclass jcls, jintArray jout) { int out = RabitVersionNumber(); jenv->SetIntArrayRegion(jout, 0, 1, &out); diff --git a/jvm-packages/xgboost4j/src/native/xgboost4j.h b/jvm-packages/xgboost4j/src/native/xgboost4j.h index 0a3eeae3a..eb2e0244a 100644 --- a/jvm-packages/xgboost4j/src/native/xgboost4j.h +++ b/jvm-packages/xgboost4j/src/native/xgboost4j.h @@ -1,306 +1,306 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ #include -/* Header for class ml_dmlc_xgboost4j_XgboostJNI */ +/* Header for class ml_dmlc_xgboost4j_java_XGBoostJNI */ -#ifndef _Included_ml_dmlc_xgboost4j_XgboostJNI -#define _Included_ml_dmlc_xgboost4j_XgboostJNI +#ifndef _Included_ml_dmlc_xgboost4j_java_XGBoostJNI +#define _Included_ml_dmlc_xgboost4j_java_XGBoostJNI #ifdef __cplusplus extern "C" { #endif /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBGetLastError * Signature: ()Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBGetLastError +JNIEXPORT jstring JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBGetLastError (JNIEnv *, jclass); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromFile * Signature: (Ljava/lang/String;I[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromFile +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromFile (JNIEnv *, jclass, jstring, jint, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromDataIter * Signature: (Ljava/util/Iterator;Ljava/lang/String;[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromDataIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromDataIter (JNIEnv *, jclass, jobject, jstring, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromCSR * Signature: ([J[I[F[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSR +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromCSR (JNIEnv *, jclass, jlongArray, jintArray, jfloatArray, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromCSC * Signature: ([J[I[F[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromCSC +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromCSC (JNIEnv *, jclass, jlongArray, jintArray, jfloatArray, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixCreateFromMat * Signature: ([FIIF[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixCreateFromMat +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixCreateFromMat (JNIEnv *, jclass, jfloatArray, jint, jint, jfloat, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSliceDMatrix * Signature: (J[I[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSliceDMatrix +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSliceDMatrix (JNIEnv *, jclass, jlong, jintArray, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixFree * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixFree +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixFree (JNIEnv *, jclass, jlong); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSaveBinary * Signature: (JLjava/lang/String;I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSaveBinary +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSaveBinary (JNIEnv *, jclass, jlong, jstring, jint); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetFloatInfo * Signature: (JLjava/lang/String;[F)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetFloatInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetFloatInfo (JNIEnv *, jclass, jlong, jstring, jfloatArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetUIntInfo * Signature: (JLjava/lang/String;[I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetUIntInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetUIntInfo (JNIEnv *, jclass, jlong, jstring, jintArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixSetGroup * Signature: (J[I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixSetGroup +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixSetGroup (JNIEnv *, jclass, jlong, jintArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixGetFloatInfo * Signature: (JLjava/lang/String;[[F)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetFloatInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixGetFloatInfo (JNIEnv *, jclass, jlong, jstring, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixGetUIntInfo * Signature: (JLjava/lang/String;[[I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixGetUIntInfo +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixGetUIntInfo (JNIEnv *, jclass, jlong, jstring, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGDMatrixNumRow * Signature: (J[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGDMatrixNumRow +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGDMatrixNumRow (JNIEnv *, jclass, jlong, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterCreate * Signature: ([J[J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterCreate +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterCreate (JNIEnv *, jclass, jlongArray, jlongArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterFree * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterFree +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterFree (JNIEnv *, jclass, jlong); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSetParam * Signature: (JLjava/lang/String;Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSetParam +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSetParam (JNIEnv *, jclass, jlong, jstring, jstring); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterUpdateOneIter * Signature: (JIJ)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterUpdateOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterUpdateOneIter (JNIEnv *, jclass, jlong, jint, jlong); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterBoostOneIter * Signature: (JJ[F[F)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterBoostOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterBoostOneIter (JNIEnv *, jclass, jlong, jlong, jfloatArray, jfloatArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterEvalOneIter * Signature: (JI[J[Ljava/lang/String;[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterEvalOneIter +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterEvalOneIter (JNIEnv *, jclass, jlong, jint, jlongArray, jobjectArray, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterPredict * Signature: (JJII[[F)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterPredict +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterPredict (JNIEnv *, jclass, jlong, jlong, jint, jint, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadModel * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadModel (JNIEnv *, jclass, jlong, jstring); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSaveModel * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSaveModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSaveModel (JNIEnv *, jclass, jlong, jstring); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadModelFromBuffer * Signature: (J[B)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadModelFromBuffer +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadModelFromBuffer (JNIEnv *, jclass, jlong, jbyteArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterGetModelRaw * Signature: (J[[B)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterGetModelRaw +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterGetModelRaw (JNIEnv *, jclass, jlong, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterDumpModel * Signature: (JLjava/lang/String;I[[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterDumpModel +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterDumpModel (JNIEnv *, jclass, jlong, jstring, jint, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterGetAttr * Signature: (JLjava/lang/String;[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterGetAttr +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterGetAttr (JNIEnv *, jclass, jlong, jstring, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSetAttr * Signature: (JLjava/lang/String;Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSetAttr +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSetAttr (JNIEnv *, jclass, jlong, jstring, jstring); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterLoadRabitCheckpoint * Signature: (J[I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterLoadRabitCheckpoint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterLoadRabitCheckpoint (JNIEnv *, jclass, jlong, jintArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: XGBoosterSaveRabitCheckpoint * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_XGBoosterSaveRabitCheckpoint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_XGBoosterSaveRabitCheckpoint (JNIEnv *, jclass, jlong); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitInit * Signature: ([Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitInit +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitInit (JNIEnv *, jclass, jobjectArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitFinalize * Signature: ()I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitFinalize +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitFinalize (JNIEnv *, jclass); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitTrackerPrint * Signature: (Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitTrackerPrint +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitTrackerPrint (JNIEnv *, jclass, jstring); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitGetRank * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetRank +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitGetRank (JNIEnv *, jclass, jintArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitGetWorldSize * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitGetWorldSize +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitGetWorldSize (JNIEnv *, jclass, jintArray); /* - * Class: ml_dmlc_xgboost4j_XgboostJNI + * Class: ml_dmlc_xgboost4j_java_XGBoostJNI * Method: RabitVersionNumber * Signature: ([I)I */ -JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_XgboostJNI_RabitVersionNumber +JNIEXPORT jint JNICALL Java_ml_dmlc_xgboost4j_java_XGBoostJNI_RabitVersionNumber (JNIEnv *, jclass, jintArray); #ifdef __cplusplus diff --git a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala index cf7494c98..e6646b95b 100644 --- a/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala +++ b/jvm-packages/xgboost4j/src/test/scala/ml/dmlc/xgboost4j/scala/DMatrixSuite.scala @@ -21,6 +21,7 @@ import java.util.Arrays import scala.util.Random import org.scalatest.FunSuite +import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix} class DMatrixSuite extends FunSuite { test("create DMatrix from File") { From bb43177eb1f8dc59899c4052d4a748f9f5a7317f Mon Sep 17 00:00:00 2001 From: CodingCat Date: Sat, 5 Mar 2016 13:44:55 -0500 Subject: [PATCH 7/7] merge --- jvm-packages/checkstyle-suppressions.xml | 2 +- .../scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala | 2 +- .../main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala | 6 ++++-- .../scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala | 2 +- .../xgboost4j/java/{XgboostJNI.java => XGBoostJNI.java} | 0 5 files changed, 7 insertions(+), 5 deletions(-) rename jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/{XgboostJNI.java => XGBoostJNI.java} (100%) diff --git a/jvm-packages/checkstyle-suppressions.xml b/jvm-packages/checkstyle-suppressions.xml index 28aed4fab..4a0f9ab33 100644 --- a/jvm-packages/checkstyle-suppressions.xml +++ b/jvm-packages/checkstyle-suppressions.xml @@ -29,5 +29,5 @@ +files="xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostJNI.java"/> diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala index fd336a9c2..4ad951567 100644 --- a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/DataUtils.scala @@ -21,7 +21,7 @@ import java.util.{Iterator => JIterator} import scala.collection.mutable.ListBuffer import scala.collection.JavaConverters._ -import ml.dmlc.xgboost4j.DataBatch +import ml.dmlc.xgboost4j.java.DataBatch import org.apache.spark.mllib.linalg.{SparseVector, DenseVector, Vector} import org.apache.spark.mllib.regression.LabeledPoint diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala index 96a6210a7..8151e6ccc 100644 --- a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala @@ -20,7 +20,7 @@ import scala.collection.immutable.HashMap import scala.collection.JavaConverters._ import com.typesafe.config.Config -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix} +import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix} import ml.dmlc.xgboost4j.scala.{XGBoost => SXGBoost, _} import org.apache.spark.SparkContext import org.apache.spark.mllib.regression.LabeledPoint @@ -48,7 +48,9 @@ object XGBoost { val dataBatches = dataUtilsBroadcast.value.fromLabeledPointsToSparseMatrix(trainingSamples) val dMatrix = new DMatrix(new JDMatrix(dataBatches, null)) Iterator(SXGBoost.train(xgBoostConfigMap, dMatrix, round, watches = null, obj, eval)) - } + }.cache() + // force the job + sc.runJob(boosters, (boosters: Iterator[Booster]) => boosters) // TODO: how to choose best model boosters.first() } diff --git a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala index 849ad6168..47efb053f 100644 --- a/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala +++ b/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoostModel.scala @@ -18,7 +18,7 @@ package ml.dmlc.xgboost4j.scala.spark import scala.collection.JavaConverters._ -import ml.dmlc.xgboost4j.{DMatrix => JDMatrix} +import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix} import ml.dmlc.xgboost4j.scala.{DMatrix, Booster} import org.apache.spark.mllib.regression.LabeledPoint import org.apache.spark.rdd.RDD diff --git a/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java b/jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostJNI.java similarity index 100% rename from jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XgboostJNI.java rename to jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/XGBoostJNI.java