A - An enumeration of attributes (features) used to inform the decision functionC - The expected output (this must either be Double, Boolean, or some kind of enum)public abstract class Decider<A extends Enum<A>,C> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected TypedAttribute[] |
_attributes |
protected TypedAttribute |
_classAttribute |
protected weka.classifiers.Classifier |
_classifier |
protected weka.core.Instances |
_datasetHeader |
| Modifier | Constructor and Description |
|---|---|
protected |
Decider(String name,
TypedAttribute[] attributes,
TypedAttribute classAttribute,
Vector<weka.filters.Filter> filters) |
| Modifier and Type | Method and Description |
|---|---|
protected weka.core.Instances |
createDatasetHeader() |
Dataset<A,C> |
createNewDataset()
Returns a new (empty) dataset that can (when filled) be used to train or test this decider.
|
abstract C |
getDecision(weka.core.Instance instance)
Makes a decision for the given instance.
|
abstract HashMap<C,Double> |
getDecisionDistribution(weka.core.Instance instance)
Returns a HashMap associating possible decision outputs with a confidence value in that decision.
|
abstract InstanceBuilder<A,C> |
getInstanceBuilder()
Returns a builder for constructing an instance that this decider can make a decision for.
|
String |
getName()
Returns the name of the decision function
|
protected double |
getRawClassification(weka.core.Instance instance) |
protected double[] |
getRawDistributionForInstance(weka.core.Instance instance) |
boolean |
isReady()
You must either
load(java.io.File) or #build before you can call getDecision(Instance) or getDecisionDistribution(Instance)
This method checks that this has been done. |
void |
load(File file)
Loads a prebuilt decider from file
|
void |
save(File file)
Serialises the classifier and saves it to the given file.
|
void |
test(Dataset<A,C> data) |
protected void |
throwIfCannotClassify(weka.core.Instance instance) |
void |
train(weka.classifiers.Classifier classifier,
Dataset<A,C> trainingData)
Trains the decider using the given classifier and training data.
|
protected TypedAttribute[] _attributes
protected TypedAttribute _classAttribute
protected weka.core.Instances _datasetHeader
protected weka.classifiers.Classifier _classifier
protected Decider(String name, TypedAttribute[] attributes, TypedAttribute classAttribute, Vector<weka.filters.Filter> filters) throws Exception
Exceptionpublic String getName()
public boolean isReady()
load(java.io.File) or #build before you can call getDecision(Instance) or getDecisionDistribution(Instance)
This method checks that this has been done.public abstract C getDecision(weka.core.Instance instance) throws Exception
This function is not available until isReady returns true.
You should typically use an instance builder to generate
the instance that is passed into this method.
instance - a set of attribute valuesExceptionpublic abstract HashMap<C,Double> getDecisionDistribution(weka.core.Instance instance) throws Exception
getDecision(Instance)
is clear-cut, or a close tie with other possible decisions.
The method by which these values are calculated and their usefulness depends on the classifier.
This function is not available until isReady returns true.
You should typically use an instance builder to generate
the instance that is passed into this method.
instance - Exceptionprotected double[] getRawDistributionForInstance(weka.core.Instance instance)
throws Exception
Exceptionprotected double getRawClassification(weka.core.Instance instance)
throws Exception
Exceptionprotected void throwIfCannotClassify(weka.core.Instance instance)
throws Exception
Exceptionpublic Dataset<A,C> createNewDataset()
public void train(weka.classifiers.Classifier classifier,
Dataset<A,C> trainingData)
throws Exception
Exceptionpublic void load(File file) throws Exception
file - Exceptionpublic void save(File file) throws IOException
file - the file to save the classifier toIOException - if the file cannot be written toprotected weka.core.Instances createDatasetHeader()
public abstract InstanceBuilder<A,C> getInstanceBuilder()
Copyright © 2012 David Milne. All Rights Reserved.