CategoryType - The type of output categories. Can be any type that has a valid
equals and hashCode method.@PublicationReference(title="Ultraconservative Online Algorithms for Multiclass Problems", author={"Koby Crammer","Yoram Singer"}, year=2003, type=Journal, publication="Journal of Machine Learning Research", pages={951,991}, url="http://portal.acm.org/citation.cfm?id=944936") public class BatchMultiPerceptron<CategoryType> extends AbstractAnytimeSupervisedBatchLearner<Vectorizable,CategoryType,LinearMultiCategorizer<CategoryType>> implements MeasurablePerformanceAlgorithm, VectorFactoryContainer
Perceptron,
OnlinePerceptron,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations, 100.
|
static double |
DEFAULT_MIN_MARGIN
The default minimum margin is 0.0.
|
protected int |
errorCount
The number of errors on the most recent iteration.
|
protected double |
minMargin
The minimum margin to enforce.
|
protected LinearMultiCategorizer<CategoryType> |
result
The linear categorizer created by the algorithm.
|
protected VectorFactory<?> |
vectorFactory
The factory to create weight vectors.
|
data, keepGoingmaxIterationsDEFAULT_ITERATION, iteration| Constructor and Description |
|---|
BatchMultiPerceptron()
Creates a new
BatchMultiPerceptron with default parameters. |
BatchMultiPerceptron(int maxIterations)
Creates a new
BatchMultiPerceptron with the given maximum number
of iterations and a default margin of 0.0. |
BatchMultiPerceptron(int maxIterations,
double minMargin)
Creates a new
BatchMultiPerceptron with the given maximum
number of iterations and margin to enforce. |
BatchMultiPerceptron(int maxIterations,
double minMargin,
VectorFactory<?> vectorFactory)
Creates a new
BatchMultiPerceptron with the given parameters. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
int |
getErrorCount()
Gets the error count of the most recent iteration.
|
double |
getMinMargin()
Gets the minimum margin to enforce.
|
NamedValue<java.lang.Integer> |
getPerformance()
Gets the performance, which is the error count on the last iteration.
|
LinearMultiCategorizer<CategoryType> |
getResult()
Gets the current result of the algorithm.
|
VectorFactory<?> |
getVectorFactory()
Gets the VectorFactory used to create the weight vector.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
protected void |
setErrorCount(int errorCount)
Sets the error count of the most recent iteration.
|
void |
setMinMargin(double minMargin)
Gets the minimum margin to enforce.
|
protected void |
setResult(LinearMultiCategorizer<CategoryType> result)
Sets the result of the algorithm.
|
void |
setVectorFactory(VectorFactory<?> vectorFactory)
Sets the VectorFactory used to create the weight vector.
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
clone, 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, waitlearnclonegetMaxIterations, setMaxIterationsaddIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListenerisResultValidpublic static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_MIN_MARGIN
protected double minMargin
protected VectorFactory<?> vectorFactory
protected transient LinearMultiCategorizer<CategoryType> result
protected transient int errorCount
public BatchMultiPerceptron()
BatchMultiPerceptron with default parameters.public BatchMultiPerceptron(int maxIterations)
BatchMultiPerceptron with the given maximum number
of iterations and a default margin of 0.0.maxIterations - The maximum number of iterations. Must be positive.public BatchMultiPerceptron(int maxIterations,
double minMargin)
BatchMultiPerceptron with the given maximum
number of iterations and margin to enforce.maxIterations - The maximum number of iterations. Must be positive.minMargin - The minimum margin to enforce. Must be non-negative.public BatchMultiPerceptron(int maxIterations,
double minMargin,
VectorFactory<?> vectorFactory)
BatchMultiPerceptron with the given parameters.maxIterations - The maximum number of iterations. Must be positive.minMargin - The minimum margin to enforce. Must be non-negative.vectorFactory - The factory to use to create weight vectors.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearnerinitializeAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,CategoryType>>,LinearMultiCategorizer<CategoryType>>protected boolean step()
AbstractAnytimeBatchLearnerstep in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,CategoryType>>,LinearMultiCategorizer<CategoryType>>protected void cleanupAlgorithm()
AbstractAnytimeBatchLearnercleanupAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vectorizable,CategoryType>>,LinearMultiCategorizer<CategoryType>>public LinearMultiCategorizer<CategoryType> getResult()
AnytimeAlgorithmgetResult in interface AnytimeAlgorithm<LinearMultiCategorizer<CategoryType>>protected void setResult(LinearMultiCategorizer<CategoryType> result)
result - The result of the algorithm.public double getMinMargin()
public void setMinMargin(double minMargin)
minMargin - The minimum margin. Cannot be negative.public VectorFactory<?> getVectorFactory()
getVectorFactory in interface VectorFactoryContainerpublic void setVectorFactory(VectorFactory<?> vectorFactory)
vectorFactory - The VectorFactory used to create the weight vector.public int getErrorCount()
protected void setErrorCount(int errorCount)
errorCount - The current error count.public NamedValue<java.lang.Integer> getPerformance()
getPerformance in interface MeasurablePerformanceAlgorithm