📄 costmatrix.html
字号:
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Field Detail</B></FONT></TD></TR></TABLE><A NAME="FILE_EXTENSION"><!-- --></A><H3>FILE_EXTENSION</H3><PRE>public static java.lang.String <B>FILE_EXTENSION</B></PRE><DL><DD>The filename extension that should be used for cost files</DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="CostMatrix(weka.classifiers.CostMatrix)"><!-- --></A><H3>CostMatrix</H3><PRE>public <B>CostMatrix</B>(<A HREF="../../weka/classifiers/CostMatrix.html">CostMatrix</A> toCopy)</PRE><DL><DD>Creates a cost matrix identical to an existing matrix.<DD><DL><DT><B>Parameters:</B><DD><CODE>toCopy</CODE> - the matrix to copy.</DL></DD></DL><HR><A NAME="CostMatrix(int)"><!-- --></A><H3>CostMatrix</H3><PRE>public <B>CostMatrix</B>(int numClasses)</PRE><DL><DD>Creates a default cost matrix for the given number of classes. The default misclassification cost is 1.<DD><DL><DT><B>Parameters:</B><DD><CODE>numClasses</CODE> - the number of classes</DL></DD></DL><HR><A NAME="CostMatrix(java.io.Reader)"><!-- --></A><H3>CostMatrix</H3><PRE>public <B>CostMatrix</B>(java.io.Reader r) throws java.lang.Exception</PRE><DL><DD>Creates a cost matrix from a cost file.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - a reader from which the cost matrix will be read<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if an error occurs</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="makeFrequencyDependentMatrix(weka.core.Instances, double)"><!-- --></A><H3>makeFrequencyDependentMatrix</H3><PRE>public static <A HREF="../../weka/classifiers/CostMatrix.html">CostMatrix</A> <B>makeFrequencyDependentMatrix</B>(<A HREF="../../weka/core/Instances.html">Instances</A> instances, double weight) throws java.lang.Exception</PRE><DL><DD>Creates a cost matrix for the class attribute of the supplied instances, where the misclassification costs are higher for misclassifying a rare class as a frequent one. The cost of classifying an instance of class i as class j is weight * Pj / Pi. (Pi and Pj are laplace estimates)<DD><DL><DT><B>Parameters:</B><DD><CODE>instances</CODE> - a value of type 'Instances'<DD><CODE>weight</CODE> - a value of type 'double'<DT><B>Returns:</B><DD>a value of type CostMatrix<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if no class attribute is assigned, or the class attribute is not nominal</DL></DD></DL><HR><A NAME="readOldFormat(java.io.Reader)"><!-- --></A><H3>readOldFormat</H3><PRE>public void <B>readOldFormat</B>(java.io.Reader reader) throws java.lang.Exception</PRE><DL><DD>Reads misclassification cost matrix from given reader. Each line has to contain three numbers: the index of the true class, the index of the incorrectly assigned class, and the weight, separated by white space characters. Comments can be appended to the end of a line by using the '%' character.<DD><DL><DT><B>Parameters:</B><DD><CODE>reader</CODE> - the reader from which the cost matrix is to be read<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the cost matrix does not have the right format</DL></DD></DL><HR><A NAME="initialize()"><!-- --></A><H3>initialize</H3><PRE>public void <B>initialize</B>()</PRE><DL><DD>Sets the costs to default values (i.e. 0 down the diagonal, and 1 for any misclassification).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../weka/core/Matrix.html#initialize()">initialize</A></CODE> in class <CODE><A HREF="../../weka/core/Matrix.html">Matrix</A></CODE></DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public int <B>size</B>()</PRE><DL><DD>Gets the number of classes.<DD><DL><DT><B>Returns:</B><DD>the number of classes</DL></DD></DL><HR><A NAME="normalize()"><!-- --></A><H3>normalize</H3><PRE>public void <B>normalize</B>()</PRE><DL><DD>Normalizes the cost matrix so that diagonal elements are zero. The value of non-zero diagonal elements is subtracted from the row containing the value. For example: <p> <pre><code> 2 5 3 -1 </code></pre> <p> becomes <p> <pre><code> 0 3 4 0 </code></pre><p> This normalization will affect total classification cost during evaluation, but will not affect the decision made by applying minimum expected cost criteria during prediction.</DL><HR><A NAME="applyCostMatrix(weka.core.Instances, java.util.Random)"><!-- --></A><H3>applyCostMatrix</H3><PRE>public <A HREF="../../weka/core/Instances.html">Instances</A> <B>applyCostMatrix</B>(<A HREF="../../weka/core/Instances.html">Instances</A> instances, java.util.Random random) throws java.lang.Exception</PRE><DL><DD>Changes the dataset to reflect a given set of costs. Sets the weights of instances according to the misclassification cost matrix, or does resampling according to the cost matrix (if a random number generator is provided). Returns a new dataset.<DD><DL><DT><B>Parameters:</B><DD><CODE>instances</CODE> - the instances to apply cost weights to.<DD><CODE>random</CODE> - a random number generator<DT><B>Returns:</B><DD>the new dataset<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the cost matrix does not have the right format</DL></DD></DL><HR><A NAME="expectedCosts(double[])"><!-- --></A><H3>expectedCosts</H3><PRE>public double[] <B>expectedCosts</B>(double[] probabilities) throws java.lang.Exception</PRE><DL><DD>Calculates the expected misclassification cost for each possible class value, given class probability estimates.<DD><DL><DT><B>Parameters:</B><DD><CODE>probabilities</CODE> - an array containing probability estimates for each class value.<DT><B>Returns:</B><DD>an array containing the expected misclassification cost for each class.<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the number of probabilities does not match the number of classes.</DL></DD></DL><HR><A NAME="getMaxCost(int)"><!-- --></A><H3>getMaxCost</H3><PRE>public double <B>getMaxCost</B>(int actualClass)</PRE><DL><DD>Gets the maximum misclassification cost possible for a given actual class value<DD><DL><DT><B>Parameters:</B><DD><CODE>actualClass</CODE> - the index of the actual class value<DT><B>Returns:</B><DD>the highest cost possible for misclassifying this class</DL></DD></DL><HR><A NAME="main(java.lang.String[])"><!-- --></A><H3>main</H3><PRE>public static void <B>main</B>(java.lang.String[] args)</PRE><DL><DD>Tests out creation of a frequency dependent cost matrix from the command line. Either pipe a set of instances into system.in or give the name of a dataset as an argument. The last column will be treated as the class attribute and a cost matrix with weight 1000 output.<DD><DL><DT><B>Parameters:</B><DD><CODE>[]args</CODE> - a value of type 'String'</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../weka/classifiers/Classifier.html"><B>PREV CLASS</B></A> <A HREF="../../weka/classifiers/CostSensitiveClassifier.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="CostMatrix.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -