public class LogisticRegressionModelObject extends Object implements Serializable
| Constructor and Description |
|---|
LogisticRegressionModelObject(LogisticRegression lrm)
Constructs a LogisticRegressionModelObject.
|
| Modifier and Type | Method and Description |
|---|---|
void |
aggregateModels(LogisticRegressionModelObject lrm)
Aggregates or combines a different model object to this logistic
regression model object.
|
double[] |
getCoefficients()
Returns the coefficients.
|
double[][] |
getHessian()
Returns the Hessian matrix.
|
double |
getLoglikelihood()
Returns the log-likeliood.
|
int |
getNumberOfClasses()
Returns the number of classes.
|
int |
getNumberOfCoefficients()
Returns the number of coefficients (per class).
|
PredictiveModel.VariableType |
getResponseVariableType()
Returns the variable type of the response variable.
|
double[] |
getStandardErrors()
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.
|
public LogisticRegressionModelObject(LogisticRegression lrm)
lrm - a previously trained LogisticRegression modelpublic double[] predict(double[][] testData)
throws PredictiveModel.PredictiveModelException
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). It is the user's responsibility to
ensure the model object and the test data are compatible. Otherwise,
errors or unexpected results will occur.double array containing the predictionsPredictiveModel.PredictiveModelExceptionpublic double[] predict(double[][] testData,
double[] testDataWeights)
throws PredictiveModel.PredictiveModelException
testData - a double matrix 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 - a double array 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.double array containing predicted outcomesPredictiveModel.PredictiveModelExceptionpublic void aggregateModels(LogisticRegressionModelObject lrm) throws SingularMatrixException
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.
lrm - a LogisticRegressionModelObjectSingularMatrixExceptionpublic double[] getCoefficients()
double array containing the coefficient estimatespublic double[] getStandardErrors()
double array containing the standard errorspublic double[][] getHessian()
double matrix containing the Hessian matrixpublic double getLoglikelihood()
double, the log-likelihood of the modelpublic int getNumberOfClasses()
int, the number of classespublic int getNumberOfCoefficients()
int, the number of coefficientspublic PredictiveModel.VariableType getResponseVariableType()
VariableType of the response variableCopyright © 2022 Rogue Wave Software. All rights reserved.