From: Aaron A. <aa...@us...> - 2008-06-03 03:17:43
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv32711/controller Modified Files: Controller.java ControllerConfiguration.java Log Message: Moved ExampleSets from the ControllerConfig to the Controller. --Aaron Index: ControllerConfiguration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/ControllerConfiguration.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ControllerConfiguration.java 24 Jan 2008 22:48:53 -0000 1.4 --- ControllerConfiguration.java 3 Jun 2008 03:17:39 -0000 1.5 *************** *** 8,12 **** import java.io.*; - import jboost.examples.ExampleSet; import jboost.monitor.Monitor; --- 8,11 ---- *************** *** 14,22 **** /** ! * The ControllerConfiguration holds all the configurable data used by the * Controller, Monitor, and anything else that needs to get access to it. * Using this configuration object allows us to reduce the exposure of the * Controller to other classes that may need to share data with it. ! * * The data that this class maintains are: * <li> specFileName --- 13,21 ---- /** ! * The ControllerConfiguration holds all the configurable data used by the * Controller, Monitor, and anything else that needs to get access to it. * Using this configuration object allows us to reduce the exposure of the * Controller to other classes that may need to share data with it. ! * * The data that this class maintains are: * <li> specFileName *************** *** 30,35 **** * <li> trainSet * <li> testSet ! * ! * * @author cschavis */ --- 29,34 ---- * <li> trainSet * <li> testSet ! * ! * * @author cschavis */ *************** *** 68,84 **** public static final String BROWN_BOOST_POTENTIAL="brownBoostPotential"; public static final String BROWN_COST_SENSITIVE="costSensitive"; ! public static final String DEFAULT_BOOSTER = "AdaBoost"; - - // private data elements that are not stored in the Configuration vector - private ExampleSet trainSet; - private ExampleSet testSet; /** * Configure the specific entries that we need for the Controller */ ! public ControllerConfiguration(String manpage, String[] argv) throws BadCommandException, IOException { ! super(manpage, argv); String stem= getString("S", "default"); --- 67,79 ---- public static final String BROWN_BOOST_POTENTIAL="brownBoostPotential"; public static final String BROWN_COST_SENSITIVE="costSensitive"; ! public static final String DEFAULT_BOOSTER = "AdaBoost"; /** * Configure the specific entries that we need for the Controller */ ! public ControllerConfiguration(String manpage, String[] argv) throws BadCommandException, IOException { ! super(manpage, argv); String stem= getString("S", "default"); *************** *** 113,163 **** addOption(BROWN_COST_SENSITIVE, getString("costSensitive", null)); } ! /** ! * Check the values of all the parameters, e.g. make sure that * the filenames for the input files exist. ! * @return */ ! protected boolean checkCommandValues() throws BadCommandException { ! // check the input files ! try { ! if(getPrintVersion()){ ! System.out.println("JBoost version " + VERSION); ! System.exit(0); ! } ! String specname = getSpecFileName(); ! String testname = getTestFileName(); ! String trainname = getTrainFileName(); ! Monitor.log("Spec: " + specname + ", Test: " + testname + ", Train: " + trainname); ! if(specname == null || testname == null || trainname == null){ ! throw new BadCommandException("ERROR: Have not assigned all (spec,train,test) input file names yet!"); ! } ! File specfile = new File(specname); ! File testfile = new File(testname); ! File trainfile = new File(trainname); ! if (! (specfile.exists() && testfile.exists() && trainfile.exists()) ) { ! throw new BadCommandException("ERROR: Input file names (spec,train,test) do not exist!"); ! } ! } catch(Exception e) { ! System.err.println("ERROR: Input files do not exist or are unreadable for other reasons!"); ! throw new BadCommandException(e.getMessage()); ! } ! ! // Check the results output file parameters ! try { ! String fname = getResultOutputFileName(); ! if(fname == null){ ! throw new BadCommandException("ERROR: Have not assigned output file name yet!"); ! } ! } catch(Exception e) { ! System.err.println("ERROR: File either does not exist or is unreadable for other reasons!"); ! throw new BadCommandException(e.getMessage()); ! } ! ! return true; } ! ! /** * @return Returns the resultOutputFileName. --- 108,158 ---- addOption(BROWN_COST_SENSITIVE, getString("costSensitive", null)); } ! /** ! * Check the values of all the parameters, e.g. make sure that * the filenames for the input files exist. ! * @return */ ! protected boolean checkCommandValues() throws BadCommandException { ! // check the input files ! try { ! if(getPrintVersion()){ ! System.out.println("JBoost version " + VERSION); ! System.exit(0); ! } ! String specname = getSpecFileName(); ! String testname = getTestFileName(); ! String trainname = getTrainFileName(); ! Monitor.log("Spec: " + specname + ", Test: " + testname + ", Train: " + trainname); ! if(specname == null || testname == null || trainname == null){ ! throw new BadCommandException("ERROR: Have not assigned all (spec,train,test) input file names yet!"); ! } ! File specfile = new File(specname); ! File testfile = new File(testname); ! File trainfile = new File(trainname); ! if (! (specfile.exists() && testfile.exists() && trainfile.exists()) ) { ! throw new BadCommandException("ERROR: Input file names (spec,train,test) do not exist!"); ! } ! } catch(Exception e) { ! System.err.println("ERROR: Input files do not exist or are unreadable for other reasons!"); ! throw new BadCommandException(e.getMessage()); ! } ! ! // Check the results output file parameters ! try { ! String fname = getResultOutputFileName(); ! if(fname == null){ ! throw new BadCommandException("ERROR: Have not assigned output file name yet!"); ! } ! } catch(Exception e) { ! System.err.println("ERROR: File either does not exist or is unreadable for other reasons!"); ! throw new BadCommandException(e.getMessage()); ! } ! ! return true; } ! ! /** * @return Returns the resultOutputFileName. *************** *** 182,199 **** /** - * @param the test set - */ - public void setTestSet(ExampleSet set) { - testSet= set; - } - - /** - * @return Returns the testSet. - */ - public ExampleSet getTestSet() { - return testSet; - } - - /** * @return Returns the trainFileName. */ --- 177,180 ---- *************** *** 203,226 **** /** - * @param the training set - */ - public void setTrainSet(ExampleSet set) { - trainSet= set; - } - - /** - * @return Returns the trainSet. - */ - public ExampleSet getTrainSet() { - return trainSet; - } - - /** * @return Returns the name of the C output file */ public String getCoutputFileName() { ! return getString(C_OUTPUT_FILENAME); } ! /** * @return Returns the name of the Java output file --- 184,193 ---- /** * @return Returns the name of the C output file */ public String getCoutputFileName() { ! return getString(C_OUTPUT_FILENAME); } ! /** * @return Returns the name of the Java output file *************** *** 229,240 **** return getString(JAVA_OUTPUT_FILENAME); } ! /** * @return Returns the name of the Matlab output file */ ! public String getMatlabOutputFileName() { return getString(MATLAB_OUTPUT_FILENAME); } ! /** * @return Returns the name of the serialized output file --- 196,207 ---- return getString(JAVA_OUTPUT_FILENAME); } ! /** * @return Returns the name of the Matlab output file */ ! public String getMatlabOutputFileName() { return getString(MATLAB_OUTPUT_FILENAME); } ! /** * @return Returns the name of the serialized output file *************** *** 243,247 **** return getString(SERIALIZED_OUTPUT_FILENAME); } ! /** * @return Returns the name of the serialized input file --- 210,214 ---- return getString(SERIALIZED_OUTPUT_FILENAME); } ! /** * @return Returns the name of the serialized input file *************** *** 250,254 **** return getString(SERIALIZED_INPUT); } ! /** * @return Returns the specified number of threads --- 217,221 ---- return getString(SERIALIZED_INPUT); } ! /** * @return Returns the specified number of threads *************** *** 257,283 **** return getString(N_THREADS); } ! /** ! * @return the runtime of the boosting algorithm * (for adaptive versions of BBM) */ public double getRuntime() { ! String runStr = getString(BOOSTER_RUNTIME); ! if (runStr == null) { ! return 0; ! } ! return Double.parseDouble(runStr); } ! /** * @return should we print the version? */ public boolean getPrintVersion() { ! String str = getString(JBOOST_VERSION); ! if (str == null) { ! return false; ! } ! return true; } --- 224,250 ---- return getString(N_THREADS); } ! /** ! * @return the runtime of the boosting algorithm * (for adaptive versions of BBM) */ public double getRuntime() { ! String runStr = getString(BOOSTER_RUNTIME); ! if (runStr == null) { ! return 0; ! } ! return Double.parseDouble(runStr); } ! /** * @return should we print the version? */ public boolean getPrintVersion() { ! String str = getString(JBOOST_VERSION); ! if (str == null) { ! return false; ! } ! return true; } *************** *** 288,296 **** */ public boolean getPrintPotential() { ! String str = getString(BROWN_BOOST_POTENTIAL); ! if (str == null) { ! return false; ! } ! return true; } --- 255,263 ---- */ public boolean getPrintPotential() { ! String str = getString(BROWN_BOOST_POTENTIAL); ! if (str == null) { ! return false; ! } ! return true; } *************** *** 300,308 **** */ public boolean getCostSensitive() { ! String str = getString(BROWN_COST_SENSITIVE); ! if (str == null) { ! return false; ! } ! return true; } --- 267,275 ---- */ public boolean getCostSensitive() { ! String str = getString(BROWN_COST_SENSITIVE); ! if (str == null) { ! return false; ! } ! return true; } Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Controller.java 24 Jan 2008 22:48:53 -0000 1.7 --- Controller.java 3 Jun 2008 03:17:39 -0000 1.8 *************** *** 48,52 **** * method will use configuration data to build a learner and read in the train * and test examples. ! * */ --- 48,52 ---- * method will use configuration data to build a learner and read in the train * and test examples. ! * */ [...1242 lines suppressed...] ! predictor.toJava( ! procedureName, ! m_config.getString("javaOutputMethod", "predict"), ! (m_config.getBool("javaStandAlone", false) ? null : 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(); ! } } } |