|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectweka.core.Matrix
weka.classifiers.CostMatrix
Class for storing and manipulating a misclassification cost matrix. The element at position i,j in the matrix is the penalty for classifying an instance of class j as class i.
| Field Summary | |
static java.lang.String |
FILE_EXTENSION
The deafult file extension for cost matrix files |
| Constructor Summary | |
CostMatrix(CostMatrix toCopy)
Creates a cost matrix that is a copy of another. |
|
CostMatrix(int numOfClasses)
Creates a default cost matrix of a particular size. |
|
CostMatrix(java.io.Reader reader)
Creates a cost matrix from a reader. |
|
| Method Summary | |
Instances |
applyCostMatrix(Instances data,
java.util.Random random)
Applies the cost matrix to a set of instances. |
double[] |
expectedCosts(double[] classProbs)
Calculates the expected misclassification cost for each possible class value, given class probability estimates. |
double |
getMaxCost(int classVal)
Gets the maximum cost for a particular class value. |
void |
initialize()
Sets the cost of all correct classifications to 0, and all misclassifications to 1. |
void |
normalize()
Normalizes the matrix so that the diagonal contains zeros. |
void |
readOldFormat(java.io.Reader reader)
Loads a cost matrix in the old format from a reader. |
int |
size()
Gets the size of the matrix. |
| Methods inherited from class weka.core.Matrix |
add, addElement, clone, eigenvalueDecomposition, getColumn, getElement, getL, getRow, getU, isSymmetric, LUDecomposition, main, multiply, numColumns, numRows, regression, regression, setColumn, setElement, setRow, solve, testEigen, toString, transpose, write |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static java.lang.String FILE_EXTENSION
| Constructor Detail |
public CostMatrix(CostMatrix toCopy)
toCopy - the matrix to copy.public CostMatrix(int numOfClasses)
numOfClasses - the number of classes that the cost matrix holds.
public CostMatrix(java.io.Reader reader)
throws java.lang.Exception
reader - the reader to get the values from.
java.lang.Exception - if the matrix is invalid.| Method Detail |
public void initialize()
public int size()
public Instances applyCostMatrix(Instances data,
java.util.Random random)
throws java.lang.Exception
data - the instances to reweight.random - a random number generator for resampling, if null then instances are
rewighted.
java.lang.Exception - if the data has no class or the matrix in inappropriate.
public double[] expectedCosts(double[] classProbs)
throws java.lang.Exception
classProbs - the class probability estimates.
java.lang.Exception - if the wrong number of class probabilities is supplied.public double getMaxCost(int classVal)
classVal - the class value.
public void normalize()
public void readOldFormat(java.io.Reader reader)
throws java.lang.Exception
reader - the reader to get the values from.
java.lang.Exception - if the matrix cannot be read correctly.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||