weka.classifiers.functions
Class SimpleLogistic

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.functions.SimpleLogistic
All Implemented Interfaces:
AdditionalMeasureProducer, java.lang.Cloneable, OptionHandler, java.io.Serializable, WeightedInstancesHandler

public class SimpleLogistic
extends Classifier
implements OptionHandler, AdditionalMeasureProducer, WeightedInstancesHandler

Class for building a logistic regression model using LogitBoost. Incorporates attribute selection by fitting simple regression functions in LogitBoost. For more information, see master thesis "Logistic Model Trees" (Niels Landwehr, 2003)

Valid options are:

-I iterations
Set fixed number of iterations for LogitBoost (instead of using cross-validation).

-S
Select the number of LogitBoost iterations that gives minimal error on the training set (instead of using cross-validation).

-P
Minimize error on probabilities instead of misclassification error.

-M iterations
Set maximum number of iterations for LogitBoost.

-H iter
Set parameter for heuristic for early stopping of LogitBoost. If enabled, the minimum is selected greedily, stopping if the current minimum has not changed for iter iterations. By default, heuristic is enabled with value 50. Set to zero to disable heuristic.

Version:
$Revision: 1.4 $
Author:
Niels Landwehr
See Also:
Serialized Form

Field Summary
protected  LogisticBase m_boostedModel
          The actual logistic regression model
protected  boolean m_errorOnProbabilities
          If true, use minimize error on probabilities instead of misclassification error
protected  int m_heuristicStop
          Parameter for the heuristic for early stopping of LogitBoost
protected  int m_maxBoostingIterations
          Maximum number of iterations for LogitBoost
protected  NominalToBinary m_NominalToBinary
          Filter for converting nominal attributes to binary ones
protected  int m_numBoostingIterations
          If non-negative, use this as fixed number of LogitBoost iterations
protected  ReplaceMissingValues m_ReplaceMissingValues
          Filter for replacing missing values
protected  boolean m_useCrossValidation
          If true, cross-validate number of LogitBoost iterations
 
Fields inherited from class weka.classifiers.Classifier
m_Debug
 
Constructor Summary
SimpleLogistic()
          Constructor for creating SimpleLogistic object with standard options.
SimpleLogistic(int numBoostingIterations, boolean useCrossValidation, boolean errorOnProbabilities)
          Constructor for creating SimpleLogistic object.
 
Method Summary
 void buildClassifier(Instances data)
          Builds the logistic regression using LogitBoost.
 double[] distributionForInstance(Instance inst)
          Returns class probabilities for an instance.
 java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 java.lang.String errorOnProbabilitiesTipText()
          Returns the tip text for this property
 boolean getErrorOnProbabilities()
          Get the value of errorOnProbabilities.
 int getHeuristicStop()
          Get the value of heuristicStop.
 int getMaxBoostingIterations()
          Get the value of maxBoostingIterations.
 double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure
 int getNumBoostingIterations()
          Get the value of numBoostingIterations.
 int getNumRegressions()
          Get the number of LogitBoost iterations performed (= the number of regression functions fit by LogitBoost).
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 boolean getUseCrossValidation()
          Get the value of useCrossValidation.
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.lang.String heuristicStopTipText()
          Returns the tip text for this property
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] argv)
          Main method for testing this class
 java.lang.String maxBoostingIterationsTipText()
          Returns the tip text for this property
 double measureAttributesUsed()
          Returns the fraction of all attributes in the data that are used in the logistic model (in percent).
 java.lang.String numBoostingIterationsTipText()
          Returns the tip text for this property
 void setErrorOnProbabilities(boolean l)
          Set the value of errorOnProbabilities.
 void setHeuristicStop(int n)
          Set the value of heuristicStop.
 void setMaxBoostingIterations(int n)
          Set the value of maxBoostingIterations.
 void setNumBoostingIterations(int n)
          Set the value of numBoostingIterations.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setUseCrossValidation(boolean l)
          Set the value of useCrossValidation.
 java.lang.String toString()
          Returns a description of the logistic model (attributes/coefficients).
 java.lang.String useCrossValidationTipText()
          Returns the tip text for this property
 
Methods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_boostedModel

protected LogisticBase m_boostedModel
The actual logistic regression model


m_NominalToBinary

