From: Aaron A. <aa...@us...> - 2008-01-24 22:48:59
|
Update of /cvsroot/jboost/jboost/src/jboost/learner In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26189/learner Modified Files: InequalitySplitter.java InequalitySplitterBuilder.java StumpSplitterBuilderFamily.java Log Message: Cost sensitive normalboost, fixed compile bug in BooleanAttribute Index: StumpSplitterBuilderFamily.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/StumpSplitterBuilderFamily.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StumpSplitterBuilderFamily.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- StumpSplitterBuilderFamily.java 24 Jan 2008 22:48:54 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- import jboost.examples.RealAttribute; import jboost.examples.SetAttribute; + import jboost.examples.*; import jboost.monitor.Monitor; *************** *** 43,46 **** --- 44,49 ---- DiscreteAttribute discreteAttribute=new DiscreteAttribute(0); SetAttribute setAttribute=new SetAttribute(); + IntegerAttribute integerAttribute=new IntegerAttribute(); + BooleanAttribute booleanAttribute=new BooleanAttribute(); Vector retval=new Vector(); *************** *** 57,60 **** --- 60,66 ---- 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, Index: InequalitySplitterBuilder.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/InequalitySplitterBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InequalitySplitterBuilder.java 13 Oct 2007 04:32:28 -0000 1.2 --- InequalitySplitterBuilder.java 24 Jan 2008 22:48:54 -0000 1.3 *************** *** 12,15 **** --- 12,16 ---- import jboost.examples.Example; import jboost.examples.Label; + import jboost.examples.*; import jboost.examples.RealAttribute; import jboost.monitor.Monitor; *************** *** 290,297 **** throw new RuntimeException("Attempt to addExample() to non-root or finalized SplitterBuilder"); RealAttribute a= null; Attribute t= example.getAttribute(attributeIndex); // check that attribute is of the correct class try { ! a= (RealAttribute) t; // try downcasting } catch (ClassCastException e) { throw new IncompAttException( --- 291,319 ---- throw new RuntimeException("Attempt to addExample() to non-root or finalized SplitterBuilder"); RealAttribute a= null; + IntegerAttribute b= null; Attribute t= example.getAttribute(attributeIndex); + Label l= example.getLabel(); // check that attribute is of the correct class try { ! if (t instanceof RealAttribute) { ! a = (RealAttribute) t; ! if (a.isDefined() && (l != null)) { ! IVL ivl= new IVL(index, a.getValue(), l); ! tempList.add(ivl); ! } ! } else if (t instanceof IntegerAttribute) { ! b = (IntegerAttribute) t; ! if (b.isDefined() && (l != null)) { ! IVL ivl= new IVL(index, b.getValue(), l); ! tempList.add(ivl); ! } ! } else { ! throw new IncompAttException( ! index, ! attributeIndex, ! "IntegerAttribute or RealAttribute", ! t.getClass()); ! } ! // check if attribute and label are defined } catch (ClassCastException e) { throw new IncompAttException( *************** *** 301,314 **** t.getClass()); } - Label l= example.getLabel(); largestIndex= (largestIndex > index) ? largestIndex : index; // remember the largest index seen // if(Monitor.logLevel>3) Monitor.log("In RootInequalitySplitterBuilder: a="+a+" t="+t // +" example="+example); - if (a.isDefined() - && (l != null)) { // check if attribute and label are defined - IVL ivl= new IVL(index, a.getValue(), l); - tempList.add(ivl); // add item to list - } // if(Monitor.logLevel>3) Monitor.log("at end of addExample("+index+")\n"+tempList); } --- 323,330 ---- *************** *** 397,400 **** --- 413,417 ---- of the previous (unmasked) example in sortedIndices */ protected boolean[] potentialSplits; + //----------------------------- Private Members -------------------------------------// /** an internal class defining the elements of {@link tempList} */ *************** *** 405,408 **** --- 422,430 ---- label= l; } + IVL(int i, int v, Label l) { + index= i; + value= v; + label= l; + } public int compareTo(Object o) { // defined so that we can use "Collections.sort" double value2= ((IVL) o).value; Index: InequalitySplitter.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/InequalitySplitter.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** InequalitySplitter.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- InequalitySplitter.java 24 Jan 2008 22:48:54 -0000 1.2 *************** *** 5,8 **** --- 5,9 ---- import jboost.examples.Instance; import jboost.examples.RealAttribute; + import jboost.examples.*; /** *************** *** 59,64 **** if(t == null) {return(-1);} try { ! RealAttribute a= (RealAttribute) t; // try downcasting ! return((a.getValue() > threshold)?1:0); } catch (ClassCastException e) { --- 60,74 ---- if(t == null) {return(-1);} try { ! ! if (t instanceof RealAttribute) { ! RealAttribute a= (RealAttribute) t; // try downcasting ! return((a.getValue() > threshold)?1:0); ! } else if (t instanceof IntegerAttribute) { ! IntegerAttribute a= (IntegerAttribute) t; // try downcasting ! return((a.getValue() > threshold)?1:0); ! } else { ! throw new IncompAttException("InequalitySplitter Error:",index ! ,t.getClass()); ! } } catch (ClassCastException e) { |