Java Doc for CostMatrix.java in  » Science » weka » weka » classifiers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » weka » weka.classifiers 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   weka.classifiers.CostMatrix

CostMatrix
public class CostMatrix implements Serializable(Code)
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. Cost values can be fixed or computed on a per-instance basis (cost sensitive evaluation only) from the value of an attribute or an expression involving attribute(s).
author:
   Mark Hall
author:
   Richard Kirkby (rkirkby@cs.waikato.ac.nz)
version:
   $Revision: 1.15 $


Field Summary
public static  StringFILE_EXTENSION
    
protected  Object[][]m_matrix
    

Constructor Summary
public  CostMatrix(int numOfClasses)
     Creates a default cost matrix of a particular size.
public  CostMatrix(CostMatrix toCopy)
     Creates a cost matrix that is a copy of another.
public  CostMatrix(Reader reader)
     Reads a matrix from a reader.

Method Summary
public  InstancesapplyCostMatrix(Instances data, Random random)
     Applies the cost matrix to a set of instances.
public  double[]expectedCosts(double[] classProbs)
     Calculates the expected misclassification cost for each possible class value, given class probability estimates.
public  double[]expectedCosts(double[] classProbs, Instance inst)
     Calculates the expected misclassification cost for each possible class value, given class probability estimates.
final public  ObjectgetCell(int rowIndex, int columnIndex)
     Return the contents of a particular cell.
final public  doublegetElement(int rowIndex, int columnIndex)
    
final public  doublegetElement(int rowIndex, int columnIndex, Instance inst)
     Return the value of a cell as a double.
public  doublegetMaxCost(int classVal)
     Gets the maximum cost for a particular class value.
Parameters:
  classVal - the class value.
public  doublegetMaxCost(int classVal, Instance inst)
     Gets the maximum cost for a particular class value.
Parameters:
  classVal - the class value.
public  voidinitialize()
    
public  voidnormalize()
     Normalizes the matrix so that the diagonal contains zeros.
public  intnumColumns()
    
public  intnumRows()
    
public static  MatrixparseMatlab(String matlab)
     creates a matrix from the given Matlab string.
public  voidreadOldFormat(Reader reader)
     Loads a cost matrix in the old format from a reader.
final public  voidsetCell(int rowIndex, int columnIndex, Object value)
    
final public  voidsetElement(int rowIndex, int columnIndex, double value)
    
public  intsize()
    
public  StringtoMatlab()
     converts the Matrix into a single line Matlab string: matrix is enclosed by parentheses, rows are separated by semicolon and single cells by blanks, e.g., [1 2; 3 4].
public  StringtoString()
     Converts a matrix to a string.
public  voidwrite(Writer w)
     Writes out a matrix.

Field Detail
FILE_EXTENSION
public static String FILE_EXTENSION(Code)
The deafult file extension for cost matrix files



m_matrix
protected Object[][] m_matrix(Code)
[rows][columns]




Constructor Detail
CostMatrix
public CostMatrix(int numOfClasses)(Code)
Creates a default cost matrix of a particular size. All diagonal values will be 0 and all non-diagonal values 1.
Parameters:
  numOfClasses - the number of classes that the cost matrix holds.



CostMatrix
public CostMatrix(CostMatrix toCopy)(Code)
Creates a cost matrix that is a copy of another.
Parameters:
  toCopy - the matrix to copy.



CostMatrix
public CostMatrix(Reader reader) throws Exception(Code)
Reads a matrix from a reader. The first line in the file should contain the number of rows and columns. Subsequent lines contain elements of the matrix. (FracPete: taken from old weka.core.Matrix class)
Parameters:
  reader - the reader containing the matrix
throws:
  Exception - if an error occurs
See Also:   CostMatrix.write(Writer)




Method Detail
applyCostMatrix
public Instances applyCostMatrix(Instances data, Random random) throws Exception(Code)
Applies the cost matrix to a set of instances. If a random number generator is supplied the instances will be resampled, otherwise they will be rewighted. Adapted from code once sitting in Instances.java
Parameters:
  data - the instances to reweight.
Parameters:
  random - a random number generator for resampling, if null then instances arerewighted. a new dataset reflecting the cost of misclassification.
