Package weka.classifiers.evaluation
Class ConfusionMatrix
java.lang.Object
weka.core.matrix.Matrix
weka.classifiers.evaluation.ConfusionMatrix
- All Implemented Interfaces:
- Serializable,- Cloneable,- RevisionHandler
Cells of this matrix correspond to counts of the number (or weight) of
 predictions for each actual value / predicted value combination.
- Version:
- $Revision: 10169 $
- Author:
- Len Trigg (len@reeltwo.com)
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConfusionMatrix(String[] classNames) Creates the confusion matrix with the given class names.
- 
Method SummaryModifier and TypeMethodDescriptionvoidIncludes a prediction in the confusion matrix.voidaddPredictions(ArrayList<Prediction> predictions) Includes a whole bunch of predictions in the confusion matrix.className(int index) Gets the name of one of the classes.clone()Creates and returns a clone of this object.doublecorrect()Gets the number of correct classifications (that is, for which a correct prediction was made).doubleReturns the estimated error rate.Returns the revision string.getTwoClassStats(int classIndex) Gets the performance with respect to one of the classes as a TwoClassStats object.doubleGets the number of incorrect classifications (that is, for which an incorrect prediction was made).makeWeighted(CostMatrix costs) Makes a copy of this ConfusionMatrix after applying the supplied CostMatrix to the cells.intsize()Gets the number of classes.toString()Calls toString() with a default title.Outputs the performance statistics as a classification confusion matrix.doubletotal()Gets the number of predictions that were made (actually the sum of the weights of predictions where the class value was known).Methods inherited from class weka.core.matrix.MatrixarrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, chol, cond, constructWithCopy, copy, det, eig, get, getArray, getArrayCopy, getColumnDimension, getColumnPackedCopy, getMatrix, getMatrix, getMatrix, getMatrix, getRowDimension, getRowPackedCopy, identity, inverse, isSquare, isSymmetric, lu, main, minus, minusEquals, norm1, norm2, normF, normInf, parseMatlab, plus, plusEquals, print, print, print, print, qr, random, rank, read, regression, regression, set, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, sqrt, svd, times, times, timesEquals, toMatlab, trace, transpose, uminus, write
- 
Constructor Details- 
ConfusionMatrixCreates the confusion matrix with the given class names.- Parameters:
- classNames- an array containing the names the classes.
 
 
- 
- 
Method Details- 
makeWeightedMakes a copy of this ConfusionMatrix after applying the supplied CostMatrix to the cells. The resulting ConfusionMatrix can be used to get cost-weighted statistics.- Parameters:
- costs- the CostMatrix.
- Returns:
- a ConfusionMatrix that has had costs applied.
- Throws:
- Exception- if the CostMatrix is not of the same size as this ConfusionMatrix.
 
- 
cloneCreates and returns a clone of this object.
- 
sizepublic int size()Gets the number of classes.- Returns:
- the number of classes
 
- 
classNameGets the name of one of the classes.- Parameters:
- index- the index of the class.
- Returns:
- the class name.
 
- 
addPredictionIncludes a prediction in the confusion matrix.- Parameters:
- pred- the NominalPrediction to include
- Throws:
- Exception- if no valid prediction was made (i.e. unclassified).
 
- 
addPredictionsIncludes a whole bunch of predictions in the confusion matrix.- Parameters:
- predictions- a FastVector containing the NominalPredictions to include
- Throws:
- Exception- if no valid prediction was made (i.e. unclassified).
 
- 
getTwoClassStatsGets the performance with respect to one of the classes as a TwoClassStats object.- Parameters:
- classIndex- the index of the class of interest.
- Returns:
- the generated TwoClassStats object.
 
- 
correctpublic double correct()Gets the number of correct classifications (that is, for which a correct prediction was made). (Actually the sum of the weights of these classifications)- Returns:
- the number of correct classifications
 
- 
incorrectpublic double incorrect()Gets the number of incorrect classifications (that is, for which an incorrect prediction was made). (Actually the sum of the weights of these classifications)- Returns:
- the number of incorrect classifications
 
- 
totalpublic double total()Gets the number of predictions that were made (actually the sum of the weights of predictions where the class value was known).- Returns:
- the number of predictions with known class
 
- 
errorRatepublic double errorRate()Returns the estimated error rate.- Returns:
- the estimated error rate (between 0 and 1).
 
- 
toStringCalls toString() with a default title.
- 
toStringOutputs the performance statistics as a classification confusion matrix. For each class value, shows the distribution of predicted class values.- Parameters:
- title- the title for the confusion matrix
- Returns:
- the confusion matrix as a String
 
- 
getRevisionReturns the revision string.- Specified by:
- getRevisionin interface- RevisionHandler
- Overrides:
- getRevisionin class- Matrix
- Returns:
- the revision
 
 
-