Package biz.k11i.xgboost
Class Predictor
- java.lang.Object
-
- biz.k11i.xgboost.Predictor
-
- All Implemented Interfaces:
Serializable
public class Predictor extends Object implements Serializable
Predicts using the Xgboost model.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Predictor(InputStream in)
Predictor(InputStream in, PredictorConfiguration configuration)
Instantiates with the Xgboost model
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNumClass()
Returns number of class.SparkModelParam
getSparkModelParam()
float[]
predict(FVec feat)
Generates predictions for given feature vector.float[]
predict(FVec feat, boolean output_margin)
Generates predictions for given feature vector.float[]
predict(FVec feat, boolean output_margin, int ntree_limit)
Generates predictions for given feature vector.int[]
predictLeaf(FVec feat)
Predicts leaf index of each tree.int[]
predictLeaf(FVec feat, int ntree_limit)
Predicts leaf index of each tree.float
predictSingle(FVec feat)
Generates a prediction for given feature vector.float
predictSingle(FVec feat, boolean output_margin)
Generates a prediction for given feature vector.float
predictSingle(FVec feat, boolean output_margin, int ntree_limit)
Generates a prediction for given feature vector.
-
-
-
Constructor Detail
-
Predictor
public Predictor(InputStream in) throws IOException
- Throws:
IOException
-
Predictor
public Predictor(InputStream in, PredictorConfiguration configuration) throws IOException
Instantiates with the Xgboost model- Parameters:
in
- input streamconfiguration
- configuration- Throws:
IOException
- If an I/O error occurs
-
-
Method Detail
-
predict
public float[] predict(FVec feat)
Generates predictions for given feature vector.- Parameters:
feat
- feature vector- Returns:
- prediction values
-
predict
public float[] predict(FVec feat, boolean output_margin)
Generates predictions for given feature vector.- Parameters:
feat
- feature vectoroutput_margin
- whether to only predict margin value instead of transformed prediction- Returns:
- prediction values
-
predict
public float[] predict(FVec feat, boolean output_margin, int ntree_limit)
Generates predictions for given feature vector.- Parameters:
feat
- feature vectoroutput_margin
- whether to only predict margin value instead of transformed predictionntree_limit
- limit the number of trees used in prediction- Returns:
- prediction values
-
predictSingle
public float predictSingle(FVec feat)
Generates a prediction for given feature vector.This method only works when the model outputs single value.
- Parameters:
feat
- feature vector- Returns:
- prediction value
-
predictSingle
public float predictSingle(FVec feat, boolean output_margin)
Generates a prediction for given feature vector.This method only works when the model outputs single value.
- Parameters:
feat
- feature vectoroutput_margin
- whether to only predict margin value instead of transformed prediction- Returns:
- prediction value
-
predictSingle
public float predictSingle(FVec feat, boolean output_margin, int ntree_limit)
Generates a prediction for given feature vector.This method only works when the model outputs single value.
- Parameters:
feat
- feature vectoroutput_margin
- whether to only predict margin value instead of transformed predictionntree_limit
- limit the number of trees used in prediction- Returns:
- prediction value
-
predictLeaf
public int[] predictLeaf(FVec feat)
Predicts leaf index of each tree.- Parameters:
feat
- feature vector- Returns:
- leaf indexes
-
predictLeaf
public int[] predictLeaf(FVec feat, int ntree_limit)
Predicts leaf index of each tree.- Parameters:
feat
- feature vectorntree_limit
- limit- Returns:
- leaf indexes
-
getSparkModelParam
public SparkModelParam getSparkModelParam()
-
getNumClass
public int getNumClass()
Returns number of class.- Returns:
- number of class
-
-