|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectace.InstanceClassifier
public class InstanceClassifier
Classifies a set of Weka Instances using a trained Weka Classifier of a TrainedModel object.
Constructor Summary | |
---|---|
InstanceClassifier()
|
Method Summary | |
---|---|
static SegmentedClassification[] |
classify(TrainedModel trained,
DataBoard data_board,
weka.core.Instances instances,
java.lang.String results_file,
boolean save_intermediate_arffs)
Classify a set of instances using a trained Weka Classifier. |
static weka.core.Instances |
classifyInstances(TrainedModel trained,
weka.core.Instances instances,
boolean save_intermediate_arffs)
Classifies a set of Weka Instances. |
static java.lang.String |
formatConfusionMatrix(double[][] matrix,
java.lang.String[] classes)
Creates an easily readable version of a confusion matrix to be included in results output. |
static double[][] |
getConfusionMatrix(weka.core.Instances model,
weka.core.Instances classified,
java.lang.String[] classes)
Gets the confusion matrix for a set of classified Instances. |
static double |
getCorrectCount(weka.core.Instances models,
weka.core.Instances results)
Compares the given classifications with the given model classifications and returns number of correct classifications. |
static double[] |
getSuccessRate(SegmentedClassification[] models,
SegmentedClassification[] results,
java.lang.StringBuffer out)
Gets the number of correct classifications for overall instances and subsections and appends the results of each classification to a given StringBuffer object. |
static java.lang.String |
getSuccessString(SegmentedClassification[] models,
SegmentedClassification[] results,
java.lang.StringBuffer out)
Gets a String describing the success rate of a classification. |
protected static java.lang.String |
num2ShortID(int num,
char[] IDChars,
int IDWidth)
Method for generating indices for the confusion matrix. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InstanceClassifier()
Method Detail |
---|
public static SegmentedClassification[] classify(TrainedModel trained, DataBoard data_board, weka.core.Instances instances, java.lang.String results_file, boolean save_intermediate_arffs) throws java.lang.Exception
trained
- Object containing references to
the Weka objects needed for Classification,
including a trained Weka Classifier.data_board
- Contains instances to classify and
method to perform classification.instances
- The Weka Instances to classify.save_intermediate_arffs
- Whether or not to save testing data to an
arff file after parsing and again after feature
selection, if any. Useful for testing.results_file
- The name of the file to which the
classification results will be stored.
Should have extention ".xml" if using
ACE XML files or ".arff" if using
Weka ARFF files. May be null if no
file is to be saved.
java.lang.Exception
- If an error is encountered.public static weka.core.Instances classifyInstances(TrainedModel trained, weka.core.Instances instances, boolean save_intermediate_arffs) throws java.lang.Exception
trained
- Object containing references to
the Weka objects needed for Classification,
including a trained Weka Classifier.instances
- The Weka Instances to classify.save_intermediate_arffs
- Whether or not to save testing data to an
arff file after parsing and again after feature
selection, if any. Useful for testing.
java.lang.Exception
- If an error occurs.public static double[][] getConfusionMatrix(weka.core.Instances model, weka.core.Instances classified, java.lang.String[] classes)
model
- The original Instances that were used for testing.classified
- The classified Instances to be evaluated.classes
- The possible classes into which an Instance may be classified.
public static java.lang.String formatConfusionMatrix(double[][] matrix, java.lang.String[] classes)
matrix
- Confusion matrix for a classification. Table representing
correct and incorrect classifications.classes
- The possible classes into which an instance may be classified.
protected static java.lang.String num2ShortID(int num, char[] IDChars, int IDWidth)
num
- integer to formatIDChars
- the characters to useIDWidth
- the width of the entry
public static double getCorrectCount(weka.core.Instances models, weka.core.Instances results)
If an instance belongs to multiple classes in its model classifications, and only a fraction of these are found, then the calculation of the overall success rate will treat this as fractionally succesful.
models
- The model classifications.results
- The classifications to compare to the models.
public static java.lang.String getSuccessString(SegmentedClassification[] models, SegmentedClassification[] results, java.lang.StringBuffer out)
models
- The model classifications from the original instances.results
- The classifications predicted by the trained Classifier.out
- StringBuffer that will be passed to getSuccessRate and to
which the results of individual classifications will be printed.
public static double[] getSuccessRate(SegmentedClassification[] models, SegmentedClassification[] results, java.lang.StringBuffer out)
If an instance belongs to multiple classes in its model classifications, and only a fraction of these are found, then the calculation of the overall success rate will treat this as fractionally succesful.
The reported value for error rate includes wrong classifications as well as additional classifications beyond the correct ones (sincce a given instance may have an arbitrary number of correct classes).
models
- The model classifications.results
- The classifications to compare to the models.out
- The StringBuffer to which results of the classification
of each individual instance will be printed. Misclassifications
will be preceded by an asterisk(*) and partially misclassified
instances will be preceeded by a caret(^).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |