~ubuntu-branches/ubuntu/precise/weka/precise

« back to all changes in this revision

Viewing changes to weka/classifiers/trees/j48/NoSplit.java

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg
  • Date: 2008-02-24 09:18:45 UTC
  • Revision ID: james.westby@ubuntu.com-20080224091845-1l8zy6fm6xipbzsr
Tags: upstream-3.5.7+tut1
ImportĀ upstreamĀ versionĀ 3.5.7+tut1

Show diffs side-by-side

added added

removed removed

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