weka.classifiers.functions
Class Logistic

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

public class Logistic
extends DistributionClassifier
implements OptionHandler, WeightedInstancesHandler

Implements linear logistic regression using LogitBoost and LinearRegression.

Missing values are replaced using ReplaceMissingValues, and nominal attributes are transformed into numeric attributes using NominalToBinary.

-P precision
Set the precision of stopping criterion based on average loglikelihood. (default 1.0e-13)

-R ridge
Set the ridge parameter for the linear regression models. (default 1.0e-8)

-M num
Set the maximum number of iterations. (default 200)

See Also:
Serialized Form

Constructor Summary
Logistic()
           
 
Method Summary
 void buildClassifier(Instances data)
          Builds the model.
 double[] distributionForInstance(Instance inst)
          Classifies an instance.
 int getMaxIts()
          Get the value of MaxIts.
 java.lang.String[] getOptions()
          Gets the current settings of the classifier.
 double getPrecision()
          Gets the precision of stopping criterion in Newton method.
 double getRidge()
          Gets the ridge parameter.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] argv)
          Main method for testing this class.
 void setMaxIts(int newMaxIts)
          Set the value of MaxIts.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setPrecision(double precision)
          Sets the precision of stopping criterion in Newton method.
 void setRidge(double ridge)
          Sets the ridge parameter.
 java.lang.String toString()
          Prints the model.
 
Methods inherited from class weka.classifiers.DistributionClassifier
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Logistic

public Logistic()
Method Detail

listOptions

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

Specified by:
listOptions in interface OptionHandler
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. Valid options are:

-P precision
Set the precision of stopping criterion based on average loglikelihood. (default 1.0e-13)

-R ridge
Set the ridge parameter for the linear regression models. (default 1.0e-8)

-M num
Set the maximum number of iterations. (default 200)

Specified by:
setOptions in interface OptionHandler
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
Returns:
an array of strings suitable for passing to setOptions

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Builds the model.

Specified by:
buildClassifier in class Classifier
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully

distributionForInstance

public double[] distributionForInstance(Instance inst)
                                 throws java.lang.Exception
Classifies an instance.

Specified by:
distributionForInstance in class DistributionClassifier
Parameters:
inst - the instance to be classified
Returns:
an array containing the estimated membership probabilities of the test instance in each class (this should sum to at most 1)
Throws:
java.lang.Exception - if distribution could not be computed successfully

toString

public java.lang.String toString()
Prints the model.


getMaxIts

public int getMaxIts()
Get the value of MaxIts.

Returns:
Value of MaxIts.

setMaxIts

public void setMaxIts(int newMaxIts)
Set the value of MaxIts.

Parameters:
newMaxIts - Value to assign to MaxIts.

setPrecision

public void setPrecision(double precision)
Sets the precision of stopping criterion in Newton method.

Parameters:
precision - the precision

getPrecision

public double getPrecision()
Gets the precision of stopping criterion in Newton method.

Returns:
the precision

setRidge

public void setRidge(double ridge)
Sets the ridge parameter.

Parameters:
ridge - the ridge

getRidge

public double getRidge()
Gets the ridge parameter.

Returns:
the ridge

main

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