Package com.imsl.datamining
Class GradientBoostingModelObject
java.lang.Object
com.imsl.datamining.GradientBoostingModelObject
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionConstructs the GradientBoostingModelObject. -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]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.intReturns the current print level.doubleReturns 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.voidsetMissingTestYFlag(boolean missingTestY) Sets the flag for whether or not the test data has missing response values.voidsetPrintLevel(int printLevel) Sets the print level.
-
Constructor Details
-
GradientBoostingModelObject
Constructs the GradientBoostingModelObject.- Parameters:
gbm- a previously trainedGradientBoostingmodel
-
-
Method Details
-
predict
Returns the predictions on the test data.- Parameters:
testData- adoublematrix containing the data. It must be compatible with the original training data (it must have the same variable types and column orders).- Returns:
- a
doublearray 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- adoublematrix containing the data. It must be compatible with the original training data (it must have the same variable types and column orders).testDataWeights- adoublearray containing weights for each row oftestData. The weights must be non-negative.- Returns:
- a
doublearray 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
NaNif 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
doublematrix 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
doublearray containing the predictor function values
-
getClassProbabilities
public double[][] getClassProbabilities()Returns the predicted probabilities on the test data for a categorical response variable.- Returns:
- a
doublematrix 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 istrue(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- abooleanindicating 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>0and the response values are non-missing, the loss function values for each iteration are printed. The default isprintLevel=0.- Parameters:
printLevel- anintspecifying the print level
-