Add Labeled Point, minor fix build

This commit is contained in:
tqchen 2016-03-05 12:12:43 -08:00
parent 51d8595372
commit ac8e950227
5 changed files with 55 additions and 10 deletions

View File

@ -20,6 +20,7 @@
<modules>
<module>xgboost4j</module>
<module>xgboost4j-demo</module>
<module>xgboost4j-flink</module>
<module>xgboost4j-spark</module>
</modules>
<build>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.dmlc</groupId>
<groupId>ml.dmlc</groupId>
<artifactId>xgboostjvm</artifactId>
<version>0.1</version>
</parent>
@ -13,7 +13,7 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.dmlc</groupId>
<groupId>ml.dmlc</groupId>
<artifactId>xgboost4j</artifactId>
<version>0.1</version>
</dependency>
@ -24,24 +24,24 @@
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java_2.11</artifactId>
<artifactId>flink-java</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_2.11</artifactId>
<artifactId>flink-scala</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
<artifactId>flink-clients</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-ml_2.11</artifactId>
<artifactId>flink-ml</artifactId>
<version>0.10.2</version>
</dependency>
</dependencies>
</project>
</project>

View File

@ -16,8 +16,7 @@
package ml.dmlc.xgboost4j.flink
import ml.dmlc.xgboost4j.java.{Rabit,RabitTracker}
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

View File

@ -8,7 +8,7 @@
<artifactId>xgboostjvm</artifactId>
<version>0.1</version>
</parent>
<artifactId>xgboost4jspark</artifactId>
<artifactId>xgboost4j-spark</artifactId>
<build>
<plugins>
<plugin>

View File

@ -0,0 +1,45 @@
package ml.dmlc.xgboost4j;
/**
* Labeled data point for training examples.
* Represent a sparse training instance.
*/
public class LabeledPoint {
/** Label of the point */
float label;
/** Weight of this data point */
float weight = 1.0f;
/** Feature indices, used for sparse input */
int[] indices = null;
/** Feature values */
float[] values;
private LabeledPoint() {}
/**
* Create Labeled data point from sparse vector.
* @param label The label of the data point.
* @param indices The indices
* @param values The values.
*/
public static LabeledPoint fromSparseVector(float label, int[] indices, float[] values) {
LabeledPoint ret = new LabeledPoint();
ret.label = label;
ret.indices = indices;
ret.values = values;
return ret;
}
/**
* Create Labeled data point from dense vector.
* @param label The label of the data point.
* @param values The values.
*/
public static LabeledPoint fromDenseVector(float label, float[] values) {
LabeledPoint ret = new LabeledPoint();
ret.label = label;
ret.indices = null;
ret.values = values;
return ret;
}
}