Oracle Data Mining Java API Reference
10g Release 1 (10.1)

B12276-01

oracle.dmt.odm
Class CostMatrix

java.lang.Object
  |
  +--oracle.dmt.odm.MiningObject
        |
        +--oracle.dmt.odm.CategoryMatrix
              |
              +--oracle.dmt.odm.CostMatrix
All Implemented Interfaces:
java.io.Serializable

public class CostMatrix
extends CategoryMatrix

Cost Matrix is used in a classification problem. It enables the user to let the algorithm know what the relative values of the various classes are to the user.

For example, suppose the problem is to predict whether a user will respond to a promotional mailing. The target has two classes: YES and NO. Suppose a positive response to the promotion generates $500 and the Category of the promotion is $5. Then the Category of misclassify a positive responder is $500. The Cost of misclassify a non-responder is $5.

The Cost matrix looks like

Actual/Predicted Predicted Yes Predicted No
Actual Yes 0 5
Actual No 500 0

From the above matrix table, we can see that (Category row, Category column) will have the following Cost Matrix values:

Cost Matrix of (Actual Yes, Predicted Yes) = 0
Cost Matrix of (Actual Yes, Predicted No) = 5.00
Cost Matrix of (Actual No, Predicted Yes) = 500.00
Cost Matrix of (Actual No, Predicted No) = 0

Some algorithms directly optimize for the Cost Matrix, modifying the model structure so as to directly produce minimal cost solutions. Other algorithms, like NB, that will predict probabilities, use the Cost Matrix during scoring to propose the least cost solution:

For example, suppose a model with the above cost matrix predicts a probability of YES of .05. Then the cost of predicting YES is 0.95 * $5 = $4.75 Whereas the cost of predicting no is:05 * $500 = $25. So the recommendation would be to send the promotion since the cost of sending out promotion is must less than the cost of not sending out promotion.

The default value of Cost Matrix will be a cost of missing an expected result

Since:
10.1.0
See Also:
Serialized Form

Constructor Summary
CostMatrix()
          Creates an empty instance of CostMatrix.

 

Method Summary
 void addEntry(Category rowValue, Category columnValue, java.lang.Object value)
          Adds a new entry to the cost matrix.
 void validate()
          Validates the cost matrix to ensure all entries have a valid value and all diagonal entries have a zero value.

 

Methods inherited from class oracle.dmt.odm.CategoryMatrix
addEntry, getDiagonalDefault, getOffDiagonalDefault, getValue, getValue, isPresent, listCategories, listColumnDisplayNames, listColumnValues, listDisplayNames, listRowDisplayNames, listRowValues, sumAllCells, sumForColumn, sumForRow, toString

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

CostMatrix

public CostMatrix()
Creates an empty instance of CostMatrix.
Method Detail

addEntry

public void addEntry(Category rowValue,
Category columnValue,
                     java.lang.Object value)
              throws ODMException
Adds a new entry to the cost matrix.
Throws:
ODMException -
  • when rowValue or columnValue is null,
  • when value is negative,
  • when rowValue and columnValue do not have the same data type,
  • when all row categories do not have the same data type,
  • when all column categories do not have the same data type, or
  • when A duplicated entry is being added.

validate

public void validate()
              throws ODMException
Validates the cost matrix to ensure all entries have a valid value and all diagonal entries have a zero value.
Overrides:
validate in class CategoryMatrix
Throws:
ODMException -
  • when a value is null,
  • when the object is invalid,
  • when a value is negative, or
  • when a diagonal value is not 0.

Copyright © 2003 Oracle Corporation. All Rights Reserved.