From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:54
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/controller Modified Files: Tag: jboost-2_0 Configuration.java Controller.java ControllerTest.java SplitEvaluatorWorker.java Log Message: jboost 2.0 Index: ControllerTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/ControllerTest.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** ControllerTest.java 15 Aug 2008 21:38:13 -0000 1.3 --- ControllerTest.java 8 Jun 2009 23:40:49 -0000 1.3.2.1 *************** *** 9,13 **** import jboost.booster.AdaBoost; import jboost.booster.LogLossBoost; - import jboost.booster.BrownBoost; import jboost.monitor.Monitor; import junit.framework.TestCase; --- 9,12 ---- *************** *** 25,30 **** protected void setUp() throws Exception { super.setUp(); ! String[] args= {"-CONFIG", System.getProperty("jboost.home") + ! File.separatorChar + "src/jboost/controller/jboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); --- 24,28 ---- protected void setUp() throws Exception { super.setUp(); ! String[] args= {"-CONFIG", "src/jboost/controller/jboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); *************** *** 35,40 **** protected void setUpWeighted() throws Exception { ! String[] args= {"-CONFIG", System.getProperty("jboost.home") + ! File.separatorChar + "src/jboost/controller/weightedjboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); --- 33,37 ---- protected void setUpWeighted() throws Exception { ! String[] args= {"-CONFIG", "src/jboost/controller/weightedjboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); *************** *** 71,92 **** assertTrue(boosterClass.isInstance(adaboost)); } - - /** - * Test building the Brown booster - */ - public final void testBrownBooster() { - // change booster type - m_config.addOption("booster_type", "jboost.booster.BrownBoost"); - try { - m_controller= new Controller(m_config); - } catch (Exception e) { - e.printStackTrace(); - System.err.println(e.toString()); - fail("Unexepected Exception"); - } - Class boosterClass= m_controller.getBooster().getClass(); - BrownBoost brown = new BrownBoost(); - assertTrue(boosterClass.isInstance(brown)); - } /** --- 68,71 ---- *************** *** 118,122 **** /** - <<<<<<< ControllerTest.java * Test the read/write tree functionality */ --- 97,100 ---- *************** *** 157,160 **** --- 135,139 ---- setUp(); m_config.addOption("numRounds", Integer.toString(rounds)); + m_config.addOption("serialTreeInput",null); m_controller.startLearning(); InstrumentedAlternatingTree secondTree= m_controller.getTree(); *************** *** 175,179 **** public final void testLogLossBoostCycle() { try { ! int rounds= 100; // learn for 40 rounds, write to file, reload and learn for 40 more rounds m_config.addOption("numRounds", Integer.toString(rounds/2)); --- 154,158 ---- public final void testLogLossBoostCycle() { try { ! int rounds= 80; // learn for 40 rounds, write to file, reload and learn for 40 more rounds m_config.addOption("numRounds", Integer.toString(rounds/2)); *************** *** 182,186 **** m_controller.startLearning(); m_controller.outputLearningResults(); ! m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); --- 161,166 ---- m_controller.startLearning(); m_controller.outputLearningResults(); ! ! setUp(); m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); *************** *** 191,196 **** --- 171,178 ---- // reset the controller and learn for 80 rounds + setUp(); m_config.addOption("numRounds", Integer.toString(rounds)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); + m_config.addOption("serialTreeInput",null); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 198,202 **** System.out.println(firstTree.toString()); System.out.println(secondTree.toString()); ! // assertTrue(firstTree.toString().equals(secondTree.toString())); } catch (Exception e) { e.printStackTrace(); --- 180,184 ---- System.out.println(firstTree.toString()); System.out.println(secondTree.toString()); ! //assertTrue(firstTree.toString().equals(secondTree.toString())); } catch (Exception e) { e.printStackTrace(); *************** *** 205,208 **** --- 187,248 ---- } + /** + * Test demo files using RobustBoost + * Write out serialized tree, then re-read and continue boosting. + * Compare output to non-serialized tree + */ + public final void testRobustBoostCycle() { + try { + int rounds= 40; + // learn for 40 rounds, write to file, reload and learn for 40 more rounds + m_config.addOption("numRounds", Integer.toString(rounds/2)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_controller= new Controller(m_config); + m_controller.startLearning(); + m_controller.outputLearningResults(); + double[] a1 = m_controller.getMarginsDistribution(); + + m_config.addOption("numRounds", Integer.toString(rounds/2)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0.41584"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); + m_controller= new Controller(m_config); + m_controller.initializeTree(); + double[] a2 = m_controller.getMarginsDistribution(); + m_controller.executeMainLoop(); + + for (int i=0;i<a1.length;i++) { + assertEquals(a1[i],a2[i],1e-7); + } + + InstrumentedAlternatingTree firstTree= m_controller.getTree(); + + // reset the controller and learn for 80 rounds + m_config.addOption("numRounds", Integer.toString(rounds)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_config.addOption("serialTreeInput", null); + m_controller= new Controller(m_config); + m_controller.startLearning(); + InstrumentedAlternatingTree secondTree= m_controller.getTree(); + System.out.println(firstTree.toString()); + System.out.println(secondTree.toString()); + // assertTrue(firstTree.toString().equals(secondTree.toString())); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + /** *************** *** 311,315 **** m_controller.outputLearningResults(); m_config.addOption(Configuration.SERIALIZED_INPUT,"src/jboost/controller/weightedatree.serialized"); ! m_config.addOption(Configuration.SAMPLE_TRAINING_DATA, "true"); m_config.addOption(Configuration.SAMPLE_THRESHOLD_WEIGHT, "0.005"); m_controller= new Controller(m_config); --- 351,355 ---- m_controller.outputLearningResults(); m_config.addOption(Configuration.SERIALIZED_INPUT,"src/jboost/controller/weightedatree.serialized"); ! //m_config.addOption(Configuration.SAMPLE_TRAINING_DATA, "true"); m_config.addOption(Configuration.SAMPLE_THRESHOLD_WEIGHT, "0.005"); m_controller= new Controller(m_config); Index: SplitEvaluatorWorker.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/SplitEvaluatorWorker.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** SplitEvaluatorWorker.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- SplitEvaluatorWorker.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 1,7 **** package jboost.controller; import jboost.CandidateSplit; import jboost.util.BaseCountWorker; - import EDU.oswego.cs.dl.util.concurrent.CountDown; /** --- 1,8 ---- package jboost.controller; + import java.util.concurrent.CountDownLatch; + import jboost.CandidateSplit; import jboost.util.BaseCountWorker; /** *************** *** 15,19 **** int pos; ! public SplitEvaluatorWorker(CandidateSplit split, double[] losses, int pos, CountDown count) { super(count); this.split=split; --- 16,20 ---- int pos; ! public SplitEvaluatorWorker(CandidateSplit split, double[] losses, int pos, CountDownLatch count) { super(count); this.split=split; Index: Configuration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Configuration.java,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** Configuration.java 12 Mar 2009 23:42:04 -0000 1.14 --- Configuration.java 8 Jun 2009 23:40:49 -0000 1.14.2.1 *************** *** 2,7 **** import java.io.BufferedReader; - import java.io.FileNotFoundException; import java.io.File; import java.io.IOException; import java.util.HashMap; --- 2,7 ---- import java.io.BufferedReader; import java.io.File; [...1719 lines suppressed...] ! public Command(String n, String v) { ! name = n; ! value = v; ! } ! public String getValue() { ! checkCount++; ! return (value); ! } ! ! public int getCount() { ! return (checkCount); ! } + public String toString() { + String retval = new String("-"); + retval += name + " " + value; + return (retval); + } + } Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** Controller.java 12 Mar 2009 23:42:04 -0000 1.17 --- Controller.java 8 Jun 2009 23:40:49 -0000 1.17.2.1 *************** *** 1,3 **** --- 1,4 ---- package jboost.controller; + import java.io.BufferedWriter; import java.io.FileInputStream; *************** *** 11,14 **** --- 12,21 ---- import java.util.Iterator; import java.util.Vector; [...1452 lines suppressed...] ! : m_config ! .getSpecFileName()), ! m_exampleDescription); ! else throw new RuntimeException( ! "Controller.generateCode: Unrecognized language:" ! + language); ! PrintWriter codeOutputStream = ! new PrintWriter( ! new BufferedWriter(new FileWriter(codeOutputFileName))); ! codeOutputStream.println(code); ! codeOutputStream.close(); ! } ! catch (Exception e) { ! System.err.println("Exception occured while attempting to write " ! + language + " code"); ! System.err.println("Message:" + e); ! e.printStackTrace(); ! } ! } } |