All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.functions.Logistic

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.functions.Logistic

public class Logistic
extends DistributionClassifier
implements OptionHandler, WeightedInstancesHandler
Second implementation for building and using a multinomial logistic regression model with a ridge estimator.

There are some modifications, however, compared to the paper of le Cessie and van Houwelingen(1992):
If there are k classes for n instances with m attributes, the parameter matrix B to be calculated will be an m*(k-1) matrix.
The probability for class j except the last class is
Pj(Xi) = exp(XiBj)/((sum[j=1..(k-1)]exp(Xi*Bj))+1)
The last class has probability
1-(sum[j=1..(k-1)]Pj(Xi)) = 1/((sum[j=1..(k-1)]exp(Xi*Bj))+1)
The (negative) multinomial log-likelihood is thus:
L = -sum[i=1..n]{ sum[j=1..(k-1)](Yij * ln(Pj(Xi))) + (1 - (sum[j=1..(k-1)]Yij)) * ln(1 - sum[j=1..(k-1)]Pj(Xi)) } + ridge * (B^2)
In order to find the matrix B for which L is minimised, a Quasi-Newton Method is used to search for the optimized values of the m*(k-1) variables. Note that before we use the optimization procedure, we "squeeze" the matrix B into a m*(k-1) vector. For details of the optimization procedure, please check weka.core.Optimization class.

Although original Logistic Regression does not deal with instance weights, we modify the algorithm a little bit to handle the instance weights.

Reference: le Cessie, S. and van Houwelingen, J.C. (1992). Ridge Estimators in Logistic Regression. Applied Statistics, Vol. 41, No. 1, pp. 191-201.

Missing values are replaced using a ReplaceMissingValuesFilter, and nominal attributes are transformed into numeric attributes using a NominalToBinaryFilter.

Valid options are:

-D
Turn on debugging output.

-R
Set the ridge parameter for the log-likelihood.

-M
Set the maximum number of iterations (default -1, iterates until convergence).

Version:
$Revision: 1.26 $
Author:
Xin Xu (xx5@cs.waikato.ac.nz)

Constructor Index

 o Logistic()
 

Method Index

 o buildClassifier(Instances)
Builds the classifier
 o distributionForInstance(Instance)
Computes the distribution for a given instance
 o getDebug()
Gets whether debugging output will be printed.
 o getMaxIts()
Get the value of MaxIts.
 o getOptions()
Gets the current settings of the classifier.
 o getRidge()
Gets the ridge in the log-likelihood.
 o listOptions()
Returns an enumeration describing the available options
 o main(String[])
Main method for testing this class.
 o setDebug(boolean)
Sets whether debugging output will be printed.
 o setMaxIts(int)
Set the value of MaxIts.
 o setOptions(String[])
Parses a given list of options.
 o setRidge(double)
Sets the ridge in the log-likelihood.
 o toString()
Gets a string describing the classifier.

Constructor Detail

 o Logistic
public Logistic()

Method Detail

 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options. Valid options are:

-D
Turn on debugging output.

-R ridge
Set the ridge parameter for the log-likelihood.

-M num
Set the maximum number of iterations. (default -1, until convergence)

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the classifier.
Returns:
an array of strings suitable for passing to setOptions
 o setDebug
public void setDebug(boolean debug)
          Sets whether debugging output will be printed.
Parameters:
debug - true if debugging output should be printed
 o getDebug
public boolean getDebug()
          Gets whether debugging output will be printed.
Returns:
true if debugging output will be printed
 o setRidge
public void setRidge(double ridge)
          Sets the ridge in the log-likelihood.
Parameters:
ridge - the ridge
 o getRidge
public double getRidge()
          Gets the ridge in the log-likelihood.
Returns:
the ridge
 o getMaxIts
public int getMaxIts()
          Get the value of MaxIts.
Returns:
Value of MaxIts.
 o setMaxIts
public void setMaxIts(int newMaxIts)
          Set the value of MaxIts.
Parameters:
newMaxIts - Value to assign to MaxIts.
 o buildClassifier
public void buildClassifier(Instances train) throws java.lang.Exception
          Builds the classifier
Parameters:
train - the training data to be used for generating the boosted classifier.
Throws:
java.lang.Exception - if the classifier could not be built successfully
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
          Computes the distribution for a given instance
Parameters:
instance - the instance for which distribution is computed
Returns:
the distribution
Throws:
java.lang.Exception - if the distribution can't be computed successfully
Overrides:
distributionForInstance in class DistributionClassifier
 o toString
public java.lang.String toString()
          Gets a string describing the classifier.
Returns:
a string describing the classifer built.
Overrides:
toString in class java.lang.Object
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - should contain the command line arguments to the scheme (see Evaluation)

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home