exception:
  Exception - if the data has no class or the matrix in inappropriate.



expectedCosts
public double[] expectedCosts(double[] classProbs) throws Exception(Code)
Calculates the expected misclassification cost for each possible class value, given class probability estimates.
Parameters:
  classProbs - the class probability estimates. the expected costs.
exception:
  Exception - if the wrong number of class probabilities is supplied.



expectedCosts
public double[] expectedCosts(double[] classProbs, Instance inst) throws Exception(Code)
Calculates the expected misclassification cost for each possible class value, given class probability estimates.
Parameters:
  classProbs - the class probability estimates.
Parameters:
  inst - the current instance for which the class probabilitesapply. Is used for computing any non-fixed cost values. the expected costs.
exception:
  Exception - if something goes wrong



getCell
final public Object getCell(int rowIndex, int columnIndex)(Code)
Return the contents of a particular cell. Note: this method returns the Object stored at a particular cell.
Parameters:
  rowIndex - the row
Parameters:
  columnIndex - the column the value at the cell



getElement
final public double getElement(int rowIndex, int columnIndex) throws Exception(Code)
Return the value of a cell as a double (for legacy code)
Parameters:
  rowIndex - the row
Parameters:
  columnIndex - the column the value at a particular cell as a double
exception:
  Exception - if the value is not a double



getElement
final public double getElement(int rowIndex, int columnIndex, Instance inst) throws Exception(Code)
Return the value of a cell as a double. Computes the value for non-fixed costs using the supplied Instance
Parameters:
  rowIndex - the row
Parameters:
  columnIndex - the column the value from a particular cell
exception:
  Exception - if something goes wrong



getMaxCost
public double getMaxCost(int classVal) throws Exception(Code)
Gets the maximum cost for a particular class value.
Parameters:
  classVal - the class value. the maximum cost.
exception:
  Exception - if cost matrix contains non-fixedcosts



getMaxCost
public double getMaxCost(int classVal, Instance inst) throws Exception(Code)
Gets the maximum cost for a particular class value.
Parameters:
  classVal - the class value. the maximum cost.
exception:
  Exception - if cost matrix contains non-fixedcosts



initialize
public void initialize()(Code)
Initializes the matrix



normalize
public void normalize()(Code)
Normalizes the matrix so that the diagonal contains zeros.



numColumns
public int numColumns()(Code)
Same as size the number of columns



numRows
public int numRows()(Code)
Same as size the number of rows



parseMatlab
public static Matrix parseMatlab(String matlab) throws Exception(Code)
creates a matrix from the given Matlab string.
Parameters:
  matlab - the matrix in matlab format the matrix represented by the given string



readOldFormat
public void readOldFormat(Reader reader) throws Exception(Code)
Loads a cost matrix in the old format from a reader. Adapted from code once sitting in Instances.java
Parameters:
  reader - the reader to get the values from.
exception:
  Exception - if the matrix cannot be read correctly.



setCell
final public void setCell(int rowIndex, int columnIndex, Object value)(Code)
Set the value of a particular cell in the matrix
Parameters:
  rowIndex - the row
Parameters:
  columnIndex - the column
Parameters:
  value - the value to set



setElement
final public void setElement(int rowIndex, int columnIndex, double value)(Code)
Set the value of a cell as a double
Parameters:
  rowIndex - the row
Parameters:
  columnIndex - the column
Parameters:
  value - the value (double) to set



size
public int size()(Code)
The number of rows (and columns) the size of the matrix



toMatlab
public String toMatlab()(Code)
converts the Matrix into a single line Matlab string: matrix is enclosed by parentheses, rows are separated by semicolon and single cells by blanks, e.g., [1 2; 3 4]. the matrix in Matlab single line format



toString
public String toString()(Code)
Converts a matrix to a string. (FracPete: taken from old weka.core.Matrix class) the converted string



write
public void write(Writer w) throws Exception(Code)
Writes out a matrix. The format can be read via the CostMatrix(Reader) constructor. (FracPete: taken from old weka.core.Matrix class)
Parameters:
  w - the output Writer
throws:
  Exception - if an error occurs



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.