Merge pull request #918 from tqchen/master
Add Labeled Point, minor fix build
This commit is contained in:
commit
ae032b12b4
@ -20,6 +20,7 @@
|
||||
<modules>
|
||||
<module>xgboost4j</module>
|
||||
<module>xgboost4j-demo</module>
|
||||
<module>xgboost4j-flink</module>
|
||||
<module>xgboost4j-spark</module>
|
||||
</modules>
|
||||
<build>
|
||||
|
||||
@ -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,22 +24,22 @@
|
||||
</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>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<artifactId>xgboostjvm</artifactId>
|
||||
<version>0.1</version>
|
||||
</parent>
|
||||
<artifactId>xgboost4jspark</artifactId>
|
||||
<artifactId>xgboost4j-spark</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user