jrip.html

来自「由java开发的软件包」· HTML 代码 · 共 1,169 行 · 第 1/3 页

HTML
1,169
字号
<!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:34 NZDT 2005 --><TITLE>JRip</TITLE><META NAME="keywords" CONTENT="weka.classifiers.rules.JRip class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="JRip";}</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>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../Tutorial.pdf"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</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>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../weka/classifiers/rules/DecisionTable.LinkedList.html" title="class in weka.classifiers.rules"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../weka/classifiers/rules/M5Rules.html" title="class in weka.classifiers.rules"><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>  &nbsp;&nbsp;<A HREF="JRip.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<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:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<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.classifiers.rules</FONT><BR>Class JRip</H2><PRE>java.lang.Object  <IMG SRC="../../../resources/inherit.gif" ALT="extended by"><A HREF="../../../weka/classifiers/Classifier.html" title="class in weka.classifiers">weka.classifiers.Classifier</A>      <IMG SRC="../../../resources/inherit.gif" ALT="extended by"><B>weka.classifiers.rules.JRip</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../weka/core/AdditionalMeasureProducer.html" title="interface in weka.core">AdditionalMeasureProducer</A>, java.lang.Cloneable, <A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, java.io.Serializable, <A HREF="../../../weka/core/WeightedInstancesHandler.html" title="interface in weka.core">WeightedInstancesHandler</A></DD></DL><HR><DL><DT>public class <B>JRip</B><DT>extends <A HREF="../../../weka/classifiers/Classifier.html" title="class in weka.classifiers">Classifier</A><DT>implements <A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, <A HREF="../../../weka/core/AdditionalMeasureProducer.html" title="interface in weka.core">AdditionalMeasureProducer</A>, <A HREF="../../../weka/core/WeightedInstancesHandler.html" title="interface in weka.core">WeightedInstancesHandler</A></DL><P>This class implements a propositional rule learner, Repeated Incremental Pruning to Produce Error Reduction (RIPPER), which is proposed by William W. Cohen as an optimized version of IREP. <p>  The algorithm is briefly described as follows: <p> Initialize RS = {}, and for each class from the less prevalent one to  the more frequent one, DO: <p> 1. Building stage: repeat 1.1 and 1.2 until the descrition length (DL)    of the ruleset and examples is 64 bits greater than the smallest DL    met so far, or there are no positive examples, or the error rate >= 50%.     <p> 1.1. Grow phase:<br>      Grow one rule by greedily adding antecedents (or conditions) to      the rule until the rule is perfect (i.e. 100% accurate).  The      procedure tries every possible value of each attribute and selects      the condition with highest information gain: p(log(p/t)-log(P/T)).      <p> 1.2. Prune phase:<br>      Incrementally prune each rule and allow the pruning of any      final sequences of the antecedents;<br>      The pruning metric is (p-n)/(p+n) -- but it's actually       2p/(p+n) -1, so in this implementation we simply use p/(p+n)      (actually (p+1)/(p+n+2), thus if p+n is 0, it's 0.5).<p> 2. Optimization stage: after generating the initial ruleset {Ri},     generate and prune two variants of each rule Ri from randomized data    using procedure 1.1 and 1.2.  But one variant is generated from an     empty rule while the other is generated by greedily adding antecedents    to the original rule.  Moreover, the pruning metric used here is     (TP+TN)/(P+N).<br>    Then the smallest possible DL for each variant and the original rule    is computed.  The variant with the minimal DL is selected as the final     representative of Ri in the ruleset. <br>    After all the rules in {Ri} have been examined and if there are still    residual positives, more rules are generated based on the residual     positives using Building Stage again. <p> 3. Delete the rules from the ruleset that would increase the DL of the    whole ruleset if it were in it. and add resultant ruleset to RS. <p>  ENDDO<p> Note that there seem to be 2 bugs in the ripper program that would affect the ruleset size and accuracy slightly.  This implementation avoids these bugs and thus is a little bit different from Cohen's original  implementation.  Even after fixing the bugs, since the order of classes with the same frequency is not defined in ripper, there still seems to be  some trivial difference between this implementation and the original ripper, especially for audiology data in UCI repository, where there are lots of classes of few instances.<p> If wrapped by other classes, typical usage of this class is:<br> <code>JRip rip = new JRip(); Instances data = ... // Data from somewhere double[] orderedClasses = ... // Get the ordered class counts for the data  double expFPRate = ... // Calculate the expected FP/(FP+FN) rate double classIndex = ...  // The class index for which ruleset is built // DL of default rule, no theory DL, only data DL double defDL = RuleStats.dataDL(expFPRate, 0.0, data.sumOfWeights(),				   0.0, orderedClasses[(int)classIndex]);	     rip.rulesetForOneClass(expFPRate, data, classIndex, defDL);  RuleStats rulesetStats = rip.getRuleStats(0); // Can get heaps of information from RuleStats, e.g. combined DL,  // simpleStats, etc. double comDL = rulesetStats.combinedDL(expFPRate, classIndex); int whichRule = ... // Want simple stats of which rule? double[] simpleStats = rulesetStats.getSimpleStats(whichRule); ... </code> Details please see "Fast Effective Rule Induction", William W. Cohen,  'Machine Learning: Proceedings of the Twelfth International Conference' (ML95). <p> PS.  We have compared this implementation with the original ripper  implementation in aspects of accuracy, ruleset size and running time  on both artificial data "ab+bcd+defg" and UCI datasets.  In all these aspects it seems to be quite comparable to the original ripper  implementation.  However, we didn't consider memory consumption optimization in this implementation.<p><P><P><DL><DT><B>Version:</B></DT>  <DD>$Revision: 1.14 $</DD><DT><B>Author:</B></DT>  <DD>Xin Xu (xx5@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz)</DD><DT><B>See Also:</B><DD><A HREF="../../../serialized-form.html#weka.classifiers.rules.JRip">Serialized Form</A></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== 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/classifiers/rules/JRip.html#JRip()">JRip</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TABLE>&nbsp;<!-- ========== 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>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#buildClassifier(weka.core.Instances)">buildClassifier</A></B>(<A HREF="../../../weka/core/Instances.html" title="class in weka.core">Instances</A>&nbsp;instances)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Builds Ripper in the order of class frequencies.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#checkErrorRateTipText()">checkErrorRateTipText</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the tip text for this property</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#debugTipText()">debugTipText</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the tip text for this property</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;double[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#distributionForInstance(weka.core.Instance)">distributionForInstance</A></B>(<A HREF="../../../weka/core/Instance.html" title="class in weka.core">Instance</A>&nbsp;datum)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Classify the test instance with the rule learner and provide the class distributions</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#enumerateMeasures()">enumerateMeasures</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an enumeration of the additional measure names</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#foldsTipText()">foldsTipText</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the tip text for this property</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getCheckErrorRate()">getCheckErrorRate</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getDebug()">getDebug</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get whether debugging is turned on.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getFolds()">getFolds</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;double</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getMeasure(java.lang.String)">getMeasure</A></B>(java.lang.String&nbsp;additionalMeasureName)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the named measure</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;double</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getMinNo()">getMinNo</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getOptimizations()">getOptimizations</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getOptions()">getOptions</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the current settings of the Classifier.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../weka/core/FastVector.html" title="class in weka.core">FastVector</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getRuleset()">getRuleset</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the ruleset generated by Ripper</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../weka/classifiers/rules/RuleStats.html" title="class in weka.classifiers.rules">RuleStats</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getRuleStats(int)">getRuleStats</A></B>(int&nbsp;pos)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the statistics of the ruleset in the given position</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;long</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getSeed()">getSeed</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#getUsePruning()">getUsePruning</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#globalInfo()">globalInfo</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a string describing classifier</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#listOptions()">listOptions</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an enumeration describing the available options Valid options are: </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../weka/classifiers/rules/JRip.html#main(java.lang.String[])">main</A></B>(java.lang.String[]&nbsp;args)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Main method.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.lang.String</CODE></FONT></TD>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?