/** * Constructs a vector of single-attribute SplitterBuilders to match the given ExampleDescription. */ public Vector<SplitterBuilder> build( ExampleDescription exDesc, int[] attr, boolean usePolicy, Configuration config, Booster booster) throws IncompAttException { // attribute class templates RealAttribute realAttribute = new RealAttribute(0.0); DiscreteAttribute discreteAttribute = new DiscreteAttribute(0); SetAttribute setAttribute = new SetAttribute(); IntegerAttribute integerAttribute = new IntegerAttribute(); Vector<SplitterBuilder> retval = new Vector<SplitterBuilder>(); AttributeDescription[] attrDesc = exDesc.getAttributes(); int noOfAtt = attr.length; SplitterBuilder tmpSB = null; // check each attribute to make sure that we are ignoring attributes when // necessary for (int i = 0; i < noOfAtt; i++) { if (!attrDesc[attr[i]].isIgnored()) { Class<?> attributeClass = attrDesc[attr[i]].getAttributeClass(); if (attributeClass.equals(realAttribute.getClass())) { tmpSB = new InequalitySplitterBuilder( attr[i], booster, new AttributeDescription[] {attrDesc[attr[i]]}); } else if (attributeClass.equals(integerAttribute.getClass())) { tmpSB = new InequalitySplitterBuilder( attr[i], booster, new AttributeDescription[] {attrDesc[attr[i]]}); } else if (attributeClass.equals(discreteAttribute.getClass())) { tmpSB = new EqualitySplitterBuilder( attr[i], booster, new AttributeDescription[] {attrDesc[attr[i]]}); } else if (attributeClass.equals(setAttribute.getClass())) { tmpSB = SetSplitterBuilder.newSplitterBuilder( attr[i], booster, textAbstain, new AttributeDescription[] {attrDesc[attr[i]]}); } else { throw new IncompAttException( "Trying to build SplitterBuilders vector but cannot identify attribute:", attr[i], attributeClass); } Monitor.log( "attribute " + attr[i] + " class is:" + attributeClass, Monitor.LOG_LEVEL_THREE); retval.add(tmpSB); } } return retval; }
/** Default constructor */ public StumpSplitterBuilderFamily(Configuration config) { textAbstain = config.getBool(prefix + "textAbstain", false); Monitor.log("textAbstain = " + textAbstain, Monitor.LOG_LEVEL_THREE); }