MOA 12.03
Real Time Analytics for Data Streams
moa.classifiers.AbstractClassifier Class Reference

Abstract Classifier. More...

Inheritance diagram for moa.classifiers.AbstractClassifier:
Collaboration diagram for moa.classifiers.AbstractClassifier:

List of all members.

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.

Detailed Description

Abstract Classifier.

All learners for nominal prediction in MOA extend this class.

Author:
Richard Kirkby (rkirkby@cs.waikato.ac.nz)
Version:
Revision:
7

Definition at line 45 of file AbstractClassifier.java.


Constructor & Destructor Documentation

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

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.

Parameters:
originalContextthe first context to compare
newContextthe second context to compare
Returns:
true if the two contexts are compatible.

Definition at line 265 of file AbstractClassifier.java.

Referenced by moa.classifiers.AbstractClassifier.setModelContext().

Here is the caller graph for this function:

Classifier moa.classifiers.AbstractClassifier.copy ( )

Produces a copy of this classifier.

Returns:
the 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
instthe instance to be classified
Returns:
true if the instance is correctly 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().

Here is the call graph for this function:

Here is the caller graph for this function:

String moa.classifiers.AbstractClassifier.getAttributeNameString ( int  attIndex)

Gets the name of an attribute from the header.

Parameters:
attIndexthe attribute index
Returns:
the name of the attribute

Definition at line 230 of file AbstractClassifier.java.

Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription().

Here is the call graph for this function:

Here is the caller graph for this function:

AWTRenderer moa.classifiers.AbstractClassifier.getAWTRenderer ( )

Returns the AWT Renderer.

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.

Parameters:
classLabelIndexthe label index
Returns:
the name of the label of the class

Definition at line 219 of file AbstractClassifier.java.

Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription(), and moa.classifiers.functions.MajorityClass.getModelDescription().

Here is the call graph for this function:

Here is the caller graph for this function:

String moa.classifiers.AbstractClassifier.getClassNameString ( )

Gets the name of the attribute of the class from the header.

Returns:
the string with name of the attribute of the class

Definition at line 209 of file AbstractClassifier.java.

Referenced by moa.classifiers.bayes.NaiveBayes.getModelDescription(), and moa.classifiers.functions.MajorityClass.getModelDescription().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
sbthe stringbuilder to add the description
indentthe number of characters to indent

Implements moa.MOAObject.

Definition at line 173 of file AbstractClassifier.java.

Here is the call graph for this function:

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

Returns:
the reference to the data stream header

Implements moa.classifiers.Classifier.

Definition at line 106 of file AbstractClassifier.java.

Measurement [] moa.classifiers.AbstractClassifier.getModelMeasurements ( )

Gets the current measurements of this classifier.

Returns:
an array of measurements to be used in evaluation tasks

Implements moa.classifiers.Classifier.

Definition at line 147 of file AbstractClassifier.java.

Referenced by moa.classifiers.AbstractClassifier.getDescription().

Here is the call graph for this function:

Here is the caller graph for this function:

String moa.classifiers.AbstractClassifier.getNominalValueString ( int  attIndex,
int  valIndex 
)

Gets the name of a value of an attribute from the header.

Parameters:
attIndexthe attribute index
valIndexthe value of the attribute
Returns:
the name of the value of the attribute

Definition at line 242 of file AbstractClassifier.java.

Here is the call graph for this function:

Classifier [] moa.classifiers.AbstractClassifier.getSubClassifiers ( )

Gets the classifiers of this ensemble.

Returns null if this classifier is a single classifier.

Returns:
an array of the classifiers of the ensemble

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().

Here is the caller graph for this function:

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.

Parameters:
indexthe index of the attribute in the learner
inststhe instances
Returns:
the index of the attribute in 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.

Parameters:
indexthe index of the attribute in the learner
instthe instance
Returns:
the index in 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().

Here is the caller graph for this function:

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.

Parameters:
monitorthe TaskMonitor to use
repositorythe 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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
ihthe reference to the data stream header

Implements moa.classifiers.Classifier.

Definition at line 91 of file AbstractClassifier.java.

Here is the call graph for this function:

void moa.classifiers.AbstractClassifier.setRandomSeed ( int  s)

Sets the seed for random number generation.

Parameters:
sthe seed

Implements moa.classifiers.Classifier.

Definition at line 111 of file AbstractClassifier.java.

Here is the call graph for this function:

boolean moa.classifiers.AbstractClassifier.trainingHasStarted ( )

Gets whether training has started.

Returns:
true if 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void moa.classifiers.AbstractClassifier.trainOnInstance ( Instance  inst)

Trains this classifier incrementally using the given instance.

Parameters:
instthe instance to be used for training

Implements moa.classifiers.Classifier.

Definition at line 139 of file AbstractClassifier.java.

Here is the call graph for this function:


Member Data Documentation

Sum of the weights of the instances trained by this model.

Definition at line 57 of file AbstractClassifier.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations