Add Labeled Point, minor fix build
This commit is contained in:
parent
51d8595372
commit
ac8e950227
@ -20,6 +20,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>xgboost4j</module>
|
<module>xgboost4j</module>
|
||||||
<module>xgboost4j-demo</module>
|
<module>xgboost4j-demo</module>
|
||||||
|
<module>xgboost4j-flink</module>
|
||||||
<module>xgboost4j-spark</module>
|
<module>xgboost4j-spark</module>
|
||||||
</modules>
|
</modules>
|
||||||
<build>
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboostjvm</artifactId>
|
<artifactId>xgboostjvm</artifactId>
|
||||||
<version>0.1</version>
|
<version>0.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j</artifactId>
|
<artifactId>xgboost4j</artifactId>
|
||||||
<version>0.1</version>
|
<version>0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -24,22 +24,22 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.flink</groupId>
|
<groupId>org.apache.flink</groupId>
|
||||||
<artifactId>flink-java_2.11</artifactId>
|
<artifactId>flink-java</artifactId>
|
||||||
<version>0.10.2</version>
|
<version>0.10.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.flink</groupId>
|
<groupId>org.apache.flink</groupId>
|
||||||
<artifactId>flink-scala_2.11</artifactId>
|
<artifactId>flink-scala</artifactId>
|
||||||
<version>0.10.2</version>
|
<version>0.10.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.flink</groupId>
|
<groupId>org.apache.flink</groupId>
|
||||||
<artifactId>flink-clients_2.11</artifactId>
|
<artifactId>flink-clients</artifactId>
|
||||||
<version>0.10.2</version>
|
<version>0.10.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.flink</groupId>
|
<groupId>org.apache.flink</groupId>
|
||||||
<artifactId>flink-ml_2.11</artifactId>
|
<artifactId>flink-ml</artifactId>
|
||||||
<version>0.10.2</version>
|
<version>0.10.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
package ml.dmlc.xgboost4j.flink
|
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.Booster
|
||||||
import ml.dmlc.xgboost4j.scala.DMatrix
|
import ml.dmlc.xgboost4j.scala.DMatrix
|
||||||
import ml.dmlc.xgboost4j.scala.XGBoost
|
import ml.dmlc.xgboost4j.scala.XGBoost
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<artifactId>xgboostjvm</artifactId>
|
<artifactId>xgboostjvm</artifactId>
|
||||||
<version>0.1</version>
|
<version>0.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4jspark</artifactId>
|
<artifactId>xgboost4j-spark</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<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