public abstract class AbstractClassifier extends AbstractOptionHandler implements Classifier
Modifier and Type | Field and Description |
---|---|
Random |
classifierRandom
Random Generator used in randomizable learners
|
protected InstancesHeader |
modelContext
Header of the instances of the data stream
|
protected int |
randomSeed
Random seed used in randomizable learners
|
IntOption |
randomSeedOption
Option for randomizable learners to change the random seed
|
protected double |
trainingWeightSeenByModel
Sum of the weights of the instances trained by this model
|
classOptionNamesToPreparedObjects, options
Constructor and Description |
---|
AbstractClassifier()
Creates an classifier and setups the random seed option
if the classifier is randomizable.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
contextIsCompatible(InstancesHeader originalContext,
InstancesHeader newContext)
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. |
Classifier |
copy()
This method produces a copy of this object.
|
boolean |
correctlyClassifies(weka.core.Instance inst)
Gets whether this classifier correctly classifies an instance.
|
String |
getAttributeNameString(int attIndex)
Gets the name of an attribute from the header.
|
AWTRenderer |
getAWTRenderer()
Returns the AWT Renderer
|
String |
getClassLabelString(int classLabelIndex)
Gets the name of a label of the class from the header.
|
String |
getClassNameString()
Gets the name of the attribute of the class from the header.
|
void |
getDescription(StringBuilder out,
int indent)
Returns a string representation of this object.
|
InstancesHeader |
getModelContext()
Gets the reference to the header of the data stream.
|
abstract void |
getModelDescription(StringBuilder out,
int indent)
Returns a string representation of the model.
|
Measurement[] |
getModelMeasurements()
Gets the current measurements of this classifier.
|
protected abstract Measurement[] |
getModelMeasurementsImpl()
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. |
String |
getNominalValueString(int attIndex,
int valIndex)
Gets the name of a value of an attribute from the header.
|
String |
getPurposeString()
Gets the purpose of this object
|
Classifier[] |
getSubClassifiers()
Gets the classifiers of this ensemble.
|
protected static int |
modelAttIndexToInstanceAttIndex(int index,
weka.core.Instance inst)
Gets the index of the attribute in the instance,
given the index of the attribute in the learner.
|
protected static int |
modelAttIndexToInstanceAttIndex(int index,
weka.core.Instances insts)
Gets the index of the attribute in a set of instances,
given the index of the attribute in the learner.
|
void |
prepareForUseImpl(TaskMonitor monitor,
ObjectRepository repository)
This method describes the implementation of how to prepare this object for use.
|
void |
resetLearning()
Resets this classifier.
|
abstract void |
resetLearningImpl()
Resets this classifier.
|
void |
setModelContext(InstancesHeader ih)
Sets 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 |
trainOnInstance(weka.core.Instance inst)
Trains this classifier incrementally using the given instance.
|
abstract void |
trainOnInstanceImpl(weka.core.Instance inst)
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. |
discoverOptionsViaReflection, getCLICreationString, getOptions, getPreparedClassOption, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
copy, measureByteSize, measureByteSize, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getVotesForInstance, isRandomizable
getCLICreationString, getOptions, prepareForUse, prepareForUse
measureByteSize
protected InstancesHeader modelContext
protected double trainingWeightSeenByModel
protected int randomSeed
public IntOption randomSeedOption
public Random classifierRandom
public AbstractClassifier()
public String getPurposeString()
OptionHandler
getPurposeString
in interface OptionHandler
getPurposeString
in class AbstractOptionHandler
public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
AbstractOptionHandler
prepareForUseImpl
and not prepareForUse
since
prepareForUse
calls prepareForUseImpl
.prepareForUseImpl
in class AbstractOptionHandler
monitor
- the TaskMonitor to userepository
- the ObjectRepository to usepublic void setModelContext(InstancesHeader ih)
Classifier
Instances
.
This header is needed to know the number of classes and attributessetModelContext
in interface Classifier
ih
- the reference to the data stream headerpublic InstancesHeader getModelContext()
Classifier
Instances
.
This header is needed to know the number of classes and attributesgetModelContext
in interface Classifier
public void setRandomSeed(int s)
Classifier
setRandomSeed
in interface Classifier
s
- the seedpublic boolean trainingHasStarted()
Classifier
trainingHasStarted
in interface Classifier
public double trainingWeightSeenByModel()
Classifier
trainOnInstance
trainingWeightSeenByModel
in interface Classifier
public void resetLearning()
Classifier
resetLearning
in interface Classifier
public void trainOnInstance(weka.core.Instance inst)
Classifier
trainOnInstance
in interface Classifier
inst
- the instance to be used for trainingpublic Measurement[] getModelMeasurements()
Classifier
getModelMeasurements
in interface Classifier
public void getDescription(StringBuilder out, int indent)
MOAObject
AbstractMOAObject.toString
to give a string representation of the object.getDescription
in interface MOAObject
out
- the stringbuilder to add the descriptionindent
- the number of characters to indentpublic Classifier[] getSubClassifiers()
Classifier
getSubClassifiers
in interface Classifier
public Classifier copy()
MOAObject
copy
in interface Classifier
copy
in interface MOAObject
copy
in interface OptionHandler
copy
in class AbstractOptionHandler
public boolean correctlyClassifies(weka.core.Instance inst)
Classifier
correctlyClassifies
in interface Classifier
inst
- the instance to be classifiedpublic String getClassNameString()
public String getClassLabelString(int classLabelIndex)
classLabelIndex
- the label indexpublic String getAttributeNameString(int attIndex)
attIndex
- the attribute indexpublic String getNominalValueString(int attIndex, int valIndex)
attIndex
- the attribute indexvalIndex
- the value of the attributepublic static boolean contextIsCompatible(InstancesHeader originalContext, InstancesHeader newContext)
originalContext
- the first context to comparenewContext
- the second context to comparepublic AWTRenderer getAWTRenderer()
getAWTRenderer
in interface AWTRenderable
public abstract void resetLearningImpl()
public abstract void trainOnInstanceImpl(weka.core.Instance inst)
inst
- the instance to be used for trainingprotected abstract Measurement[] getModelMeasurementsImpl()
public abstract void getModelDescription(StringBuilder out, int indent)
out
- the stringbuilder to add the descriptionindent
- the number of characters to indentprotected static int modelAttIndexToInstanceAttIndex(int index, weka.core.Instance inst)
index
- the index of the attribute in the learnerinst
- the instanceprotected static int modelAttIndexToInstanceAttIndex(int index, weka.core.Instances insts)
index
- the index of the attribute in the learnerinsts
- the instancesCopyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.