|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.trees.lmt.LogisticBase
Base/helper class for building logistic regression models with the LogitBoost algorithm. Used for building logistic model trees (weka.classifiers.trees.lmt.LMT) and standalone logistic regression (weka.classifiers.functions.SimpleLogistic).
Field Summary | |
protected boolean |
m_errorOnProbabilities
Use error on probabilities for stopping criterion of LogitBoost? |
protected int |
m_fixedNumIterations
Use fixed number of iterations for LogitBoost? |
protected int |
m_heuristicStop
Use heuristic to stop performing LogitBoost iterations earlier? |
protected int |
m_maxIterations
The maximum number of LogitBoost iterations |
protected int |
m_numClasses
The number of different classes |
protected Instances |
m_numericData
Numeric version of the training data. |
protected Instances |
m_numericDataHeader
Header-only version of the numeric version of the training data |
protected static int |
m_numFoldsBoosting
Number of folds for cross-validating number of LogitBoost iterations |
protected int |
m_numRegressions
The number of LogitBoost iterations performed. |
protected SimpleLinearRegression[][] |
m_regressions
Array holding the simple regression functions fit by LogitBoost |
protected Instances |
m_train
Training data |
protected boolean |
m_useCrossValidation
Use cross-validation to determine best number of LogitBoost iterations ? |
protected static double |
Z_MAX
Threshold on the Z-value for LogitBoost |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
LogisticBase()
Constructor that creates LogisticBase object with standard options. |
|
LogisticBase(int numBoostingIterations,
boolean useCrossValidation,
boolean errorOnProbabilities)
Constructor to create LogisticBase object. |
Method Summary | |
void |
buildClassifier(Instances data)
Builds the logistic regression model usiing LogitBoost. |
void |
cleanup()
Cleanup in order to save memory. |
double[] |
distributionForInstance(Instance instance)
Returns class probabilities for an instance. |
protected int |
getBestIteration(double[] errors,
int maxIteration)
Helper function to find the minimum in an array of error values. |
protected double[][] |
getCoefficients()
Returns an array holding the coefficients of the logistic model. |
protected double |
getErrorRate(Instances data)
Returns the misclassification error of the current model on a set of instances. |
protected double[] |
getFs(Instance instance)
Computes the F-values for a single instance. |
protected double[][] |
getFs(Instances data)
Computes the F-values for a set of instances. |
int |
getMaxIterations()
Returns the maxIterations parameter. |
protected double |
getMeanAbsoluteError(Instances data)
Returns the error of the probability estimates for the current model on a set of instances. |
protected Instances |
getNumericData(Instances data)
Converts training data to numeric version. |
int |
getNumRegressions()
The number of LogitBoost iterations performed (= the number of simple regression functions fit). |
protected double[][] |
getProbs(double[][] dataFs)
Computes the p-values (probabilities for the different classes) from the F-values for a set of instances. |
int[][] |
getUsedAttributes()
Returns an array of the indices of the attributes used in the logistic model. |
protected double[][] |
getWs(double[][] probs,
double[][] dataYs)
Computes the LogitBoost weights from an array of y/p values (actual/estimated class probabilities). |
protected double[][] |
getYs(Instances data)
Computes the Y-values (actual class probabilities) for a set of instances. |
protected double |
getZ(double actual,
double p)
Computes the LogitBoost response variable from y/p values (actual/estimated class probabilities). |
protected double[][] |
getZs(double[][] probs,
double[][] dataYs)
Computes the LogitBoost response for an array of y/p values (actual/estimated class probabilities). |
protected SimpleLinearRegression[][] |
initRegressions()
Helper function to initialize m_regressions. |
protected double |
logLikelihood(double[][] dataYs,
double[][] probs)
Returns the likelihood of the Y-values (actual class probabilities) given the p-values (current probability estimates). |
double |
percentAttributesUsed()
Returns the fraction of all attributes in the data that are used in the logistic model (in percent). |
protected void |
performBoosting()
Runs LogitBoost using the stopping criterion on the training set. |
protected int |
performBoosting(Instances train,
Instances test,
double[] error,
int maxIterations)
Runs LogitBoost on a training set and monitors the error on a test set. |
protected void |
performBoosting(int numIterations)
Runs LogitBoost with a fixed number of iterations. |
protected void |
performBoostingCV()
Runs LogitBoost, determining the best number of iterations by cross-validation. |
protected boolean |
performIteration(int iteration,
double[][] trainYs,
double[][] trainFs,
double[][] probs,
Instances trainNumeric)
Performs a single iteration of LogitBoost, and updates the model accordingly. |
protected double[] |
probs(double[] Fs)
Computes the p-values (probabilities for the classes) from the F-values of the logistic model. |
protected SimpleLinearRegression[][] |
selectRegressions(SimpleLinearRegression[][] classifiers)
Helper function for cutting back m_regressions to the set of classifiers (corresponsing to the number of LogitBoost iterations) that gave the smallest error. |
void |
setHeuristicStop(int heuristicStop)
Sets the option "heuristicStop". |
void |
setMaxIterations(int maxIterations)
Sets the parameter "maxIterations". |
java.lang.String |
toString()
Returns a description of the logistic model (i.e., attributes and coefficients). |
Methods inherited from class weka.classifiers.Classifier |
classifyInstance, debugTipText, forName, getDebug, getOptions, listOptions, makeCopies, setDebug, setOptions |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Instances m_numericDataHeader
protected Instances m_numericData
protected Instances m_train
protected boolean m_useCrossValidation
protected boolean m_errorOnProbabilities
protected int m_fixedNumIterations
protected int m_heuristicStop
protected int m_numRegressions
protected int m_maxIterations
protected int m_numClasses
protected SimpleLinearRegression[][] m_regressions
protected static int m_numFoldsBoosting
protected static final double Z_MAX
Constructor Detail |
public LogisticBase()
public LogisticBase(int numBoostingIterations, boolean useCrossValidation, boolean errorOnProbabilities)
numBoostingIterations
- fixed number of iterations for LogitBoost (if negative, use cross-validation or
stopping criterion on the training data).useCrossValidation
- cross-validate number of LogitBoost iterations (if false, use stopping
criterion on the training data).errorOnProbabilities
- if true, use error on probabilities
instead of misclassification for stopping criterion of LogitBoostMethod Detail |
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- the training data
java.lang.Exception
- if the classifier has not been
generated successfullyprotected void performBoostingCV() throws java.lang.Exception
java.lang.Exception
protected int performBoosting(Instances train, Instances test, double[] error, int maxIterations) throws java.lang.Exception
train
- the training settest
- the test seterror
- array to hold the logged error valuesmaxIterations
- the maximum number of LogitBoost iterations to run
java.lang.Exception
protected void performBoosting(int numIterations) throws java.lang.Exception
numIterations
- the number of iterations to run
java.lang.Exception
protected void performBoosting() throws java.lang.Exception
java.lang.Exception
protected double getErrorRate(Instances data) throws java.lang.Exception
data
- the set of instances
java.lang.Exception
protected double getMeanAbsoluteError(Instances data) throws java.lang.Exception
data
- the set of instances
java.lang.Exception
protected int getBestIteration(double[] errors, int maxIteration)
protected boolean performIteration(int iteration, double[][] trainYs, double[][] trainFs, double[][] probs, Instances trainNumeric) throws java.lang.Exception
iteration
- the current iterationtrainYs
- the y-values (see description of LogitBoost) for the model trained so fartrainFs
- the F-values (see description of LogitBoost) for the model trained so farprobs
- the p-values (see description of LogitBoost) for the model trained so fartrainNumeric
- numeric version of the training data
java.lang.Exception
protected SimpleLinearRegression[][] initRegressions()
protected Instances getNumericData(Instances data) throws java.lang.Exception
java.lang.Exception
protected SimpleLinearRegression[][] selectRegressions(SimpleLinearRegression[][] classifiers)
protected double getZ(double actual, double p)
protected double[][] getZs(double[][] probs, double[][] dataYs)
protected double[][] getWs(double[][] probs, double[][] dataYs)
protected double[] probs(double[] Fs)
protected double[][] getYs(Instances data)
protected double[] getFs(Instance instance) throws java.lang.Exception
java.lang.Exception
protected double[][] getFs(Instances data) throws java.lang.Exception
java.lang.Exception
protected double[][] getProbs(double[][] dataFs)
protected double logLikelihood(double[][] dataYs, double[][] probs)
public int[][] getUsedAttributes()
public int getNumRegressions()
public void setMaxIterations(int maxIterations)
public void setHeuristicStop(int heuristicStop)
public int getMaxIterations()
protected double[][] getCoefficients()
public double percentAttributesUsed()
public java.lang.String toString()
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computed successfullypublic void cleanup()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |