NoSplit.java
Upload User: rhdiban
Upload Date: 2013-08-09
Package Size: 15085k
Code Size: 3k
Category:

Windows Develop

Development Platform:

Java

  1. /*
  2.  *    This program is free software; you can redistribute it and/or modify
  3.  *    it under the terms of the GNU General Public License as published by
  4.  *    the Free Software Foundation; either version 2 of the License, or
  5.  *    (at your option) any later version.
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  *    GNU General Public License for more details.
  11.  *
  12.  *    You should have received a copy of the GNU General Public License
  13.  *    along with this program; if not, write to the Free Software
  14.  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  */
  16. /*
  17.  *    NoSplit.java
  18.  *    Copyright (C) 1999 Eibe Frank
  19.  *
  20.  */
  21. package weka.classifiers.j48;
  22. import weka.core.*;
  23. /**
  24.  * Class implementing a "no-split"-split.
  25.  *
  26.  * @author Eibe Frank (eibe@cs.waikato.ac.nz)
  27.  * @version $Revision: 1.5 $
  28.  */
  29. public final class NoSplit extends ClassifierSplitModel{
  30.   /**
  31.    * Creates "no-split"-split for given distribution.
  32.    */
  33.   public NoSplit(Distribution distribution){
  34.     
  35.     m_distribution = new Distribution(distribution);
  36.     m_numSubsets = 1;
  37.   }
  38.   
  39.   /**
  40.    * Creates a "no-split"-split for a given set of instances.
  41.    *
  42.    * @exception Exception if split can't be built successfully
  43.    */
  44.   public final void buildClassifier(Instances instances) 
  45.        throws Exception {
  46.     m_distribution = new Distribution(instances);
  47.     m_numSubsets = 1;
  48.   }
  49.   /**
  50.    * Always returns 0 because only there is only one subset.
  51.    */
  52.   public final int whichSubset(Instance instance){
  53.     
  54.     return 0;
  55.   }
  56.   /**
  57.    * Always returns null because there is only one subset.
  58.    */
  59.   public final double [] weights(Instance instance){
  60.     return null;
  61.   }
  62.   
  63.   /**
  64.    * Does nothing because no condition has to be satisfied.
  65.    */
  66.   public final String leftSide(Instances instances){
  67.     return "";
  68.   }
  69.   
  70.   /**
  71.    * Does nothing because no condition has to be satisfied.
  72.    */
  73.   public final String rightSide(int index, Instances instances){
  74.     return "";
  75.   }
  76.   /**
  77.    * Returns a string containing java source code equivalent to the test
  78.    * made at this node. The instance being tested is called "i".
  79.    *
  80.    * @param index index of the nominal value tested
  81.    * @param data the data containing instance structure info
  82.    * @return a value of type 'String'
  83.    */
  84.   public final String sourceExpression(int index, Instances data) {
  85.     return "true";  // or should this be false??
  86.   }  
  87. }