source: src/main/java/weka/classifiers/trees/j48/NoSplit.java @ 19

Last change on this file since 19 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 2.9 KB
Line 
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/*
18 *    NoSplit.java
19 *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.classifiers.trees.j48;
24
25import weka.core.Instance;
26import weka.core.Instances;
27import weka.core.RevisionUtils;
28
29/**
30 * Class implementing a "no-split"-split.
31 *
32 * @author Eibe Frank (eibe@cs.waikato.ac.nz)
33 * @version $Revision: 1.9 $
34 */
35public final class NoSplit
36  extends ClassifierSplitModel{
37
38  /** for serialization */
39  private static final long serialVersionUID = -1292620749331337546L;
40
41  /**
42   * Creates "no-split"-split for given distribution.
43   */
44  public NoSplit(Distribution distribution){
45   
46    m_distribution = new Distribution(distribution);
47    m_numSubsets = 1;
48  }
49 
50  /**
51   * Creates a "no-split"-split for a given set of instances.
52   *
53   * @exception Exception if split can't be built successfully
54   */
55  public final void buildClassifier(Instances instances) 
56       throws Exception {
57
58    m_distribution = new Distribution(instances);
59    m_numSubsets = 1;
60  }
61
62  /**
63   * Always returns 0 because only there is only one subset.
64   */
65  public final int whichSubset(Instance instance){
66   
67    return 0;
68  }
69
70  /**
71   * Always returns null because there is only one subset.
72   */
73  public final double [] weights(Instance instance){
74
75    return null;
76  }
77 
78  /**
79   * Does nothing because no condition has to be satisfied.
80   */
81  public final String leftSide(Instances instances){
82
83    return "";
84  }
85 
86  /**
87   * Does nothing because no condition has to be satisfied.
88   */
89  public final String rightSide(int index, Instances instances){
90
91    return "";
92  }
93
94  /**
95   * Returns a string containing java source code equivalent to the test
96   * made at this node. The instance being tested is called "i".
97   *
98   * @param index index of the nominal value tested
99   * @param data the data containing instance structure info
100   * @return a value of type 'String'
101   */
102  public final String sourceExpression(int index, Instances data) {
103
104    return "true";  // or should this be false??
105  } 
106 
107  /**
108   * Returns the revision string.
109   *
110   * @return            the revision
111   */
112  public String getRevision() {
113    return RevisionUtils.extract("$Revision: 1.9 $");
114  }
115}
Note: See TracBrowser for help on using the repository browser.