MOA 12.03
Real Time Analytics for Data Streams
|
Abstract Classifier. More...
Public Member Functions | |
String | getPurposeString () |
Gets the purpose of this object. | |
AbstractClassifier () | |
Creates an classifier and setups the random seed option if the classifier is randomizable. | |
void | prepareForUseImpl (TaskMonitor monitor, ObjectRepository repository) |
This method describes the implementation of how to prepare this object for use. | |
void | setModelContext (InstancesHeader ih) |
Sets the reference to the header of the data stream. | |
InstancesHeader | getModelContext () |
Gets the reference to the header of the data stream. | |
void | setRandomSeed (int s) |
Sets the seed for random number generation. | |
boolean | trainingHasStarted () |
Gets whether training has started. | |
double | trainingWeightSeenByModel () |
Gets the sum of the weights of the instances that have been used by this classifier during the training in trainOnInstance | |
void | resetLearning () |
Resets this classifier. | |
void | trainOnInstance (Instance inst) |
Trains this classifier incrementally using the given instance. | |
Measurement[] | getModelMeasurements () |
Gets the current measurements of this classifier. | |
void | getDescription (StringBuilder out, int indent) |
Returns a string representation of this object. | |
Classifier[] | getSubClassifiers () |
Gets the classifiers of this ensemble. | |
Classifier | copy () |
Produces a copy of this classifier. | |
boolean | correctlyClassifies (Instance inst) |
Gets whether this classifier correctly classifies an instance. | |
String | getClassNameString () |
Gets the name of the attribute of the class from the header. | |
String | getClassLabelString (int classLabelIndex) |
Gets the name of a label of the class from the header. | |
String | getAttributeNameString (int attIndex) |
Gets the name of an attribute from the header. | |
String | getNominalValueString (int attIndex, int valIndex) |
Gets the name of a value of an attribute from the header. | |
AWTRenderer | getAWTRenderer () |
Returns the AWT Renderer. | |
abstract void | resetLearningImpl () |
Resets this classifier. | |
abstract void | trainOnInstanceImpl (Instance inst) |
Trains this classifier incrementally using the given instance. | |
abstract void | getModelDescription (StringBuilder out, int indent) |
Returns a string representation of the model. | |
Static Public Member Functions | |
static boolean | contextIsCompatible (InstancesHeader originalContext, InstancesHeader newContext) |
Returns if two contexts or headers of instances are compatible. | |
Public Attributes | |
IntOption | randomSeedOption |
Option for randomizable learners to change the random seed. | |
Random | classifierRandom |
Random Generator used in randomizable learners. | |
Protected Member Functions | |
abstract Measurement[] | getModelMeasurementsImpl () |
Gets the current measurements of this classifier. | |
Static Protected Member Functions | |
static int | modelAttIndexToInstanceAttIndex (int index, Instance inst) |
Gets the index of the attribute in the instance, given the index of the attribute in the learner. | |
static int | modelAttIndexToInstanceAttIndex (int index, Instances insts) |
Gets the index of the attribute in a set of instances, given the index of the attribute in the learner. | |
Protected Attributes | |
InstancesHeader | modelContext |
Header of the instances of the data stream. | |
double | trainingWeightSeenByModel = 0.0 |
Sum of the weights of the instances trained by this model. | |
int | randomSeed = 1 |
Random seed used in randomizable learners. |
Abstract Classifier.
All learners for nominal prediction in MOA extend this class.
Definition at line 45 of file AbstractClassifier.java.
moa.classifiers.AbstractClassifier.AbstractClassifier | ( | ) |
Creates an classifier and setups the random seed option if the classifier is randomizable.
Definition at line 72 of file AbstractClassifier.java.
Referenced by moa.classifiers.drift.SingleClassifierDrift.getModelDescription(), moa.classifiers.active.ActiveClassifier.getModelDescription(), moa.classifiers.drift.SingleClassifierDrift.getModelMeasurementsImpl(), and moa.classifiers.active.ActiveClassifier.getModelMeasurementsImpl().
static boolean moa.classifiers.AbstractClassifier.contextIsCompatible | ( | InstancesHeader | originalContext, |
InstancesHeader | newContext | ||
) | [static] |
Returns if two contexts or headers of instances are compatible.
Two contexts are compatible if they follow the following rules:
Rule 1: num classes can increase but never decrease
Rule 2: num attributes can increase but never decrease
Rule 3: num nominal attribute values can increase but never decrease
Rule 4: attribute types must stay in the same order (although class can move; is always skipped over)
Attribute names are free to change, but should always still represent the original attributes.
originalContext | the first context to compare |
newContext | the second context to compare |
Definition at line 265 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.setModelContext().
Classifier moa.classifiers.AbstractClassifier.copy | ( | ) |
Produces a copy of this classifier.
Implements moa.classifiers.Classifier.
Definition at line 195 of file AbstractClassifier.java.
Referenced by moa.classifiers.drift.SingleClassifierDrift.resetLearningImpl(), moa.classifiers.active.ActiveClassifier.resetLearningImpl(), and moa.classifiers.drift.SingleClassifierDrift.trainOnInstanceImpl().
boolean moa.classifiers.AbstractClassifier.correctlyClassifies | ( | Instance | inst | ) |
Gets whether this classifier correctly classifies an instance.
Uses getVotesForInstance to obtain the prediction and the instance to obtain its true class.
inst | the instance to be classified |
Implements moa.classifiers.Classifier.
Definition at line 200 of file AbstractClassifier.java.
Referenced by moa.classifiers.meta.OzaBoostAdwin.trainOnInstanceImpl(), moa.classifiers.meta.OzaBoost.trainOnInstanceImpl(), moa.classifiers.meta.OzaBagAdwin.trainOnInstanceImpl(), moa.classifiers.meta.OCBoost.trainOnInstanceImpl(), moa.classifiers.meta.LimAttClassifier.trainOnInstanceImpl(), and moa.classifiers.meta.LeveragingBag.trainOnInstanceImpl().
String moa.classifiers.AbstractClassifier.getAttributeNameString | ( | int | attIndex | ) |
Gets the name of an attribute from the header.
attIndex | the attribute index |
Definition at line 230 of file AbstractClassifier.java.
Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription().
AWTRenderer moa.classifiers.AbstractClassifier.getAWTRenderer | ( | ) |
Returns the AWT Renderer.
Implements moa.gui.AWTRenderable.
Definition at line 311 of file AbstractClassifier.java.
String moa.classifiers.AbstractClassifier.getClassLabelString | ( | int | classLabelIndex | ) |
Gets the name of a label of the class from the header.
classLabelIndex | the label index |
Definition at line 219 of file AbstractClassifier.java.
Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription(), and moa.classifiers.functions.MajorityClass.getModelDescription().
String moa.classifiers.AbstractClassifier.getClassNameString | ( | ) |
Gets the name of the attribute of the class from the header.
Definition at line 209 of file AbstractClassifier.java.
Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription(), and moa.classifiers.functions.MajorityClass.getModelDescription().
void moa.classifiers.AbstractClassifier.getDescription | ( | StringBuilder | sb, |
int | indent | ||
) |
Returns a string representation of this object.
Used in AbstractMOAObject.toString
to give a string representation of the object.
sb | the stringbuilder to add the description |
indent | the number of characters to indent |
Implements moa.MOAObject.
Definition at line 173 of file AbstractClassifier.java.
InstancesHeader moa.classifiers.AbstractClassifier.getModelContext | ( | ) |
Gets the reference to the header of the data stream.
The header of the data stream is extended from WEKA Instances
. This header is needed to know the number of classes and attributes
Implements moa.classifiers.Classifier.
Definition at line 106 of file AbstractClassifier.java.
abstract void moa.classifiers.AbstractClassifier.getModelDescription | ( | StringBuilder | out, |
int | indent | ||
) | [pure virtual] |
Returns a string representation of the model.
out | the stringbuilder to add the description |
indent | the number of characters to indent |
Implemented in moa.classifiers.active.ActiveClassifier, moa.classifiers.bayes.NaiveBayes, moa.classifiers.bayes.NaiveBayesMultinomial, moa.classifiers.drift.SingleClassifierDrift, moa.classifiers.functions.MajorityClass, moa.classifiers.functions.Perceptron, moa.classifiers.functions.SGD, moa.classifiers.functions.SPegasos, moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBagASHT, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, moa.classifiers.meta.WeightedMajorityAlgorithm, moa.classifiers.meta.WEKAClassifier, moa.classifiers.trees.DecisionStump, moa.classifiers.trees.HoeffdingOptionTree, and moa.classifiers.trees.HoeffdingTree.
Referenced by moa.classifiers.AbstractClassifier.getDescription().
Measurement [] moa.classifiers.AbstractClassifier.getModelMeasurements | ( | ) |
Gets the current measurements of this classifier.
Implements moa.classifiers.Classifier.
Definition at line 147 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.getDescription().
abstract Measurement [] moa.classifiers.AbstractClassifier.getModelMeasurementsImpl | ( | ) | [protected, pure virtual] |
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.
Implemented in moa.classifiers.active.ActiveClassifier, moa.classifiers.bayes.NaiveBayes, moa.classifiers.bayes.NaiveBayesMultinomial, moa.classifiers.drift.SingleClassifierDrift, moa.classifiers.functions.MajorityClass, moa.classifiers.functions.Perceptron, moa.classifiers.functions.SGD, moa.classifiers.functions.SPegasos, moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, moa.classifiers.meta.WeightedMajorityAlgorithm, moa.classifiers.meta.WEKAClassifier, moa.classifiers.trees.DecisionStump, moa.classifiers.trees.HoeffdingOptionTree, and moa.classifiers.trees.HoeffdingTree.
Referenced by moa.classifiers.AbstractClassifier.getModelMeasurements().
String moa.classifiers.AbstractClassifier.getNominalValueString | ( | int | attIndex, |
int | valIndex | ||
) |
Gets the name of a value of an attribute from the header.
attIndex | the attribute index |
valIndex | the value of the attribute |
Definition at line 242 of file AbstractClassifier.java.
String moa.classifiers.AbstractClassifier.getPurposeString | ( | ) |
Gets the purpose of this object.
Reimplemented from moa.options.AbstractOptionHandler.
Reimplemented in moa.classifiers.active.ActiveClassifier, moa.classifiers.bayes.NaiveBayes, moa.classifiers.bayes.NaiveBayesMultinomial, moa.classifiers.drift.SingleClassifierDrift, moa.classifiers.functions.MajorityClass, moa.classifiers.functions.Perceptron, moa.classifiers.functions.SGD, moa.classifiers.functions.SPegasos, moa.classifiers.meta.AccuracyUpdatedEnsemble, moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBagASHT, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, moa.classifiers.meta.WeightedMajorityAlgorithm, moa.classifiers.meta.WEKAClassifier, moa.classifiers.trees.AdaHoeffdingOptionTree, moa.classifiers.trees.ASHoeffdingTree, moa.classifiers.trees.DecisionStump, moa.classifiers.trees.HoeffdingAdaptiveTree, moa.classifiers.trees.HoeffdingOptionTree, moa.classifiers.trees.HoeffdingTree, moa.classifiers.trees.LimAttHoeffdingTree, and moa.classifiers.trees.RandomHoeffdingTree.
Definition at line 49 of file AbstractClassifier.java.
Classifier [] moa.classifiers.AbstractClassifier.getSubClassifiers | ( | ) |
Gets the classifiers of this ensemble.
Returns null if this classifier is a single classifier.
Implements moa.classifiers.Classifier.
Reimplemented in moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, and moa.classifiers.meta.WeightedMajorityAlgorithm.
Definition at line 190 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.getModelMeasurements().
static int moa.classifiers.AbstractClassifier.modelAttIndexToInstanceAttIndex | ( | int | index, |
Instances | insts | ||
) | [static, protected] |
Gets the index of the attribute in a set of instances, given the index of the attribute in the learner.
index | the index of the attribute in the learner |
insts | the instances |
Definition at line 379 of file AbstractClassifier.java.
static int moa.classifiers.AbstractClassifier.modelAttIndexToInstanceAttIndex | ( | int | index, |
Instance | inst | ||
) | [static, protected] |
Gets the index of the attribute in the instance, given the index of the attribute in the learner.
index | the index of the attribute in the learner |
inst | the instance |
Definition at line 366 of file AbstractClassifier.java.
Referenced by moa.classifiers.bayes.NaiveBayes.doNaiveBayesPrediction(), moa.classifiers.bayes.NaiveBayes.trainOnInstanceImpl(), and moa.classifiers.trees.DecisionStump.trainOnInstanceImpl().
void moa.classifiers.AbstractClassifier.prepareForUseImpl | ( | TaskMonitor | monitor, |
ObjectRepository | repository | ||
) | [virtual] |
This method describes the implementation of how to prepare this object for use.
All classes that extends this class have to implement prepareForUseImpl
and not prepareForUse
since prepareForUse
calls prepareForUseImpl
.
monitor | the TaskMonitor to use |
repository | the ObjectRepository to use |
Implements moa.options.AbstractOptionHandler.
Reimplemented in moa.classifiers.meta.AccuracyUpdatedEnsemble, moa.classifiers.meta.AccuracyWeightedEnsemble, and moa.classifiers.meta.WeightedMajorityAlgorithm.
Definition at line 80 of file AbstractClassifier.java.
void moa.classifiers.AbstractClassifier.resetLearning | ( | ) |
Resets this classifier.
It must be similar to starting a new classifier from scratch.
Implements moa.classifiers.Classifier.
Definition at line 130 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.prepareForUseImpl().
abstract void moa.classifiers.AbstractClassifier.resetLearningImpl | ( | ) | [pure virtual] |
Resets this classifier.
It must be similar to starting a new classifier from scratch.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.
Implemented in moa.classifiers.active.ActiveClassifier, moa.classifiers.bayes.NaiveBayes, moa.classifiers.bayes.NaiveBayesMultinomial, moa.classifiers.drift.SingleClassifierDrift, moa.classifiers.functions.MajorityClass, moa.classifiers.functions.Perceptron, moa.classifiers.functions.SGD, moa.classifiers.functions.SPegasos, moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBagASHT, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, moa.classifiers.meta.WeightedMajorityAlgorithm, moa.classifiers.meta.WEKAClassifier, moa.classifiers.trees.ASHoeffdingTree, moa.classifiers.trees.DecisionStump, moa.classifiers.trees.HoeffdingOptionTree, and moa.classifiers.trees.HoeffdingTree.
Referenced by moa.classifiers.AbstractClassifier.resetLearning().
void moa.classifiers.AbstractClassifier.setModelContext | ( | InstancesHeader | ih | ) |
Sets the reference to the header of the data stream.
The header of the data stream is extended from WEKA Instances
. This header is needed to know the number of classes and attributes
ih | the reference to the data stream header |
Implements moa.classifiers.Classifier.
Definition at line 91 of file AbstractClassifier.java.
void moa.classifiers.AbstractClassifier.setRandomSeed | ( | int | s | ) |
Sets the seed for random number generation.
s | the seed |
Implements moa.classifiers.Classifier.
Definition at line 111 of file AbstractClassifier.java.
boolean moa.classifiers.AbstractClassifier.trainingHasStarted | ( | ) |
Gets whether training has started.
Implements moa.classifiers.Classifier.
Definition at line 120 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.getDescription(), moa.classifiers.AbstractClassifier.prepareForUseImpl(), and moa.classifiers.AbstractClassifier.setModelContext().
Gets the sum of the weights of the instances that have been used by this classifier during the training in trainOnInstance
Implements moa.classifiers.Classifier.
Definition at line 125 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.getModelMeasurements(), moa.classifiers.meta.AccuracyWeightedEnsemble.getVotesForInstance(), moa.classifiers.AbstractClassifier.resetLearning(), moa.classifiers.AbstractClassifier.trainingHasStarted(), moa.classifiers.AbstractClassifier.trainOnInstance(), moa.classifiers.meta.OzaBoostAdwin.trainOnInstanceImpl(), moa.classifiers.meta.OzaBoost.trainOnInstanceImpl(), moa.classifiers.trees.DecisionStump.trainOnInstanceImpl(), and moa.classifiers.trees.ASHoeffdingTree.trainOnInstanceImpl().
void moa.classifiers.AbstractClassifier.trainOnInstance | ( | Instance | inst | ) |
Trains this classifier incrementally using the given instance.
inst | the instance to be used for training |
Implements moa.classifiers.Classifier.
Definition at line 139 of file AbstractClassifier.java.
abstract void moa.classifiers.AbstractClassifier.trainOnInstanceImpl | ( | Instance | inst | ) | [pure virtual] |
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.
inst | the instance to be used for training |
Implemented in moa.classifiers.active.ActiveClassifier, moa.classifiers.bayes.NaiveBayes, moa.classifiers.bayes.NaiveBayesMultinomial, moa.classifiers.drift.SingleClassifierDrift, moa.classifiers.functions.MajorityClass, moa.classifiers.functions.Perceptron, moa.classifiers.functions.SGD, moa.classifiers.functions.SPegasos, moa.classifiers.meta.AccuracyWeightedEnsemble, moa.classifiers.meta.LeveragingBag, moa.classifiers.meta.LimAttClassifier, moa.classifiers.meta.OCBoost, moa.classifiers.meta.OzaBag, moa.classifiers.meta.OzaBagAdwin, moa.classifiers.meta.OzaBagASHT, moa.classifiers.meta.OzaBoost, moa.classifiers.meta.OzaBoostAdwin, moa.classifiers.meta.WeightedMajorityAlgorithm, moa.classifiers.meta.WEKAClassifier, moa.classifiers.trees.ASHoeffdingTree, moa.classifiers.trees.DecisionStump, moa.classifiers.trees.HoeffdingAdaptiveTree, moa.classifiers.trees.HoeffdingOptionTree, and moa.classifiers.trees.HoeffdingTree.
Referenced by moa.classifiers.AbstractClassifier.trainOnInstance().
Random Generator used in randomizable learners.
Definition at line 66 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.resetLearning(), moa.classifiers.meta.OzaBoostAdwin.trainOnInstanceImpl(), moa.classifiers.meta.OzaBoost.trainOnInstanceImpl(), moa.classifiers.meta.OzaBagASHT.trainOnInstanceImpl(), moa.classifiers.meta.OzaBagAdwin.trainOnInstanceImpl(), moa.classifiers.meta.OzaBag.trainOnInstanceImpl(), moa.classifiers.meta.LeveragingBag.trainOnInstanceImpl(), and moa.classifiers.active.ActiveClassifier.trainOnInstanceImpl().
Header of the instances of the data stream.
Definition at line 54 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.getAttributeNameString(), moa.classifiers.AbstractClassifier.getClassLabelString(), moa.classifiers.AbstractClassifier.getClassNameString(), moa.classifiers.AbstractClassifier.getModelContext(), moa.classifiers.AbstractClassifier.getNominalValueString(), and moa.classifiers.AbstractClassifier.setModelContext().
int moa.classifiers.AbstractClassifier.randomSeed = 1 [protected] |
Random seed used in randomizable learners.
Definition at line 60 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.prepareForUseImpl(), moa.classifiers.AbstractClassifier.resetLearning(), and moa.classifiers.AbstractClassifier.setRandomSeed().
Option for randomizable learners to change the random seed.
Definition at line 63 of file AbstractClassifier.java.
Referenced by moa.classifiers.AbstractClassifier.AbstractClassifier(), moa.classifiers.AbstractClassifier.prepareForUseImpl(), and moa.classifiers.AbstractClassifier.setRandomSeed().
double moa.classifiers.AbstractClassifier.trainingWeightSeenByModel = 0.0 [protected] |
Sum of the weights of the instances trained by this model.
Definition at line 57 of file AbstractClassifier.java.