public class Evaluation extends java.lang.Object implements Summarizable, RevisionHandler, java.io.Serializable
public static void main(String [] args) {
runClassifier(new FunkyClassifier(), args);
}
------------------------------------------------------------------
Example usage from within an application:
Instances trainInstances = ... instances got from somewhere
Instances testInstances = ... instances got from somewhere
Classifier scheme = ... scheme got from somewhere
Evaluation evaluation = new Evaluation(trainInstances);
evaluation.evaluateModel(scheme, testInstances);
System.out.println(evaluation.toSummaryString());
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
BUILT_IN_EVAL_METRICS |
Constructor and Description |
---|
Evaluation(Instances data)
Initializes all the counters for the evaluation.
|
Evaluation(Instances data,
CostMatrix costMatrix)
Initializes all the counters for the evaluation and also takes a cost
matrix as parameter.
|
Modifier and Type | Method and Description |
---|---|
double |
areaUnderPRC(int classIndex)
Returns the area under precision-recall curve (AUPRC) for those predictions
that have been collected in the evaluateClassifier(Classifier, Instances)
method.
|
double |
areaUnderROC(int classIndex)
Returns the area under ROC for those predictions that have been collected
in the evaluateClassifier(Classifier, Instances) method.
|
double |
avgCost()
Gets the average cost, that is, total cost of misclassifications (incorrect
plus unclassified) over the total number of instances.
|
double[][] |
confusionMatrix()
Returns a copy of the confusion matrix.
|
double |
correct()
Gets the number of instances correctly classified (that is, for which a
correct prediction was made).
|
double |
correlationCoefficient()
Returns the correlation coefficient if the class is numeric.
|
double |
coverageOfTestCasesByPredictedRegions()
Gets the coverage of the test cases by the predicted regions at the
confidence level specified when evaluation was performed.
|
void |
crossValidateModel(Classifier classifier,
Instances data,
int numFolds,
java.util.Random random)
Performs a (stratified if class is nominal) cross-validation for a
classifier on a set of instances.
|
void |
crossValidateModel(Classifier classifier,
Instances data,
int numFolds,
java.util.Random random,
java.lang.Object... forPrinting)
Performs a (stratified if class is nominal) cross-validation for a
classifier on a set of instances.
|
void |
crossValidateModel(java.lang.String classifierString,
Instances data,
int numFolds,
java.lang.String[] options,
java.util.Random random)
Performs a (stratified if class is nominal) cross-validation for a
classifier on a set of instances.
|
boolean |
equals(java.lang.Object obj)
Tests whether the current evaluation object is equal to another evaluation
object.
|
double |
errorRate()
Returns the estimated error rate or the root mean squared error (if the
class is numeric).
|
double[] |
evaluateModel(Classifier classifier,
Instances data,
java.lang.Object... forPredictionsPrinting)
Evaluates the classifier on a given set of instances.
|
static java.lang.String |
evaluateModel(Classifier classifier,
java.lang.String[] options)
Evaluates a classifier with the options given in an array of strings.
|
static java.lang.String |
evaluateModel(java.lang.String classifierString,
java.lang.String[] options)
Evaluates a classifier with the options given in an array of strings.
|
double |
evaluateModelOnce(Classifier classifier,
Instance instance)
Evaluates the classifier on a single instance.
|
double |
evaluateModelOnce(double[] dist,
Instance instance)
Evaluates the supplied distribution on a single instance.
|
void |
evaluateModelOnce(double prediction,
Instance instance)
Evaluates the supplied prediction on a single instance.
|
double |
evaluateModelOnceAndRecordPrediction(Classifier classifier,
Instance instance)
Evaluates the classifier on a single instance and records the prediction.
|
double |
evaluateModelOnceAndRecordPrediction(double[] dist,
Instance instance)
Evaluates the supplied distribution on a single instance.
|
double |
evaluationForSingleInstance(double[] dist,
Instance instance,
boolean storePredictions)
Evaluates the supplied distribution on a single instance.
|
double |
falseNegativeRate(int classIndex)
Calculate the false negative rate with respect to a particular class.
|
double |
falseNegativeRate(int classIndex,
double numPositives)
Calculate the false negative rate with respect to a particular class.
|
double |
falsePositiveRate(int classIndex)
Calculate the false positive rate with respect to a particular class.
|
double |
falsePositiveRate(int classIndex,
double numNegatives)
Calculate the false positive rate with respect to a particular class.
|
double |
fMeasure(double precision,
double recall)
Calculate the F-Measure with respect to a particular class.
|
double |
fMeasure(int classIndex)
Calculate the F-Measure with respect to a particular class.
|
static java.util.List<java.lang.String> |
getAllEvaluationMetricNames()
Utility method to get a list of the names of all built-in and plugin
evaluation metrics
|
double[] |
getClassPriors()
Get the current weighted class counts.
|
boolean |
getDiscardPredictions()
Returns whether predictions are not recorded at all, in order to conserve
memory.
|
Instances |
getHeader()
Returns the header of the underlying dataset.
|
java.util.List<java.lang.String> |
getMetricsToDisplay()
Get a list of the names of metrics to have appear in the output The default
is to display all built in metrics and plugin metrics that haven't been
globally disabled.
|
AbstractEvaluationMetric |
getPluginMetric(java.lang.String name)
Get the named plugin evaluation metric
|
java.util.List<AbstractEvaluationMetric> |
getPluginMetrics()
Returns the list of plugin metrics in use (or null if there are none)
|
java.lang.String |
getRevision()
Returns the revision string.
|
double |
incorrect()
Gets the number of instances incorrectly classified (that is, for which an
incorrect prediction was made).
|
double |
kappa()
Returns value of kappa statistic if class is nominal.
|
double |
KBInformation()
Return the total Kononenko & Bratko Information score in bits.
|
double |
KBMeanInformation()
Return the Kononenko & Bratko Information score in bits per instance.
|
double |
KBRelativeInformation()
Return the Kononenko & Bratko Relative Information score.
|
static void |
main(java.lang.String[] args)
A test method for this class.
|
double |
matthewsCorrelationCoefficient(int classIndex)
Calculates the matthews correlation coefficient (sometimes called phi
coefficient) for the supplied class.
|
double |
matthewsCorrelationCoefficient(int classIndex,
double numTP,
double numTN,
double numFP,
double numFN)
Calculates the matthews correlation coefficient (sometimes called phi
coefficient) for the supplied class.
|
double |
meanAbsoluteError()
Returns the mean absolute error.
|
double |
meanPriorAbsoluteError()
Returns the mean absolute error of the prior.
|
double |
missingClass()
Gets the weight of the instances that had missing class values
|
double |
numClassified()
Returns the number (really, weight) of instances that have been classified.
|
double |
numFalseNegatives(int classIndex)
Calculate number (really, weight) of false negatives with respect to a particular class.
|
double |
numFalsePositives(int classIndex)
Calculate the number (really, weight) of false positives with respect to a particular class.
|
double |
numInstances()
Gets the number of test instances that had a known class value (actually
the sum of the weights of test instances with known class value).
|
double |
numNegatives(int classIndex)
Calculate the number (really, weight) of instances not in the given class.
|
double |
numPositives(int classIndex)
Calculate the number (really, weight) of instances of the given class.
|
double |
numPredictedNegatives(int classIndex)
Calculate the number (really, weight) of instances predicted not to be of the given class.
|
double |
numPredictedPositives(int classIndex)
Calculate the number (really, weight) of instances predicted to be of the given class.
|
double |
numTrueNegatives(int classIndex)
Calculate the number (really, weight) of true negatives with respect to a particular class.
|
double |
numTruePositives(int classIndex)
Calculate the number (really, weight) of true positives with respect to a particular class.
|
double |
pctCorrect()
Gets the percentage of instances correctly classified (that is, for which a
correct prediction was made).
|
double |
pctIncorrect()
Gets the percentage of instances incorrectly classified (that is, for which
an incorrect prediction was made).
|
double |
pctUnclassified()
Gets the percentage of instances not classified (that is, for which no
prediction was made by the classifier).
|
double |
precision(int classIndex)
Calculate the precision with respect to a particular class.
|
double[] |
predictedClassCounts()
Returns the predicted number (really, weight) of instances in each class.
|
java.util.ArrayList<Prediction> |
predictions()
Returns the predictions that have been collected.
|
double |
priorEntropy()
Returns the mean base-2 log loss wrt the null model.
|
double |
recall(int classIndex)
Calculate the recall with respect to a particular class.
|
double |
relativeAbsoluteError()
Returns the relative absolute error.
|
double |
rootMeanPriorSquaredError()
Returns the root mean prior squared error.
|
double |
rootMeanSquaredError()
Returns the root mean squared error.
|
double |
rootRelativeSquaredError()
Returns the root relative squared error if the class is numeric.
|
void |
setDiscardPredictions(boolean value)
Sets whether to discard predictions, ie, not storing them for future
reference via predictions() method in order to conserve memory.
|
void |
setMetricsToDisplay(java.util.List<java.lang.String> display)
Set a list of the names of metrics to have appear in the output.
|
void |
setPriors(Instances train)
Sets the class prior probabilities.
|
double |
SFEntropyGain()
Returns the difference in base-2 log loss between null model and scheme.
|
double |
SFMeanEntropyGain()
Returns the mean difference in base-2 log loss between null model and scheme.
|
double |
SFMeanPriorEntropy()
Returns the mean base-2 log loss wrt the null model.
|
double |
SFMeanSchemeEntropy()
Returns the mean base-2 log loss wrt the scheme.
|
double |
SFPriorEntropy()
Returns the base-2 log loss wrt the null model.
|
double |
SFSchemeEntropy()
Returns the base-2 log loss wrt the scheme.
|
double |
sizeOfPredictedRegions()
Gets the average size of the predicted regions, relative to the range of
the target in the training data, at the confidence level specified when
evaluation was performed.
|
java.lang.String |
toClassDetailsString()
Generates a breakdown of the accuracy for each class (with default title),
incorporating various information-retrieval statistics, such as true/false
positive rate, precision/recall/F-Measure.
|
java.lang.String |
toClassDetailsString(java.lang.String title)
Generates a breakdown of the accuracy for each class, incorporating various
information-retrieval statistics, such as true/false positive rate,
precision/recall/F-Measure.
|
java.lang.String |
toCumulativeMarginDistributionString()
Output the cumulative margin distribution as a string suitable for input
for gnuplot or similar package.
|
void |
toggleEvalMetrics(java.util.List<java.lang.String> metricsToToggle)
Toggle the output of the metrics specified in the supplied list.
|
java.lang.String |
toMatrixString()
Calls toMatrixString() with a default title.
|
java.lang.String |
toMatrixString(java.lang.String title)
Outputs the performance statistics as a classification confusion matrix.
|
java.lang.String |
toSummaryString()
Calls toSummaryString() with no title and no complexity stats.
|
java.lang.String |
toSummaryString(boolean printComplexityStatistics)
Calls toSummaryString() with a default title.
|
java.lang.String |
toSummaryString(java.lang.String title,
boolean printComplexityStatistics)
Outputs the performance statistics in summary form.
|
double |
totalCost()
Gets the total cost, that is, the cost of each prediction times the weight
of the instance, summed over all instances.
|
double[] |
trueClassCounts()
Returns the number (really, weight) of instances in each class.
|
double |
trueNegativeRate(int classIndex)
Calculate the true negative rate with respect to a particular class.
|
double |
trueNegativeRate(int classIndex,
double numNegatives)
Calculate the true negative rate with respect to a particular class.
|
double |
truePositiveRate(int classIndex)
Calculate the true positive rate with respect to a particular class.
|
double |
truePositiveRate(int classIndex,
double numPositives)
Calculate the true positive rate with respect to a particular class.
|
double |
unclassified()
Gets the number of instances not classified (that is, for which no
prediction was made by the classifier).
|
double |
unweightedMacroFmeasure()
Unweighted macro-averaged F-measure.
|
double |
unweightedMicroFmeasure()
Unweighted micro-averaged F-measure.
|
void |
updatePriors(Instance instance)
Updates the class prior probabilities or the mean respectively (when
incrementally training).
|
void |
useNoPriors()
disables the use of priors, e.g., in case of de-serialized schemes that
have no access to the original training set, but are evaluated on a set
set.
|
double |
weightedAreaUnderPRC()
Calculates the weighted (by class size) AUPRC.
|
double |
weightedAreaUnderROC()
Calculates the weighted (by class size) AUROC.
|
double |
weightedFalseNegativeRate()
Calculates the weighted (by class size) false negative rate.
|
double |
weightedFalsePositiveRate()
Calculates the weighted (by class size) false positive rate.
|
double |
weightedFMeasure()
Calculates the macro weighted (by class size) average F-Measure.
|
double |
weightedMatthewsCorrelation()
Calculates the weighted (by class size) matthews correlation coefficient.
|
double |
weightedPrecision()
Calculates the weighted (by class size) precision.
|
double |
weightedRecall()
Calculates the weighted (by class size) recall.
|
double |
weightedTrueNegativeRate()
Calculates the weighted (by class size) true negative rate.
|
double |
weightedTruePositiveRate()
Calculates the weighted (by class size) true positive rate.
|
static java.lang.String |
wekaStaticWrapper(Sourcable classifier,
java.lang.String className)
Wraps a static classifier in enough source to test using the weka class
libraries.
|
double |
withClass()
Gets the weight of the instances that had a non-missing class value
|
public Evaluation(Instances data) throws java.lang.Exception
useNoPriors()
if the dataset is the test set and you can't
initialize with the priors from the training set via
setPriors(Instances)
.data
- set of training instances, to get some header information and
prior class distribution informationjava.lang.Exception
- if the class is not defineduseNoPriors()
,
setPriors(Instances)
public Evaluation(Instances data, CostMatrix costMatrix) throws java.lang.Exception
useNoPriors()
if the dataset is the
test set and you can't initialize with the priors from the training set via
setPriors(Instances)
.data
- set of training instances, to get some header information and
prior class distribution informationcostMatrix
- the cost matrix---if null, default costs will be usedjava.lang.Exception
- if cost matrix is not compatible with data, the class is
not defined or the class is numericuseNoPriors()
,
setPriors(Instances)
public static java.util.List<java.lang.String> getAllEvaluationMetricNames()
public Instances getHeader()
public void setDiscardPredictions(boolean value)
value
- true if to discard the predictionspredictions()
public boolean getDiscardPredictions()
predictions()
public java.util.List<AbstractEvaluationMetric> getPluginMetrics()
public void setMetricsToDisplay(java.util.List<java.lang.String> display)
display
- a list of metric names to have appear in the outputpublic java.util.List<java.lang.String> getMetricsToDisplay()
public void toggleEvalMetrics(java.util.List<java.lang.String> metricsToToggle)
metricsToToggle
- a list of metrics to togglepublic AbstractEvaluationMetric getPluginMetric(java.lang.String name)
name
- the name of the metric (as returned by
AbstractEvaluationMetric.getName()) or the fully qualified class
name of the metric to findpublic double areaUnderROC(int classIndex)
classIndex
- the index of the class to consider as "positive"public double weightedAreaUnderROC()
public double areaUnderPRC(int classIndex)
classIndex
- the index of the class to consider as "positive"public double weightedAreaUnderPRC()
public double[][] confusionMatrix()
public void crossValidateModel(Classifier classifier, Instances data, int numFolds, java.util.Random random) throws java.lang.Exception
classifier
- the classifier with any options set.data
- the data on which the cross-validation is to be performednumFolds
- the number of folds for the cross-validationrandom
- random number generator for randomizationjava.lang.Exception
- if a classifier could not be generated successfully or
the class is not definedpublic void crossValidateModel(Classifier classifier, Instances data, int numFolds, java.util.Random random, java.lang.Object... forPrinting) throws java.lang.Exception
classifier
- the classifier with any options set.data
- the data on which the cross-validation is to be performednumFolds
- the number of folds for the cross-validationrandom
- random number generator for randomizationforPrinting
- varargs parameter that, if supplied, is
expected to hold a
weka.classifiers.evaluation.output.prediction.AbstractOutput
object or a StringBuffer for model outputjava.lang.Exception
- if a classifier could not be generated successfully or
the class is not definedpublic void crossValidateModel(java.lang.String classifierString, Instances data, int numFolds, java.lang.String[] options, java.util.Random random) throws java.lang.Exception
classifierString
- a string naming the class of the classifierdata
- the data on which the cross-validation is to be performednumFolds
- the number of folds for the cross-validationoptions
- the options to the classifier. Any optionsrandom
- the random number generator for randomizing the data accepted
by the classifier will be removed from this array.java.lang.Exception
- if a classifier could not be generated successfully or
the class is not definedpublic static java.lang.String evaluateModel(java.lang.String classifierString, java.lang.String[] options) throws java.lang.Exception
Valid options are:
-t filename
Name of the file with the training data. (required)
-T filename
Name of the file with the test data. If missing a cross-validation is
performed.
-c index
Index of the class attribute (1, 2, ...; default: last).
-x number
The number of folds for the cross-validation (default: 10).
-no-cv
No cross validation. If no test file is provided, no evaluation is done.
-split-percentage percentage
Sets the percentage for the train/test set split, e.g., 66.
-preserve-order
Preserves the order in the percentage split instead of randomizing the data
first with the seed value ('-s').
-s seed
Random number seed for the cross-validation and percentage split (default:
1).
-m filename
The name of a file containing a cost matrix.
-l filename
Loads classifier from the given file. In case the filename ends with
".xml",a PMML file is loaded or, if that fails, options are loaded from
XML.
-d filename
Saves classifier built from the training data into the given file. In case
the filename ends with ".xml" the options are saved XML, not the model.
-v
Outputs no statistics for the training data.
-o
Outputs statistics only, not the classifier.
-output-models-for-training-splits
Output models for training splits if cross-validation or percentage-split evaluation is used.
-do-not-output-per-class-statistics
Do not output statistics per class.
-k
Outputs information-theoretic statistics.
-classifications
"weka.classifiers.evaluation.output.prediction.AbstractOutput + options"
Uses the specified class for generating the classification output. E.g.:
weka.classifiers.evaluation.output.prediction.PlainText or :
weka.classifiers.evaluation.output.prediction.CSV
-p range
Outputs predictions for test instances (or the train instances if no test
instances provided and -no-cv is used), along with the attributes in the
specified range (and nothing else). Use '-p 0' if no attributes are
desired.
-distribution
Outputs the distribution instead of only the prediction in conjunction with
the '-p' option (only nominal classes).
-no-predictions
Turns off the collection of predictions in order to conserve memory.
-r
Outputs cumulative margin distribution (and nothing else).
-g
Only for classifiers that implement "Graphable." Outputs the graph
representation of the classifier (and nothing else).
-xml filename | xml-string
Retrieves the options from the XML-data instead of the command line.
-threshold-file file
The file to save the threshold data to. The format is determined by the
extensions, e.g., '.arff' for ARFF format or '.csv' for CSV.
-threshold-label label
The class label to determine the threshold data for (default is the first
label)
classifierString
- class of machine learning classifier as a stringoptions
- the array of string containing the optionsjava.lang.Exception
- if model could not be evaluated successfullypublic static void main(java.lang.String[] args)
args
- an array of command line arguments, the first of which must be
the class name of a classifier.public static java.lang.String evaluateModel(Classifier classifier, java.lang.String[] options) throws java.lang.Exception
classifier
- machine learning classifieroptions
- the array of string containing the optionsjava.lang.Exception
- if model could not be evaluated successfullypublic double[] evaluateModel(Classifier classifier, Instances data, java.lang.Object... forPredictionsPrinting) throws java.lang.Exception
classifier
- machine learning classifierdata
- set of test instances for evaluationforPredictionsPrinting
- varargs parameter that, if supplied, is
expected to hold a
weka.classifiers.evaluation.output.prediction.AbstractOutput
objectjava.lang.Exception
- if model could not be evaluated successfullypublic double evaluationForSingleInstance(double[] dist, Instance instance, boolean storePredictions) throws java.lang.Exception
dist
- the supplied distributioninstance
- the test instance to be classifiedstorePredictions
- whether to store predictions for nominal classifierjava.lang.Exception
- if model could not be evaluated successfullypublic double evaluateModelOnceAndRecordPrediction(Classifier classifier, Instance instance) throws java.lang.Exception
classifier
- machine learning classifierinstance
- the test instance to be classifiedjava.lang.Exception
- if model could not be evaluated successfully or the data
contains string attributespublic double evaluateModelOnce(Classifier classifier, Instance instance) throws java.lang.Exception
classifier
- machine learning classifierinstance
- the test instance to be classifiedjava.lang.Exception
- if model could not be evaluated successfully or the data
contains string attributespublic double evaluateModelOnce(double[] dist, Instance instance) throws java.lang.Exception
dist
- the supplied distributioninstance
- the test instance to be classifiedjava.lang.Exception
- if model could not be evaluated successfullypublic double evaluateModelOnceAndRecordPrediction(double[] dist, Instance instance) throws java.lang.Exception
dist
- the supplied distributioninstance
- the test instance to be classifiedjava.lang.Exception
- if model could not be evaluated successfullypublic void evaluateModelOnce(double prediction, Instance instance) throws java.lang.Exception
prediction
- the supplied predictioninstance
- the test instance to be classifiedjava.lang.Exception
- if model could not be evaluated successfullypublic java.util.ArrayList<Prediction> predictions()
public static java.lang.String wekaStaticWrapper(Sourcable classifier, java.lang.String className) throws java.lang.Exception
classifier
- a Sourcable ClassifierclassName
- the name to give to the source code classjava.lang.Exception
- if code-generation failspublic final double numInstances()
public final double coverageOfTestCasesByPredictedRegions()
public final double sizeOfPredictedRegions()
public final double withClass()
public final double missingClass()
public final double incorrect()
public final double pctIncorrect()
public final double totalCost()
public final double avgCost()
public final double correct()
public final double pctCorrect()
public final double unclassified()
public final double pctUnclassified()
public final double errorRate()
public final double kappa()
public final double correlationCoefficient() throws java.lang.Exception
java.lang.Exception
- if class is not numericpublic final double meanAbsoluteError()
public final double meanPriorAbsoluteError()
public final double relativeAbsoluteError() throws java.lang.Exception
java.lang.Exception
- if it can't be computedpublic final double rootMeanSquaredError()
public final double rootMeanPriorSquaredError()
public final double rootRelativeSquaredError()
public final double priorEntropy()
public final double KBInformation() throws java.lang.Exception
java.lang.Exception
- if the class is not nominalpublic final double KBMeanInformation() throws java.lang.Exception
java.lang.Exception
- if the class is not nominalpublic final double KBRelativeInformation() throws java.lang.Exception
java.lang.Exception
- if the class is not nominalpublic final double SFPriorEntropy()
public final double SFMeanPriorEntropy()
public final double SFSchemeEntropy()
public final double SFMeanSchemeEntropy()
public final double SFEntropyGain()
public final double SFMeanEntropyGain()
public java.lang.String toCumulativeMarginDistributionString() throws java.lang.Exception
java.lang.Exception
- if the class attribute is nominalpublic java.lang.String toSummaryString()
toSummaryString
in interface Summarizable
public java.lang.String toSummaryString(boolean printComplexityStatistics)
printComplexityStatistics
- if true, complexity statistics are
returned as wellpublic java.lang.String toSummaryString(java.lang.String title, boolean printComplexityStatistics)
title
- the title for the statisticsprintComplexityStatistics
- if true, complexity statistics are
returned as wellpublic java.lang.String toMatrixString() throws java.lang.Exception
java.lang.Exception
- if the class is numericpublic java.lang.String toMatrixString(java.lang.String title) throws java.lang.Exception
title
- the title for the confusion matrixjava.lang.Exception
- if the class is numericpublic java.lang.String toClassDetailsString() throws java.lang.Exception
java.lang.Exception
- if class is not nominalpublic java.lang.String toClassDetailsString(java.lang.String title) throws java.lang.Exception
title
- the title to prepend the stats string withjava.lang.Exception
- if class is not nominalpublic double numClassified()
public double numPositives(int classIndex)
classIndex
- the index of the class to consider as "positive"public double numPredictedPositives(int classIndex)
classIndex
- the index of the class to consider as "positive"public double numNegatives(int classIndex)
classIndex
- the index of the class to consider as "positive"public double numPredictedNegatives(int classIndex)
classIndex
- the index of the class to consider as "positive"public double[] trueClassCounts()
public double[] predictedClassCounts()
public double numTruePositives(int classIndex)
correctly classified positivesUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double numFalseNegatives(int classIndex)
incorrectly classified positivesUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double numTrueNegatives(int classIndex)
correctly classified negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"public double numFalsePositives(int classIndex)
incorrectly classified negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"public double truePositiveRate(int classIndex)
correctly classified positives ------------------------------ total positivesThis does not include any instances that are left unclassified by the classifier.
classIndex
- the index of the class to consider as "positive"public double truePositiveRate(int classIndex, double numPositives)
correctly classified positives ------------------------------ total positivesUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"numPositives
- the total number (really, weight) of positives for that classpublic double weightedTruePositiveRate()
public double trueNegativeRate(int classIndex)
correctly classified negatives ------------------------------ total negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"public double trueNegativeRate(int classIndex, double numNegatives)
correctly classified negatives ------------------------------ total negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"numNegatives
- the number (really, weight) of the negative instancespublic double weightedTrueNegativeRate()
public double falsePositiveRate(int classIndex)
incorrectly classified negatives -------------------------------- total negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"public double falsePositiveRate(int classIndex, double numNegatives)
incorrectly classified negatives -------------------------------- total negativesUnclassified instances are not included in the calculation
classIndex
- the index of the class to consider as "positive"numNegatives
- the number (really, weight) of the negative instancespublic double weightedFalsePositiveRate()
public double falseNegativeRate(int classIndex)
incorrectly classified positives -------------------------------- total positivesUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double falseNegativeRate(int classIndex, double numPositives)
incorrectly classified positives -------------------------------- total positivesUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"numPositives
- the number (really, weight) of the instances in the positive classpublic double weightedFalseNegativeRate()
public double matthewsCorrelationCoefficient(int classIndex)
classIndex
- the index of the class to compute the matthews
correlation coefficient for
Unclassified instances are not included in the calculation.public double matthewsCorrelationCoefficient(int classIndex, double numTP, double numTN, double numFP, double numFN)
classIndex
- the index of the class to compute the matthews
correlation coefficient fornumTP
- the number (really, weight) of the true positive instancesnumTN
- the number (really, weight) of the true negative instancesnumFP
- the number (really, weight) of the false positive instancesnumFN
- the number (really, weight) of the false negative instancespublic double weightedMatthewsCorrelation()
public double recall(int classIndex)
correctly classified positives ------------------------------ total positivesThis is the same as the true positive rate. Unclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double weightedRecall()
public double precision(int classIndex)
correctly classified positives ------------------------------ total predicted as positiveUnclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double weightedPrecision()
public double fMeasure(int classIndex)
2 * recall * precision ---------------------- recall + precisionReturns zero when both precision and recall are zero. Unclassified instances are not included in the calculation.
classIndex
- the index of the class to consider as "positive"public double fMeasure(double precision, double recall)
2 * recall * precision ---------------------- recall + precisionReturns zero when both precision and recall are zero. Unclassified instances are not included in the calculation.
precision
- the precisionrecall
- the recallpublic double weightedFMeasure()
public double unweightedMacroFmeasure()
public double unweightedMicroFmeasure()
public void setPriors(Instances train) throws java.lang.Exception
train
- the training instances used to determine the prior
probabilitiesjava.lang.Exception
- if the class attribute of the instances is not setpublic double[] getClassPriors()
public void updatePriors(Instance instance) throws java.lang.Exception
instance
- the new training instance seenjava.lang.Exception
- if the class of the instance is not setpublic void useNoPriors()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare againstpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler