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

@@ -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;
}
}