Package com.imsl.datamining
Class LogisticRegressionModelObject
java.lang.Object
com.imsl.datamining.LogisticRegressionModelObject
- All Implemented Interfaces:
Serializable
Predicts a data set using a previously trained logistic regression model
object.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a LogisticRegressionModelObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidAggregates or combines a different model object to this logistic regression model object.double[]Returns the coefficients.double[][]Returns the Hessian matrix.doubleReturns the log-likeliood.intReturns the number of classes.intReturns the number of coefficients (per class).Returns the variable type of the response variable.double[]Returns the standard errors of the coefficients.double[]predict(double[][] testData) Returns the predictions on the test data.double[]predict(double[][] testData, double[] testDataWeights) Returns predictions on the given test data based on the given weights.
-
Constructor Details
-
LogisticRegressionModelObject
Constructs a LogisticRegressionModelObject.- Parameters:
lrm- a previously trainedLogisticRegressionmodel
-
-
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). It is the user's responsibility to ensure the model object and the test data are compatible. Otherwise, errors or unexpected results will occur.- Returns:
- a
doublearray containing the predictions - Throws:
PredictiveModel.PredictiveModelException
-
predict
public double[] predict(double[][] testData, double[] testDataWeights) throws PredictiveModel.PredictiveModelException Returns predictions on the given test data based on the given weights.- Parameters:
testData- adoublematrix containing the test data predictors. It must be compatible with the original training data (it must have the same variable types and column orders). It is the user's responsibility to ensure the model object and the test data are compatible. Otherwise, errors or unexpected results will occur.testDataWeights- adoublearray containing the test data weights. For the binomial/multinomial response the weights are typically the frequencies, or number of trials. They must be non-negative.- Returns:
- a
doublearray containing predicted outcomes - Throws:
PredictiveModel.PredictiveModelException
-
aggregateModels
Aggregates or combines a different model object to this logistic regression model object.It is assumed that the objects have the same structure and are models of the same data problem. The result approximates the model that would result if a LogisticRegression model was trained on all the data. The approximation follows the method presented in Xi, Lin, and Chen (2008).
To illustrate, let \(\beta_1\) and \(\beta_2\) be the MLE’s from separate fits to two different sets of data, and let \(\matrix{H}_1\) and \( \matrix{H}_2\) be the associated Hessian matrices. Then $$\beta = (\matrix{H_1} + \matrix{H_2})^{-1}(\matrix{H_1}\beta_1 + \matrix{H_2}\beta_2) $$ approximates the MLE of the combined data set.
The method replaces the coefficients, standard errors, and Hessian matrix with the aggregated estimates.
- Parameters:
lrm- aLogisticRegressionModelObject- Throws:
SingularMatrixException
-
getCoefficients
public double[] getCoefficients()Returns the coefficients.- Returns:
- a
doublearray containing the coefficient estimates
-
getStandardErrors
public double[] getStandardErrors()Returns the standard errors of the coefficients.- Returns:
- a
doublearray containing the standard errors
-
getHessian
public double[][] getHessian()Returns the Hessian matrix.- Returns:
- a
doublematrix containing the Hessian matrix
-
getLoglikelihood
public double getLoglikelihood()Returns the log-likeliood.- Returns:
- a
double, the log-likelihood of the model
-
getNumberOfClasses
public int getNumberOfClasses()Returns the number of classes.- Returns:
- an
int, the number of classes
-
getNumberOfCoefficients
public int getNumberOfCoefficients()Returns the number of coefficients (per class).- Returns:
- an
int, the number of coefficients
-
getResponseVariableType
Returns the variable type of the response variable.- Returns:
- the
VariableTypeof the response variable
-