Class LogisticRegressionModelObject

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

public class LogisticRegressionModelObject extends Object implements Serializable
Predicts a data set using a previously trained logistic regression model object.
See Also:
  • Constructor Details

    • LogisticRegressionModelObject

      public LogisticRegressionModelObject(LogisticRegression lrm)
      Constructs a LogisticRegressionModelObject.
      Parameters:
      lrm - a previously trained LogisticRegression 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). 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 double array 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 - 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.
      Returns:
      a double array containing predicted outcomes
      Throws:
      PredictiveModel.PredictiveModelException
    • aggregateModels

      public void aggregateModels(LogisticRegressionModelObject lrm) throws SingularMatrixException
      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 - a LogisticRegressionModelObject
      Throws:
      SingularMatrixException
    • getCoefficients

      public double[] getCoefficients()
      Returns the coefficients.
      Returns:
      a double array containing the coefficient estimates
    • getStandardErrors

      public double[] getStandardErrors()
      Returns the standard errors of the coefficients.
      Returns:
      a double array containing the standard errors
    • getHessian

      public double[][] getHessian()
      Returns the Hessian matrix.
      Returns:
      a double matrix 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

      public PredictiveModel.VariableType getResponseVariableType()
      Returns the variable type of the response variable.
      Returns:
      the VariableType of the response variable