Class Predictor

  • All Implemented Interfaces:
    java.io.Serializable

    public class Predictor
    extends java.lang.Object
    implements java.io.Serializable
    Predicts using the Xgboost model.
    See Also:
    Serialized Form
    • Constructor Detail

      • Predictor

        public Predictor​(java.io.InputStream in)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • Predictor

        public Predictor​(java.io.InputStream in,
                         PredictorConfiguration configuration)
                  throws java.io.IOException
        Instantiates with the Xgboost model
        Parameters:
        in - input stream
        configuration - configuration
        Throws:
        java.io.IOException - If an I/O error occurs
    • Method Detail

      • readParam

        void readParam​(ModelReader reader)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • initObjGbm

        void initObjGbm()
      • 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 vector
        output_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 vector
        output_margin - whether to only predict margin value instead of transformed prediction
        ntree_limit - limit the number of trees used in prediction
        Returns:
        prediction values
      • predictRaw

        float[] predictRaw​(FVec feat,
                           int ntree_limit)
      • 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 vector
        output_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 vector
        output_margin - whether to only predict margin value instead of transformed prediction
        ntree_limit - limit the number of trees used in prediction
        Returns:
        prediction value
      • predictSingleRaw

        float predictSingleRaw​(FVec feat,
                               int ntree_limit)
      • 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 vector
        ntree_limit - limit
        Returns:
        leaf indexes
      • getNumClass

        public int getNumClass()
        Returns number of class.
        Returns:
        number of class