protected NominalToBinary m_NominalToBinary
Filter for converting nominal attributes to binary ones


m_ReplaceMissingValues

protected ReplaceMissingValues m_ReplaceMissingValues
Filter for replacing missing values


m_numBoostingIterations

protected int m_numBoostingIterations
If non-negative, use this as fixed number of LogitBoost iterations


m_maxBoostingIterations

protected int m_maxBoostingIterations
Maximum number of iterations for LogitBoost


m_heuristicStop

protected int m_heuristicStop
Parameter for the heuristic for early stopping of LogitBoost


m_useCrossValidation

protected boolean m_useCrossValidation
If true, cross-validate number of LogitBoost iterations


m_errorOnProbabilities

protected boolean m_errorOnProbabilities
If true, use minimize error on probabilities instead of misclassification error

Constructor Detail

SimpleLogistic

public SimpleLogistic()
Constructor for creating SimpleLogistic object with standard options.


SimpleLogistic

public SimpleLogistic(int numBoostingIterations,
                      boolean useCrossValidation,
                      boolean errorOnProbabilities)
Constructor for creating SimpleLogistic object.

Parameters:
numBoostingIterations - if non-negative, use this as fixed number of iterations for LogitBoost
useCrossValidation - cross-validate number of LogitBoost iterations.
errorOnProbabilities - minimize error on probabilities instead of misclassification error
Method Detail

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Builds the logistic regression using LogitBoost.

Specified by:
buildClassifier in class Classifier
Parameters:
data - the training data
Throws:
java.lang.Exception - if something goes wrong

distributionForInstance

public double[] distributionForInstance(Instance inst)
                                 throws java.lang.Exception
Returns class probabilities for an instance.

Overrides:
distributionForInstance in class Classifier
Parameters:
inst - the instance to be classified
Returns:
an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
Throws:
java.lang.Exception - if distribution can't be computed successfully

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface OptionHandler
Overrides:
listOptions in class Classifier
Returns:
an enumeration of all the available options.

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class Classifier
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the Classifier.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class Classifier
Returns:
an array of strings suitable for passing to setOptions

getNumBoostingIterations

public int getNumBoostingIterations()
Get the value of numBoostingIterations.


getUseCrossValidation

public boolean getUseCrossValidation()
Get the value of useCrossValidation.


getErrorOnProbabilities

public boolean getErrorOnProbabilities()
Get the value of errorOnProbabilities.


getMaxBoostingIterations

public int getMaxBoostingIterations()
Get the value of maxBoostingIterations.


getHeuristicStop

public int getHeuristicStop()
Get the value of heuristicStop.


setNumBoostingIterations

public void setNumBoostingIterations(int n)
Set the value of numBoostingIterations.


setUseCrossValidation

public void setUseCrossValidation(boolean l)
Set the value of useCrossValidation.


setErrorOnProbabilities

public void setErrorOnProbabilities(boolean l)
Set the value of errorOnProbabilities.


setMaxBoostingIterations

public void setMaxBoostingIterations(int n)
Set the value of maxBoostingIterations.


setHeuristicStop

public void setHeuristicStop(int n)
Set the value of heuristicStop.


getNumRegressions

public int getNumRegressions()
Get the number of LogitBoost iterations performed (= the number of regression functions fit by LogitBoost).


toString

public java.lang.String toString()
Returns a description of the logistic model (attributes/coefficients).


measureAttributesUsed

public double measureAttributesUsed()
Returns the fraction of all attributes in the data that are used in the logistic model (in percent). An attribute is used in the model if it is used in any of the models for the different classes.


enumerateMeasures

public java.util.Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure

Specified by:
getMeasure in interface AdditionalMeasureProducer
Parameters:
additionalMeasureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
java.lang.IllegalArgumentException - if the named measure is not supported

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

numBoostingIterationsTipText

public java.lang.String numBoostingIterationsTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

useCrossValidationTipText

public java.lang.String useCrossValidationTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

errorOnProbabilitiesTipText

public java.lang.String errorOnProbabilitiesTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

maxBoostingIterationsTipText

public java.lang.String maxBoostingIterationsTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

heuristicStopTipText

public java.lang.String heuristicStopTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

main

public static void main(java.lang.String[] argv)
Main method for testing this class