Class GradientBoostingModelObject

java.lang.Object
com.imsl.datamining.GradientBoostingModelObject
All Implemented Interfaces:
Serializable

public class GradientBoostingModelObject extends Object implements Serializable
Predicts a data set using a trained gradient boosting model.

This class extracts the decision trees and other necessary parameters from a trained gradient boosting model for the purpose of predicting a new data set separately from the original training data.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs the GradientBoostingModelObject.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[][]
    Returns the predictor function values \(\{f(x_i)\}\) on the test data for a categorical (binomial or multinomial) response variable.
    double[][]
    Returns the predicted probabilities on the test data for a categorical response variable.
    double[]
    Returns the predictor function values \(\{f(x_i)\}\) for a continuous response variable on the test data.
    int
    Returns the current print level.
    double
    Returns the value of the loss function on the test data.
    double[]
    predict(double[][] testData)
    Returns the predictions on the test data.
    double[]
    predict(double[][] testData, double[] testDataWeights)
    Returns the predictions on the test data using data weights.
    void
    setMissingTestYFlag(boolean missingTestY)
    Sets the flag for whether or not the test data has missing response values.
    void
    setPrintLevel(int printLevel)
    Sets the print level.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GradientBoostingModelObject

      public GradientBoostingModelObject(GradientBoosting gbm)
      Constructs the GradientBoostingModelObject.
      Parameters:
      gbm - a previously trained GradientBoosting model
  • Method Details

    • predict

      public double[] predict(double[][] testData) throws PredictiveModel.PredictiveModelException
      Returns the predictions on the test data.
      Parameters:
      testData - a double matrix containing the data. It must be compatible with the original training data (it must have the same variable types and column orders).
      Returns:
      a double array containing the predictions
      Throws:
      PredictiveModel.PredictiveModelException
    • predict

      public double[] predict(double[][] testData, double[] testDataWeights) throws PredictiveModel.PredictiveModelException
      Returns the predictions on the test data using data weights.
      Parameters:
      testData - a double matrix containing the data. It must be compatible with the original training data (it must have the same variable types and column orders).
      testDataWeights - a double array containing weights for each row of testData. The weights must be non-negative.
      Returns:
      a double array containing the predictions
      Throws:
      PredictiveModel.PredictiveModelException
    • getTestLossValue

      public double getTestLossValue()
      Returns the value of the loss function on the test data.

      The result will be NaN if the test data response variable is missing (the default).

      Returns:
      a double, the value of the loss function.
    • getClassPredictorValues

      public double[][] getClassPredictorValues()
      Returns the predictor function values \(\{f(x_i)\}\) on the test data for a categorical (binomial or multinomial) response variable.
      Returns:
      a double matrix containing the predictor function values
    • getContinuousPredictorValues

      public double[] getContinuousPredictorValues()
      Returns the predictor function values \(\{f(x_i)\}\) for a continuous response variable on the test data.
      Returns:
      a double array containing the predictor function values
    • getClassProbabilities

      public double[][] getClassProbabilities()
      Returns the predicted probabilities on the test data for a categorical response variable.
      Returns:
      a double matrix containing the class probabilities on the test data. The i,k-th element of the matrix is the estimated probability that the observation at row index i belongs to the k+1-st class, where k=0,..., nClasses-1.
    • setMissingTestYFlag

      public void setMissingTestYFlag(boolean missingTestY)
      Sets the flag for whether or not the test data has missing response values. The default is true (the methods will assume the response values are not present). If the response variable is not missing, the value of the loss function on the test data can be calculated.
      Parameters:
      missingTestY - a boolean indicating whether or not the test data response variable is missing
    • getPrintLevel

      public int getPrintLevel()
      Returns the current print level.
      Returns:
      an int, the current print level
    • setPrintLevel

      public void setPrintLevel(int printLevel)
      Sets the print level.

      When printLevel>0 and the response values are non-missing, the loss function values for each iteration are printed. The default is printLevel=0.

      Parameters:
      printLevel - an int specifying the print level