📄 utils.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_05) on Mon Mar 07 15:27:48 NZDT 2005 --><TITLE>Utils</TITLE><META NAME="keywords" CONTENT="weka.core.Utils class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="Utils";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <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="../../../Tutorial.pdf"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="http://www.cs.waikato.ac.nz/ml/weka/index.html"><FONT CLASS="NavBarFont1"><B>Weka's home</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/core/Tag.html" title="class in weka.core"><B>PREV CLASS</B></A> <A HREF="../../weka/core/Version.html" title="class in weka.core"><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="Utils.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <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><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">weka.core</FONT><BR>Class Utils</H2><PRE>java.lang.Object <IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>weka.core.Utils</B></PRE><HR><DL><DT>public final class <B>Utils</B><DT>extends java.lang.Object</DL><P>Class implementing some simple utility methods.<P><P><DL><DT><B>Version:</B></DT> <DD>$Revision: 1.44 $</DD><DT><B>Author:</B></DT> <DD>Eibe Frank, Yong Wang, Len Trigg, Julien Prados</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#log2">log2</A></B></CODE><BR> The natural logarithm of 2.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#SMALL">SMALL</A></B></CODE><BR> The small deviation allowed in double comparisons</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../weka/core/Utils.html#Utils()">Utils</A></B>()</CODE><BR> </TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#backQuoteChars(java.lang.String)">backQuoteChars</A></B>(java.lang.String string)</CODE><BR> Converts carriage returns and new lines in a string into \r and \n.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#checkForRemainingOptions(java.lang.String[])">checkForRemainingOptions</A></B>(java.lang.String[] options)</CODE><BR> Checks if the given array contains any non-empty options.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#convertNewLines(java.lang.String)">convertNewLines</A></B>(java.lang.String string)</CODE><BR> Converts carriage returns and new lines in a string into \r and \n.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#correlation(double[], double[], int)">correlation</A></B>(double[] y1, double[] y2, int n)</CODE><BR> Returns the correlation coefficient of two double vectors.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#doubleToString(double, int)">doubleToString</A></B>(double value, int afterDecimalPoint)</CODE><BR> Rounds a double and converts it into String.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#doubleToString(double, int, int)">doubleToString</A></B>(double value, int width, int afterDecimalPoint)</CODE><BR> Rounds a double and converts it into a formatted decimal-justified String.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#eq(double, double)">eq</A></B>(double a, double b)</CODE><BR> Tests if a is equal to b.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#forName(java.lang.Class, java.lang.String, java.lang.String[])">forName</A></B>(java.lang.Class classType, java.lang.String className, java.lang.String[] options)</CODE><BR> Creates a new instance of an object given it's class name and (optional) arguments to pass to it's setOptions method.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#getFlag(char, java.lang.String[])">getFlag</A></B>(char flag, java.lang.String[] options)</CODE><BR> Checks if the given array contains the flag "-Char".</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#getFlag(java.lang.String, java.lang.String[])">getFlag</A></B>(java.lang.String flag, java.lang.String[] options)</CODE><BR> Checks if the given array contains the flag "-String".</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#getOption(char, java.lang.String[])">getOption</A></B>(char flag, java.lang.String[] options)</CODE><BR> Gets an option indicated by a flag "-Char" from the given array of strings.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#getOption(java.lang.String, java.lang.String[])">getOption</A></B>(java.lang.String flag, java.lang.String[] options)</CODE><BR> Gets an option indicated by a flag "-String" from the given array of strings.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#gr(double, double)">gr</A></B>(double a, double b)</CODE><BR> Tests if a is smaller than b.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#grOrEq(double, double)">grOrEq</A></B>(double a, double b)</CODE><BR> Tests if a is greater or equal to b.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#info(int[])">info</A></B>(int[] counts)</CODE><BR> Computes entropy for an array of integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#joinOptions(java.lang.String[])">joinOptions</A></B>(java.lang.String[] optionArray)</CODE><BR> Joins all the options in an option array into a single string, as might be used on the command line.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#log2(double)">log2</A></B>(double a)</CODE><BR> Returns the logarithm of a for base 2.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#logs2probs(double[])">logs2probs</A></B>(double[] a)</CODE><BR> Converts an array containing the natural logarithms of probabilities stored in a vector back into probabilities.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#main(java.lang.String[])">main</A></B>(java.lang.String[] ops)</CODE><BR> Main method for testing this class.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#maxIndex(double[])">maxIndex</A></B>(double[] doubles)</CODE><BR> Returns index of maximum element in a given array of doubles.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#maxIndex(int[])">maxIndex</A></B>(int[] ints)</CODE><BR> Returns index of maximum element in a given array of integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static double</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#mean(double[])">mean</A></B>(double[] vector)</CODE><BR> Computes the mean for an array of doubles.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#minIndex(double[])">minIndex</A></B>(double[] doubles)</CODE><BR> Returns index of minimum element in a given array of doubles.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../weka/core/Utils.html#minIndex(int[])">minIndex</A></B>(int[] ints)</CODE><BR> Returns index of minimum element in a given array of integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -