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, prepareForUsecopy, measureByteSize, measureByteSize, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetVotesForInstance, isRandomizablegetCLICreationString, getOptions, prepareForUse, prepareForUsemeasureByteSizeprotected InstancesHeader modelContext
protected double trainingWeightSeenByModel
protected int randomSeed
public IntOption randomSeedOption
public Random classifierRandom
public AbstractClassifier()
public String getPurposeString()
OptionHandlergetPurposeString in interface OptionHandlergetPurposeString in class AbstractOptionHandlerpublic void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
AbstractOptionHandlerprepareForUseImpl
and not prepareForUse since
prepareForUse calls prepareForUseImpl.prepareForUseImpl in class AbstractOptionHandlermonitor - the TaskMonitor to userepository - the ObjectRepository to usepublic void setModelContext(InstancesHeader ih)
ClassifierInstances.
This header is needed to know the number of classes and attributessetModelContext in interface Classifierih - the reference to the data stream headerpublic InstancesHeader getModelContext()
ClassifierInstances.
This header is needed to know the number of classes and attributesgetModelContext in interface Classifierpublic void setRandomSeed(int s)
ClassifiersetRandomSeed in interface Classifiers - the seedpublic boolean trainingHasStarted()
ClassifiertrainingHasStarted in interface Classifierpublic double trainingWeightSeenByModel()
ClassifiertrainOnInstancetrainingWeightSeenByModel in interface Classifierpublic void resetLearning()
ClassifierresetLearning in interface Classifierpublic void trainOnInstance(weka.core.Instance inst)
ClassifiertrainOnInstance in interface Classifierinst - the instance to be used for trainingpublic Measurement[] getModelMeasurements()
ClassifiergetModelMeasurements in interface Classifierpublic void getDescription(StringBuilder out, int indent)
MOAObjectAbstractMOAObject.toString
to give a string representation of the object.getDescription in interface MOAObjectout - the stringbuilder to add the descriptionindent - the number of characters to indentpublic Classifier[] getSubClassifiers()
ClassifiergetSubClassifiers in interface Classifierpublic Classifier copy()
MOAObjectcopy in interface Classifiercopy in interface MOAObjectcopy in interface OptionHandlercopy in class AbstractOptionHandlerpublic boolean correctlyClassifies(weka.core.Instance inst)
ClassifiercorrectlyClassifies in interface Classifierinst - 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 AWTRenderablepublic 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.