@PublicationReference(author="Tommi S. Jaakkola",title="Machine learning: lecture 5",type=WebPage,year=2004,url="http://www.ai.mit.edu/courses/6.867-f04/lectures/lecture-5-ho.pdf",notes="Good formulation of logistic regression on slides 15-20") @PublicationReference(author={"Paul Komarek","Andrew Moore"},title="Making Logistic Regression A Core Data Mining Tool With TR-IRLS",publication="Proceedings of the 5th International Conference on Data Mining Machine Learning",type=Conference,year=2005,url="http://www.autonlab.org/autonweb/14717.html",notes="Good practical overview of logistic regression") @PublicationReference(author="Christopher M. Bishop",title="Pattern Recognition and Machine Learning",type=Book,year=2006,pages={207,208},notes="Section 4.3.3") public class LogisticRegression extends AbstractAnytimeSupervisedBatchLearner<Vectorizable,java.lang.Double,LogisticRegression.Function>
| Modifier and Type | Class and Description |
|---|---|
static class |
LogisticRegression.Function
Class that is a linear discriminant, followed by a sigmoid function.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_ITERATIONS
Default number of iterations before stopping, 100
|
static double |
DEFAULT_REGULARIZATION
Default regularization, 0.0.
|
static double |
DEFAULT_TOLERANCE
Default tolerance change in weights before stopping, 1.0E-10
|
data, keepGoingmaxIterationsDEFAULT_ITERATION, iteration| Constructor and Description |
|---|
LogisticRegression()
Default constructor, with no regularization.
|
LogisticRegression(double regularization)
Creates a new instance of LogisticRegression
|
LogisticRegression(double regularization,
double tolerance,
int maxIterations)
Creates a new instance of LogisticRegression
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
LogisticRegression |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
LogisticRegression.Function |
getObjectToOptimize()
Getter for objectToOptimize
|
double |
getRegularization()
Getter for regularization
|
LogisticRegression.Function |
getResult()
Gets the current result of the algorithm.
|
double |
getTolerance()
Getter for tolerance
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
void |
setObjectToOptimize(LogisticRegression.Function objectToOptimize)
Setter for objectToOptimize
|
void |
setRegularization(double regularization)
Setter for regularization
|
void |
setResult(LogisticRegression.Function result)
Setter for result
|
void |
setTolerance(double tolerance)
Setter for tolerance
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
getData, getKeepGoing, learn, setData, setKeepGoing, stopgetMaxIterations, isResultValid, setMaxIterationsaddIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListenersequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlearngetMaxIterations, setMaxIterationsaddIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListenerisResultValidpublic static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_TOLERANCE
public static final double DEFAULT_REGULARIZATION
public LogisticRegression()
public LogisticRegression(double regularization)
regularization - L2 ridge regularization term, must be nonnegative, a value of zero is
equivalent to unregularized regression.public LogisticRegression(double regularization,
double tolerance,
int maxIterations)
regularization - L2 ridge regularization term, must be nonnegative, a value of zero is
equivalent to unregularized regression.tolerance - Tolerance change in weights before stoppingmaxIterations - Maximum number of iterations before stoppingpublic LogisticRegression clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,java.lang.Double>>,LogisticRegression.Function>protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearnerinitializeAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,java.lang.Double>>,LogisticRegression.Function>protected boolean step()
AbstractAnytimeBatchLearnerstep in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,java.lang.Double>>,LogisticRegression.Function>protected void cleanupAlgorithm()
AbstractAnytimeBatchLearnercleanupAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,java.lang.Double>>,LogisticRegression.Function>public LogisticRegression.Function getObjectToOptimize()
public void setObjectToOptimize(LogisticRegression.Function objectToOptimize)
objectToOptimize - The object to optimize, used as a factory on successive runs of the
algorithm.public LogisticRegression.Function getResult()
AnytimeAlgorithmpublic void setResult(LogisticRegression.Function result)
result - Return value from the algorithmpublic double getTolerance()
public void setTolerance(double tolerance)
tolerance - Tolerance change in weights before stopping, must be nonnegative.public double getRegularization()
public void setRegularization(double regularization)
regularization - L2 ridge regularization term, must be nonnegative, a value of zero is
equivalent to unregularized regression.