001: /*
002: * This program is free software; you can redistribute it and/or modify
003: * it under the terms of the GNU General Public License as published by
004: * the Free Software Foundation; either version 2 of the License, or
005: * (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
015: */
016:
017: /*
018: * NoSplit.java
019: * Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
020: *
021: */
022:
023: package weka.classifiers.trees.j48;
024:
025: import weka.core.Instance;
026: import weka.core.Instances;
027:
028: /**
029: * Class implementing a "no-split"-split.
030: *
031: * @author Eibe Frank (eibe@cs.waikato.ac.nz)
032: * @version $Revision: 1.8 $
033: */
034: public final class NoSplit extends ClassifierSplitModel {
035:
036: /** for serialization */
037: private static final long serialVersionUID = -1292620749331337546L;
038:
039: /**
040: * Creates "no-split"-split for given distribution.
041: */
042: public NoSplit(Distribution distribution) {
043:
044: m_distribution = new Distribution(distribution);
045: m_numSubsets = 1;
046: }
047:
048: /**
049: * Creates a "no-split"-split for a given set of instances.
050: *
051: * @exception Exception if split can't be built successfully
052: */
053: public final void buildClassifier(Instances instances)
054: throws Exception {
055:
056: m_distribution = new Distribution(instances);
057: m_numSubsets = 1;
058: }
059:
060: /**
061: * Always returns 0 because only there is only one subset.
062: */
063: public final int whichSubset(Instance instance) {
064:
065: return 0;
066: }
067:
068: /**
069: * Always returns null because there is only one subset.
070: */
071: public final double[] weights(Instance instance) {
072:
073: return null;
074: }
075:
076: /**
077: * Does nothing because no condition has to be satisfied.
078: */
079: public final String leftSide(Instances instances) {
080:
081: return "";
082: }
083:
084: /**
085: * Does nothing because no condition has to be satisfied.
086: */
087: public final String rightSide(int index, Instances instances) {
088:
089: return "";
090: }
091:
092: /**
093: * Returns a string containing java source code equivalent to the test
094: * made at this node. The instance being tested is called "i".
095: *
096: * @param index index of the nominal value tested
097: * @param data the data containing instance structure info
098: * @return a value of type 'String'
099: */
100: public final String sourceExpression(int index, Instances data) {
101:
102: return "true"; // or should this be false??
103: }
104:
105: }
|