You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(37) |
Jun
(11) |
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(22) |
Nov
|
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(9) |
May
(1) |
Jun
(2) |
Jul
(8) |
Aug
(7) |
Sep
(29) |
Oct
|
Nov
(1) |
Dec
|
2009 |
Jan
(8) |
Feb
(18) |
Mar
(5) |
Apr
|
May
|
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Aaron A. <aa...@us...> - 2007-06-14 16:35:46
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20381/src/jboost/booster Modified Files: MixedBinaryPrediction.java Log Message: Added in warnings for the mixed binary prediction. Index: MixedBinaryPrediction.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/MixedBinaryPrediction.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MixedBinaryPrediction.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- MixedBinaryPrediction.java 14 Jun 2007 16:35:43 -0000 1.2 *************** *** 33,44 **** * since we have symmetry (i.e. (1-x)y+y = (1-y)x+x ) we allow this operation. */ ! public Prediction add(Prediction p) throws NotNormalizedPredException{ double other_p = ((MixedBinaryPrediction) p).prediction; ! if (Math.abs(other_p) > 1) { throw new NotNormalizedPredException("Prediction may result in unnormalized " + "prediction! p is: " + p); } - - prediction = (1-other_p) * prediction + other_p; return this; } --- 33,43 ---- * since we have symmetry (i.e. (1-x)y+y = (1-y)x+x ) we allow this operation. */ ! public Prediction add(Prediction p) throws NotNormalizedPredException{ double other_p = ((MixedBinaryPrediction) p).prediction; ! prediction = (1-Math.abs(prediction)) * other_p + prediction; ! if (Math.abs(other_p) > 1 || Math.abs(prediction) > 1) { throw new NotNormalizedPredException("Prediction may result in unnormalized " + "prediction! p is: " + p); } return this; } *************** *** 47,52 **** * This is not well defined for normalized predictions. However, we * do allow it. - * - * */ public Prediction scale(double w) throws NotNormalizedPredException{ --- 46,49 ---- *************** *** 71,78 **** public String toString() { ! return "MixedBinaryPrediction. p(1)= "+prediction; } public String cPreamble() { return "typedef double Prediction_t;\n" + --- 68,77 ---- public String toString() { ! return "MixedBinaryPrediction. p(1)= " + prediction; } public String cPreamble() { + System.out.println("Prediction::cPreamble not supported."); + System.exit(2); return "typedef double Prediction_t;\n" + *************** *** 84,87 **** --- 83,88 ---- public String javaPreamble() { + System.out.println("Prediction::javaPreamble not supported."); + System.exit(2); return "" + " static private double p;\n" |
From: Aaron A. <aa...@us...> - 2007-06-14 16:33:54
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19548/src/jboost/booster Modified Files: AbstractBooster.java Log Message: Removed output line Index: AbstractBooster.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/AbstractBooster.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractBooster.java 29 May 2007 05:03:57 -0000 1.3 --- AbstractBooster.java 14 Jun 2007 16:33:51 -0000 1.4 *************** *** 73,77 **** yaba.setParams(c1,c2,theta); result = yaba; - System.out.println("YABA is:" + yaba); } --- 73,76 ---- |
From: Aaron A. <aa...@us...> - 2007-06-14 16:33:34
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19514 Modified Files: CHANGES Log Message: added release notes for 1.3.1 Index: CHANGES =================================================================== RCS file: /cvsroot/jboost/jboost/CHANGES,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CHANGES 31 May 2007 10:04:03 -0000 1.3 --- CHANGES 14 Jun 2007 16:33:31 -0000 1.4 *************** *** 2,5 **** --- 2,12 ---- -------------------- + + Release 1.3.1 + + ================= + + - BrownBoost now able to handle hypotheses that abstain + - Several bug fixes (BrownBoost, Controller, etc) + + + Release 1.3 + =============== |
From: Aaron A. <aa...@us...> - 2007-06-14 16:21:19
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14582/src/jboost/monitor Modified Files: Monitor.java Log Message: log of surfing data Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Monitor.java 31 May 2007 10:04:04 -0000 1.4 --- Monitor.java 14 Jun 2007 16:21:13 -0000 1.5 *************** *** 10,13 **** --- 10,14 ---- import jboost.Predictor; import jboost.booster.Booster; + import jboost.booster.BrownBoost; import jboost.controller.ControllerConfiguration; import jboost.controller.Configuration; *************** *** 44,47 **** --- 45,53 ---- private String trainMarginOutputFilename; + /** surfing streams and varialbes */ + private int surfPrintRate; + private PrintWriter surfStream; // a stream for the training data scores + private String surfOutputFilename; + /** a stream for logging resampling activity */ private PrintWriter samplingStream; *************** *** 104,107 **** --- 110,114 ---- trainMarginOutputFilename= outputStem + ".train.margin"; testMarginOutputFilename= outputStem + ".test.margin"; + surfOutputFilename= outputStem + ".surfing"; samplingOutputFilename= outputStem + ".sampling"; *************** *** 136,139 **** --- 143,147 ---- scoresPrintRate= config.getInt("a", 0); marginPrintRate= scoresPrintRate; + surfPrintRate= scoresPrintRate; if (scoresPrintRate != 0) { trainScoresStream= new PrintWriter(new BufferedWriter( *************** *** 155,158 **** --- 163,171 ---- new FileWriter(testMarginOutputFilename))); } + if (marginPrintRate != 0) { + surfStream = new PrintWriter( + new BufferedWriter( + new FileWriter(surfOutputFilename))); + } afterInitTime= new Date(); infoStream.println("Init Start time = " + startTime); *************** *** 194,197 **** --- 207,211 ---- logScores(iter, combined, base); logMargins(iter, combined, base); + logSurfing(iter, combined, base); infoStream.println(); } *************** *** 234,237 **** --- 248,280 ---- } + + /** output the scores distribution of the training set */ + private void logSurfing(int iter, Predictor combined, Predictor base) { + if (surfPrintRate == 0 || // never print surf + (surfPrintRate > 0 && surfPrintRate != iter)) + // or print surf only on iteration surfPrintRate + return; + if (surfPrintRate == -1) { + // print score when highest order digit in iter changes. + double m= + java.lang.Math.floor( + java.lang.Math.log(iter) / java.lang.Math.log(10.0)); + int t= (int) java.lang.Math.pow(10.0, m); + if (iter == 0) + t= 1; // fix bug in "pow" + if ((iter % t) != 0) + return; + } + infoStream.print(" \t# output surf #"); + // output training surf + // double m_margins[] = m_booster.getMargins(); // get m_margins from the + // m_booster + + surfStream.println("iteration=" + iter + ", elements=" + trainSet.getExampleNo()); + if(m_booster instanceof BrownBoost) { + surfStream.print(((BrownBoost)m_booster).surfingData()); + } + } + |
From: Aaron A. <aa...@us...> - 2007-06-13 16:09:19
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv618/scripts Modified Files: margin.py Log Message: Significant speed up (only find max once) Index: margin.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/margin.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** margin.py 31 May 2007 10:03:00 -0000 1.6 --- margin.py 13 Jun 2007 16:09:14 -0000 1.7 *************** *** 87,90 **** --- 87,96 ---- lines = [] + margin_list_maxes = [] + for i in range(len(margin_list)): + margins = margin_list[i] + margin_list_maxes.append(max(margins)) + + for w in range(len(margin_list[0])): line = "" *************** *** 92,96 **** for i in range(len(margin_list)): margins = margin_list[i] ! marg_max = max(margins) line += ' ' line += str(margins[w]/marg_max) --- 98,102 ---- for i in range(len(margin_list)): margins = margin_list[i] ! marg_max = margin_list_maxes[i] line += ' ' line += str(margins[w]/marg_max) *************** *** 287,293 **** margin_list.append(margins) process_data(examples, labels, margin_list[len(margin_list)-1], scores, datafile, sample) - write_gnuplot(margin_list, iters, datafile) --- 293,300 ---- margin_list.append(margins) + write_gnuplot(margin_list, iters, datafile) + process_data(examples, labels, margin_list[len(margin_list)-1], scores, datafile, sample) |
From: Aaron A. <aa...@us...> - 2007-06-04 22:16:04
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv651 Modified Files: build.xml jboost Log Message: Update the version, output jar file Index: jboost =================================================================== RCS file: /cvsroot/jboost/jboost/jboost,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** jboost 31 May 2007 10:04:03 -0000 1.3 --- jboost 4 Jun 2007 22:15:12 -0000 1.4 *************** *** 22,30 **** fi ! ! exec java -Xmx500M jboost.controller.Controller $@ ! ! if [ $? -ne 0 ]; then --- 22,29 ---- fi + echo -n "JBoost jar file is:" + echo "${CLASSPATH}" | sed 's/:/\n/g' | grep 'jboost\.jar' ! exec java -Xmx1000M jboost.controller.Controller $@ if [ $? -ne 0 ]; then Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** build.xml 31 May 2007 10:04:03 -0000 1.6 --- build.xml 4 Jun 2007 22:15:10 -0000 1.7 *************** *** 15,19 **** <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> ! <property name="jboost.version" value="1.3"/> <property name="test.class.name" value="jboost.AllTests"/> --- 15,19 ---- <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> ! <property name="jboost.version" value="1.3.1"/> <property name="test.class.name" value="jboost.AllTests"/> |
From: Aaron A. <aa...@us...> - 2007-06-04 07:24:45
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15744 Modified Files: BrownBoost.java Log Message: Some optimizations Index: BrownBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/BrownBoost.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BrownBoost.java 27 May 2007 11:23:23 -0000 1.2 --- BrownBoost.java 4 Jun 2007 07:24:38 -0000 1.3 *************** *** 179,185 **** /** ! * Implements the calculation of the constraints and partial derivatives. ! * To better understand notation, please see Freund 1999, ! * Freund 2001, and Freund & Arvey 2008. * @returns ErfVars which contains the values of the various parameters. */ --- 179,185 ---- /** ! * Implements the calculation of the constraints and partial ! * derivatives. To better understand notation, see Freund 1999, ! * Freund 2001, and Freund & Arvey 2008. * @returns ErfVars which contains the values of the various parameters. */ *************** *** 187,204 **** { ErfVars vars = new ErfVars(); - double current_time = m_c - m_s; - double c1 = 1; - double c2 = 1; - double theta = 0; - double mu = - c1*Math.exp(-current_time - t) + theta; - double sd = Math.sqrt(c2*(Math.exp(-2*current_time - 2*t) - Math.exp(-2))); ! for (int i= 0; i < m_hypPredictions.length; i++) { ! int example = i; double margin = m_margins[example]; // m_labels are 0 or 1 or arbitrary other, this moves it to +-1 double step = getStep(m_labels[example], m_hypPredictions[example]); ! // variable names are taken from Freund 1999, Freund 2001 double aj = margin + m_s; --- 187,200 ---- { ErfVars vars = new ErfVars(); ! ! double new_margin, new_time_remaining, new_weight, new_potential, orig_potential; ! for (int example= 0; example < m_hypPredictions.length; example++) { double margin = m_margins[example]; // m_labels are 0 or 1 or arbitrary other, this moves it to +-1 double step = getStep(m_labels[example], m_hypPredictions[example]); ! ! /* // variable names are taken from Freund 1999, Freund 2001 double aj = margin + m_s; *************** *** 206,235 **** double dj = margin + bj*alpha + m_s - t; double wj = Math.exp(-(dj*dj)/m_c); ! ! /* vars.W += wj; vars.U += wj*dj*bj; vars.B += wj*bj; vars.V += wj*dj*bj*bj; ! vars.I += erf(dj / Math.sqrt(m_c)) - m_initialPotential; ! vars.E += erf(dj / Math.sqrt(m_c)) - erf(aj / Math.sqrt(m_c)); vars.Potential += (1-erf( dj /Math.sqrt(m_c)))/2; */ - ! ! double new_margin = margin + bj*alpha; ! double new_time_remaining = m_s - t; ! double new_weight = calculateWeight(new_margin, new_time_remaining); ! double new_potential = calculatePotential(new_margin, new_time_remaining); ! double orig_potential = calculatePotential(margin, m_s); ! vars.E += orig_potential - new_potential; // - orig_potential; ! vars.B += new_weight * bj; ! vars.Potential += calculatePotential(new_margin, new_time_remaining) / m_hypPredictions.length; ! ! //System.out.println("Example: " + j + ", Step: " + step + ", Label: " + label + ", Margin: " + margin + ", Pred: " + pred); //System.out.println("W:" + W + ", U:" + U + ", B:" + B + ", V:" + V + ", E:" + E); } return vars; } --- 202,230 ---- double dj = margin + bj*alpha + m_s - t; double wj = Math.exp(-(dj*dj)/m_c); ! vars.W += wj; vars.U += wj*dj*bj; vars.B += wj*bj; vars.V += wj*dj*bj*bj; ! vars.I += erf(dj / Math.sqrt(m_c)) - m_initialPotential; ! vars.E += erf(dj / Math.sqrt(m_c)) - erf(aj / Math.sqrt(m_c)); vars.Potential += (1-erf( dj /Math.sqrt(m_c)))/2; */ ! new_margin = margin + step*alpha; ! new_time_remaining = m_s - t; ! new_weight = calculateWeight(new_margin, new_time_remaining); ! new_potential = calculatePotential(new_margin, new_time_remaining); ! orig_potential = calculatePotential(margin, m_s); vars.E += orig_potential - new_potential; // - orig_potential; ! vars.B += new_weight * step; ! vars.Potential += calculatePotential(new_margin, new_time_remaining); ! ! //System.out.println("Example: " + j + ", Step: " + step + ", Label: " ! //+ label + ", Margin: " + margin + ", Pred: " + pred); //System.out.println("W:" + W + ", U:" + U + ", B:" + B + ", V:" + V + ", E:" + E); } + + vars.Potential /= m_hypPredictions.length; return vars; } *************** *** 320,329 **** int NUM_ITERATIONS_FINISH_GAME = 10; int count_t_over_s = 0; - double lastE = 0; - double STEP_EPS = 0.00001; double CORR_EPS = 0.001; - boolean first_iter = true; while(Math.abs(t_step) > STEP_EPS) { --- 315,321 ---- *************** *** 407,410 **** --- 399,405 ---- t = bs_t; + m_oldS = m_s; + m_s -= t; + System.out.format("\tBrownBoost: alpha=%.4f, t=%.4f, time left=%.4f, " + "potential=%.4f\n", alpha, t, m_s, vars.Potential); *************** *** 417,422 **** } - m_oldS = m_s; - m_s -= t; //System.out.println("\ns: " + m_s); return alpha; --- 412,415 ---- *************** *** 457,474 **** int example = indexes[j]; m_margins[example] += value[m_labels[example]]; - - m_totalWeight -= m_weights[example]; - m_weights[example] = calculateWeight(m_margins[example]); - m_totalWeight += m_weights[example]; - - //System.out.println("Example: " + j + - // ", Label: " + getLabel(m_labels[example]) + - // ", Margin: " + m_margins[example] + - // ", Step: " + getStep(m_labels[example], m_hypPredictions[example]) + - // ", Weight: " + m_weights[example] - // ); } - //predictions[i].scale(alpha); } } --- 450,461 ---- int example = indexes[j]; m_margins[example] += value[m_labels[example]]; } } + + for (int i=0; i < m_hypPredictions.length; i++) { + m_totalWeight -= m_weights[i]; + m_weights[i] = calculateWeight(m_margins[i]); + m_totalWeight += m_weights[i]; + } } |
From: Aaron A. <aa...@us...> - 2007-05-31 10:04:07
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6381 Modified Files: CHANGES build.xml jboost Log Message: misc small changes Index: jboost =================================================================== RCS file: /cvsroot/jboost/jboost/jboost,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** jboost 27 May 2007 11:24:32 -0000 1.2 --- jboost 31 May 2007 10:04:03 -0000 1.3 *************** *** 1,8 **** #!/bin/sh ! PWD=`pwd` ! JBOOST_HOME=`echo "$PWD/$0" | sed 's/\/jboost$//'` ! CLASSPATH="$JBOOST_HOME/lib/concurrent.jar:$CLASSPATH" ! CLASSPATH="$JBOOST_HOME/dist/jboost.jar:$CLASSPATH" #echo $PWD --- 1,8 ---- #!/bin/sh ! #PWD=`pwd` ! #JBOOST_HOME=`echo "$PWD/$0" | sed 's/\/jboost$//'` ! #CLASSPATH="$JBOOST_HOME/lib/concurrent.jar:$CLASSPATH" ! #CLASSPATH="$JBOOST_HOME/dist/jboost.jar:$CLASSPATH" #echo $PWD Index: CHANGES =================================================================== RCS file: /cvsroot/jboost/jboost/CHANGES,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CHANGES 27 May 2007 11:22:40 -0000 1.2 --- CHANGES 31 May 2007 10:04:03 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- - Minor improvements to margin.py and error.py - Added options outputting serialized trees + - Added some more misc documentation Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** build.xml 27 May 2007 11:24:49 -0000 1.5 --- build.xml 31 May 2007 10:04:03 -0000 1.6 *************** *** 15,19 **** <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> ! <property name="jboost.version" value="1.2"/> <property name="test.class.name" value="jboost.AllTests"/> --- 15,19 ---- <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> ! <property name="jboost.version" value="1.3"/> <property name="test.class.name" value="jboost.AllTests"/> *************** *** 165,168 **** --- 165,169 ---- <copy todir="${jboost.home}/jboost-${jboost.version}/demo/" > <fileset dir="${dir.demo}"> + <include name="README" /> <include name="*.data" /> <include name="*.train" /> |
From: Aaron A. <aa...@us...> - 2007-05-31 10:04:07
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6381/src/jboost/monitor Modified Files: Monitor.java Log Message: misc small changes Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Monitor.java 29 May 2007 05:05:24 -0000 1.3 --- Monitor.java 31 May 2007 10:04:04 -0000 1.4 *************** *** 188,192 **** double testError= testSet.calcError(iter, combined, base); double theoryBound= m_booster.getTheoryBound(); ! NumberFormat f= new DecimalFormat("0.000"); infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" + f.format(trainError) + "\t" + f.format(testError)); --- 188,192 ---- double testError= testSet.calcError(iter, combined, base); double theoryBound= m_booster.getTheoryBound(); ! NumberFormat f= new DecimalFormat("0.0000"); infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" + f.format(trainError) + "\t" + f.format(testError)); |
From: Aaron A. <aa...@us...> - 2007-05-31 10:03:26
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6308/src/jboost/booster Modified Files: YabaBoost.java Log Message: minor improvements Index: YabaBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/YabaBoost.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** YabaBoost.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- YabaBoost.java 31 May 2007 10:03:23 -0000 1.2 *************** *** 75,82 **** --- 75,84 ---- public YabaBoost() { super(); + /* m_c = 1; m_c1 = 2; m_c2 = 1; m_theta = 0.5; + */ } *************** *** 167,179 **** double new_margin = (1-alpha)*margin + alpha*step; ! double wj = calculateWeight(new_margin, new_time_remaining); double new_pot = calculatePotential(new_margin, new_time_remaining); double orig_pot = calculatePotential(orig_margin, orig_time_remaining); ! vars.B += wj*step; vars.E += orig_pot - new_pot; ! ! totalWeight += wj; //System.out.println("Example: " + j + ", Step: " + step + ", Margin: " + margin + ", Weight: " + wj); //System.out.println("aj: " + aj + ", dj: " + dj + ", dj^2/sd^2: " + (dj*dj/(sd*sd)) + ", bj: " + bj); --- 169,182 ---- double new_margin = (1-alpha)*margin + alpha*step; ! double new_weight = calculateWeight(new_margin, new_time_remaining); double new_pot = calculatePotential(new_margin, new_time_remaining); double orig_pot = calculatePotential(orig_margin, orig_time_remaining); ! vars.B += new_weight*step; vars.E += orig_pot - new_pot; ! vars.Potential += new_pot / m_hypPredictions.length; ! ! totalWeight += new_weight; //System.out.println("Example: " + j + ", Step: " + step + ", Margin: " + margin + ", Weight: " + wj); //System.out.println("aj: " + aj + ", dj: " + dj + ", dj^2/sd^2: " + (dj*dj/(sd*sd)) + ", bj: " + bj); *************** *** 197,201 **** --- 200,207 ---- System.err.println(""); + System.err.println(""); System.err.println("Dumping everything"); + System.err.println("% " + v.Potential + ", " + m_initialPotential); + dumpfile.println("% Avg Diff Potential, Gamma correlation"); dumpfile.println("% " + v.E + ", " + v.B); *************** *** 234,239 **** /* * If the game has a small amount of time remaining, quit now. ! * The last little bit of the game is very numerically instable. ! * As such, we avoid playing. */ if( m_s < FINISH_GAME_NOW){ --- 240,245 ---- /* * If the game has a small amount of time remaining, quit now. ! * The last little bit of the game is very numerically ! * instable. As such, we avoid playing. */ if( m_s < FINISH_GAME_NOW){ *************** *** 319,323 **** alpha = 0; ! System.out.print("\nt: " + t); double alpha_step = 0.1; while(Math.abs(alpha_step) > STEP_EPS) { --- 325,329 ---- alpha = 0; ! //System.out.print("\nt: " + t); double alpha_step = 0.1; while(Math.abs(alpha_step) > STEP_EPS) { *************** *** 325,329 **** // Increment alpha alpha += alpha_step; ! System.out.print(" alpha: " + alpha); // Deal with boundary cases, keep margin normalized --- 331,335 ---- // Increment alpha alpha += alpha_step; ! //System.out.print(" alpha: " + alpha); // Deal with boundary cases, keep margin normalized *************** *** 341,348 **** } ! System.out.print("\n(alpha:" + alpha + ", t:" + t + ") is, gamma + pot_diff = |" ! + vars.B + "| + |" + vars.E + "| = " ! + (Math.abs(vars.B) + Math.abs(vars.E))); ! // reverse t search direction if(sign(vars.E) != sign(t_step)) t_step /= -2; --- 347,353 ---- } ! System.out.format("\tYabaBoost: (alpha=%.4f, t=%.4f) -> (corr=%.6f, pot_diff=%.6f), " ! + "potential=%.6f\n", alpha, t, vars.B, vars.E, vars.Potential); ! // reverse t search direction if(sign(vars.E) != sign(t_step)) t_step /= -2; *************** *** 357,360 **** --- 362,371 ---- alpha = bs_alpha; t = bs_t; + + + System.out.format("YabaBoost: alpha=%.4f, t=%.4f, time left=%.4f, " + + "potential=%.4f\n", alpha, t, m_s, vars.Potential); + + m_oldS = m_s; *************** *** 383,387 **** double CONSTRAINT_EPS = 0.001; if (t < m_s && ! (Math.abs(vars.E)>CONSTRAINT_EPS || Math.abs(vars.B)>CONSTRAINT_EPS)) { m_s = m_oldS; --- 394,398 ---- double CONSTRAINT_EPS = 0.001; if (t < m_s && ! (Math.abs(vars.Potential-m_initialPotential)>CONSTRAINT_EPS || Math.abs(vars.B)>CONSTRAINT_EPS)) { m_s = m_oldS; *************** *** 466,472 **** --- 477,485 ---- // print all margins. + /* for (int i= 0; i < m_margins.length; i++){ System.out.println("Margin: " + (m_margins[i] >= 0 ? " " : "") + m_margins[i] ); } + */ } |
From: Aaron A. <aa...@us...> - 2007-05-31 10:03:04
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5926/scripts Modified Files: margin.py Log Message: now reads margins file Index: margin.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/margin.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** margin.py 27 May 2007 03:57:27 -0000 1.5 --- margin.py 31 May 2007 10:03:00 -0000 1.6 *************** *** 10,14 **** def usage(): print 'Usage: margin.py ' ! print '\t--scores=filename scores file as output by jboost' print '\t--data=filename train/test filename' print '\t--spec=filename spec filename' --- 10,15 ---- def usage(): print 'Usage: margin.py ' ! print '\t--margins=filename margins file as output by jboost (-a -2 switch)' ! print '\t--scores=filename scores file as output by jboost (-a -2 switch)' print '\t--data=filename train/test filename' print '\t--spec=filename spec filename' *************** *** 76,92 **** ! def write_gnuplot(labels, scores_list, iters, datafile): margin_list = [] for i in range(len(iters)): scores = scores_list[i] ! margins = get_margins(labels, scores); margins.sort() margin_list.append(margins) lines = [] ! for w in range(len(margins)): line = "" ! line += str(float(w)/len(margins)) for i in range(len(margin_list)): margins = margin_list[i] --- 77,93 ---- ! def write_gnuplot(scores_list, iters, datafile): margin_list = [] for i in range(len(iters)): scores = scores_list[i] ! margins = scores_list[i] #get_margins(labels, scores); margins.sort() margin_list.append(margins) lines = [] ! for w in range(len(margin_list[0])): line = "" ! line += str(float(w)/len(margin_list[0])) for i in range(len(margin_list)): margins = margin_list[i] *************** *** 166,185 **** ! def process_data(examples, labels, scores, datafile, sample): print 'Examples ' + str(len(examples)) print 'Scores ' + str(len(scores)) ! print 'Labels ' + str(len(labels)) print 'Generating margins' - margins = get_margins(labels, scores) - - if len(examples) != len(margins): - print "Don't have margin for each example" - sys.exit(2) - print 'Matching margins with data' - #pos_label, neg_label = getLabels(specfile) --- 167,179 ---- ! def process_data(examples, labels, margins, scores, datafile, sample): print 'Examples ' + str(len(examples)) print 'Scores ' + str(len(scores)) ! print 'Margins ' + str(len(margins)) print 'Generating margins' print 'Matching margins with data' #pos_label, neg_label = getLabels(specfile) *************** *** 213,217 **** try: ! opts, args= getopt.getopt(sys.argv[1:], '', ['scores=','data=','spec=','labels=', 'iteration=', 'sample']) except getopt.GetoptError, inst: print 'Received an illegal argument:', inst --- 207,211 ---- try: ! opts, args= getopt.getopt(sys.argv[1:], '', ['margins=', 'scores=','data=','spec=','labels=', 'iteration=', 'sample']) except getopt.GetoptError, inst: print 'Received an illegal argument:', inst *************** *** 219,224 **** sys.exit(2) ! scoresfile = datafile = specfile = labelsfile = sample = iteration = None for opt,arg in opts: if (opt == '--scores'): scoresfile = arg --- 213,220 ---- sys.exit(2) ! marginsfile = scoresfile = datafile = specfile = labelsfile = sample = iteration = None for opt,arg in opts: + if (opt == '--margins'): + marginsfile = arg if (opt == '--scores'): scoresfile = arg *************** *** 235,239 **** ! if(scoresfile == None or datafile == None or specfile == None): print 'Need score, data, and spec file.' usage() --- 231,235 ---- ! if(marginsfile == None or scoresfile == None or datafile == None or specfile == None): print 'Need score, data, and spec file.' usage() *************** *** 262,290 **** data= f.readlines() f.close() ! elements= int((string.split(data[0],'='))[2]) print 'Reading labels' f= open(labelsfile,'r') ! labels= f.readlines()[-elements:] f.close() ! score_list = [] if (iteration != None): iters = map(int, iteration.split(',')) for iter in iters: ! scores= [float(x) for x in data[iter*(elements+1)+1:(iter+1)*(elements+1)]] ! score_list.append(scores) else: ! scores= [float(x) for x in data[-elements:]] ! score_list.append(scores) ! ! process_data(examples, labels, score_list[len(score_list)-1], datafile, sample) ! write_gnuplot(labels, score_list, iters, datafile) - if __name__ == "__main__": --- 258,295 ---- data= f.readlines() f.close() ! score_elements= int((string.split(data[0],'='))[2]) ! ! print 'Reading margin values' ! f= open(marginsfile,'r') ! data= f.readlines() ! f.close() ! margin_elements= int((string.split(data[0],'='))[2]) print 'Reading labels' f= open(labelsfile,'r') ! labels= f.readlines()[-score_elements:] f.close() + scores = [] + margin_list = [] ! iters = [1] ! iters[0] = len(data) / (margin_elements+1) if (iteration != None): iters = map(int, iteration.split(',')) for iter in iters: ! margins = [float(x) for x in data[iter*(margin_elements+1)+1:(iter+1)*(margin_elements+1)]] ! scores = [float(x) for x in data[iter*(score_elements+1)+1:(iter+1)*(score_elements+1)]] ! margin_list.append(margins) else: ! margins = [float(x) for x in data[-margin_elements:]] ! scores = [float(x) for x in data[-score_elements:]] ! margin_list.append(margins) ! process_data(examples, labels, margin_list[len(margin_list)-1], scores, datafile, sample) + write_gnuplot(margin_list, iters, datafile) if __name__ == "__main__": |
From: Aaron A. <aa...@us...> - 2007-05-30 07:41:59
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14220 Modified Files: MulticlassWrapMH.java Log Message: muliclass and multilabel margins bug fixed Index: MulticlassWrapMH.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/MulticlassWrapMH.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MulticlassWrapMH.java 29 May 2007 05:03:57 -0000 1.2 --- MulticlassWrapMH.java 30 May 2007 07:41:55 -0000 1.3 *************** *** 360,384 **** } ! public double[] getMargins(Label l) { ! double[] ret; ! if (m_isMultiLabel) { ! ret = new double[m_numLabels]; ! } else { ! ret = new double[1]; ! } for (int j = 0; j < m_numLabels; j++) { ! if (m_isMultiLabel) { ! ret[j] = preds[j].getMargins(new Label(l.getMultiValue(j) ? ! 1 : 0))[0]; ! } else { ! if (l.getMultiValue(j)){ ! ret[0] = preds[j].getMargins(new Label(l.getMultiValue(j) ? ! 1 : 0))[0]; ! } } } return ret; } public double[] getClassScores() { double[] scores = new double[m_numLabels]; --- 360,399 ---- } ! public double[] getMarginsSingleLabel(Label l) { ! int maxClass = -1; ! double maxScore = Double.MIN_VALUE; ! int thisClass = -1; ! double thisScore = 0; for (int j = 0; j < m_numLabels; j++) { ! double predScore = preds[j].getClassScores()[1]; ! if (l.getMultiValue(j)){ ! thisClass = j; ! thisScore = predScore; ! } else if (maxScore < predScore) { ! maxScore = predScore; ! maxClass = j; } } + double[] ret = new double[1]; + ret[0] = thisScore - maxScore; + return ret; + } + + public double[] getMarginsMultiLabel(Label l) { + double[] ret = new double[m_numLabels]; + for (int j = 0; j < m_numLabels; j++) { + ret[j] = preds[j].getMargins(new Label(l.getMultiValue(j) ? + 1 : 0))[0]; + } return ret; } + + public double[] getMargins(Label l) { + if (m_isMultiLabel) + return getMarginsMultiLabel(l); + return getMarginsSingleLabel(l); + } + public double[] getClassScores() { double[] scores = new double[m_numLabels]; |
From: Aaron A. <aa...@us...> - 2007-05-29 05:05:52
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17698/controller Modified Files: Configuration.java Log Message: version 1.3 Index: Configuration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Configuration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Configuration.java 27 May 2007 11:20:23 -0000 1.3 --- Configuration.java 29 May 2007 05:05:47 -0000 1.4 *************** *** 54,58 **** private Vector m_validCommands; private String m_unSpecified; ! public final static String VERSION="1.2"; private final static String m_usage = "" + "jboost Version " + VERSION + "\n" --- 54,58 ---- private Vector m_validCommands; private String m_unSpecified; ! public final static String VERSION="1.3"; private final static String m_usage = "" + "jboost Version " + VERSION + "\n" |
From: Aaron A. <aa...@us...> - 2007-05-29 05:05:27
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17610/monitor Modified Files: Monitor.java Log Message: monitor can now output margins as well as scores Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Monitor.java 16 May 2007 21:16:30 -0000 1.2 --- Monitor.java 29 May 2007 05:05:24 -0000 1.3 *************** *** 21,215 **** */ public class Monitor { ! private static Date startTime; ! private static Date afterInitTime; ! private static Date endTime; ! private String outputStem; ! private PrintWriter infoStream; // the stream for providing ! private String infoFileName; ! // a high-level log of the program's progress. ! private PrintWriter scoresStream; // a stream for the training data scores ! private String scoresOutputFileName; ! private int scoresPrintRate; ! // parameter that controls when scores are printed ! private PrintWriter testScoresStream; // a stream for the test data scores ! private String testScoresOutputFileName; ! private PrintWriter samplingStream; ! // a stream for logging resampling activity ! private String samplingOutputFileName; ! private static String logOutputFileName; ! private static PrintWriter logStream; // a central stream for all ! // logging/debugging purposes ! private ExampleSet trainSet; // the training ExampleSet ! private ExampleSet testSet; // the test ExampleSet ! private Booster m_booster; // used to get theoretical bound and m_margins ! /** ! * a public variable that stores the logging level for this run. The variable ! * should be checked before each call to log(). Calls to log should be of the ! * form</br> ! * <tt> ! if(Monitor.logLevel> 5) Monitor.log("log message"); ! </tt> ! */ ! public static int logLevel= 0; ! public static void init_log(Configuration config) throws IOException { ! String stem= config.getString("S", "data"); ! logOutputFileName= config.getString("log", stem + ".log"); ! logLevel= config.getInt("loglevel", 2); ! if (logLevel < 2) { ! logStream= new PrintWriter(System.out); ! } else { ! logStream= ! new PrintWriter(new BufferedWriter(new FileWriter(logOutputFileName))); } ! startTime= new Date(); // remember time at start to report it later ! } ! /** a central place to print debugging logs */ ! public static void log(Object message) { ! logStream.println(message); ! } ! /** close the logging file */ ! public static void closeLog() { ! logStream.close(); ! } ! /** ! * The constructor ! * ! * @param config a configuration object with the run-time parameters ! * @param trainSet the training set (to calcualte training error) ! * @param testSet the test set ! * @param m_booster the m_booster (to compute m_margins) ! */ ! public Monitor(Booster booster, ControllerConfiguration config) { ! trainSet= config.getTrainSet(); ! testSet= config.getTestSet(); ! m_booster= booster; ! outputStem= config.getString("S", "noname_out"); ! infoFileName= config.getString("info", outputStem + ".info"); ! scoresOutputFileName= outputStem + ".train.scores"; ! testScoresOutputFileName= outputStem + ".test.scores"; ! samplingOutputFileName= outputStem + ".sampling"; ! try { ! infoStream= ! new PrintWriter( ! new BufferedWriter(new FileWriter(outputStem + ".info"))); ! infoStream.println("Command line parameters: " + config.getString("args")); ! infoStream.println(); ! infoStream.println("Configuration parameters:\n" + config); ! infoStream.println(""); ! infoStream.println("FILENAMES"); ! infoStream.println("specFileName = " + config.getSpecFileName()); ! infoStream.println("trainFileName = " + config.getTrainFileName()); ! infoStream.println("testFileName = " + config.getTestFileName()); ! infoStream.println("scoresOutputFileName = " + scoresOutputFileName); ! infoStream.println("testScoresOutputFileName = " + ! testScoresOutputFileName); ! infoStream.println("resultOutputFileName = " + ! config.getResultOutputFileName()); ! infoStream.println("samplingOutputFileName = " + samplingOutputFileName); ! infoStream.println("logOutputFileName = " + logOutputFileName); ! infoStream.println(""); ! infoStream.println("Train set size = " + trainSet.getExampleNo()); ! infoStream.println("Test set size = " + testSet.getExampleNo()); ! infoStream.println(""); ! scoresPrintRate= config.getInt("a", 0); ! if (scoresPrintRate != 0) { ! scoresStream= new PrintWriter(new BufferedWriter( ! new FileWriter(scoresOutputFileName))); ! testScoresStream= new PrintWriter(new BufferedWriter( ! new FileWriter(testScoresOutputFileName))); ! samplingStream= new PrintWriter(new BufferedWriter( ! new FileWriter(samplingOutputFileName))); ! logLabels(); ! // output train and test m_labels onto the samplingStream ! samplingStream.close(); ! } ! afterInitTime= new Date(); ! infoStream.println("Init Start time = " + startTime); ! infoStream.println("Learn Start time = " + afterInitTime); ! infoStream.println("iter \tbound \ttrain \ttest"); ! infoStream.flush(); ! } catch (IOException e) { ! throw new RuntimeException( ! "monitor failed to open file for output\n" + e.getMessage()); } - } ! /** print the m_labels of trainSet and testSet onto samplingStream */ ! private void logLabels() { ! ArrayList labels= trainSet.getBinaryLabels(); ! samplingStream.println("train labels, elements=" + labels.size()); ! for (int i= 0; i < labels.size(); i++) { ! samplingStream.println(((Boolean) labels.get(i)).booleanValue() ? "+1" : "-1"); } ! labels.clear(); // release memory ! labels= testSet.getBinaryLabels(); ! samplingStream.println("test labels, elements=" + labels.size()); ! for (int i= 0; i < labels.size(); i++) { ! samplingStream.println(((Boolean) labels.get(i)).booleanValue() ? "+1" : "-1"); } - labels.clear(); // release memory - labels= null; - } ! /** generate logs for current boosting iteration */ ! public void logIteration(int iter, Predictor combined, Predictor base) { ! double trainError= trainSet.calcError(iter, combined, base); ! double testError= testSet.calcError(iter, combined, base); ! double theoryBound= m_booster.getTheoryBound(); ! NumberFormat f= new DecimalFormat("0.000"); ! infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" ! + f.format(trainError) + "\t" + f.format(testError)); ! infoStream.flush(); ! logScores(iter, combined, base); ! infoStream.println(); ! } ! /** output the scores distribution of the training set */ ! private void logScores(int iter, Predictor combined, Predictor base) { ! if (scoresPrintRate == 0 || // never print scores ! (scoresPrintRate > 0 && scoresPrintRate != iter)) ! // or print scores only on iteration scoresPrintRate ! return; ! if (scoresPrintRate == -1) { ! // print score when highest order digit in iter changes. ! double m= ! java.lang.Math.floor( ! java.lang.Math.log(iter) / java.lang.Math.log(10.0)); ! int t= (int) java.lang.Math.pow(10.0, m); ! if (iter == 0) ! t= 1; // fix bug in "pow" ! if ((iter % t) != 0) ! return; } - infoStream.print(" \t# output scores #"); - // output training scores - // double m_margins[] = m_booster.getMargins(); // get m_margins from the - // m_booster - ArrayList trainScores= trainSet.calcScores(iter, combined, base); - scoresStream.println( - "iteration=" + iter + ", elements=" + trainScores.size()); - for (int i= 0; i < trainScores.size(); i++) - scoresStream.println((Double) trainScores.get(i)); - trainScores= null; // release memory - // output test scores - ArrayList testScores= testSet.calcScores(iter, combined, base); - testScoresStream.println( - "iteration=" + iter + ", elements=" + testScores.size()); - for (int i= 0; i < testScores.size(); i++) - testScoresStream.println((Double) testScores.get(i)); - testScores.clear(); // release memory - testScores= null; - } ! /** close the monitor output files */ ! public void close() throws IOException { ! endTime= new Date(); ! infoStream.println("End time=" + endTime); ! infoStream.close(); ! if (scoresStream != null) ! scoresStream.close(); ! if (testScoresStream != null) ! testScoresStream.close(); ! log("finished closing output files"); ! } } --- 21,293 ---- */ public class Monitor { ! private static Date startTime; ! private static Date afterInitTime; ! private static Date endTime; ! private String outputStem; ! private PrintWriter infoStream; // the stream for providing ! private String infoFilename; ! // a high-level log of the program's progress. ! ! ! /** parameter that controls when scores are printed */ ! private int scoresPrintRate; ! private PrintWriter testScoresStream; // a stream for the test data scores ! private String testScoresOutputFilename; ! private PrintWriter trainScoresStream; // a stream for the training data scores ! private String trainScoresOutputFilename; ! ! /** margin streams and varialbes */ ! private int marginPrintRate; ! private PrintWriter testMarginStream; // a stream for the test data scores ! private String testMarginOutputFilename; ! private PrintWriter trainMarginStream; // a stream for the training data scores ! private String trainMarginOutputFilename; ! ! /** a stream for logging resampling activity */ ! private PrintWriter samplingStream; ! private String samplingOutputFilename; ! ! /** log file info */ ! private static String logOutputFilename; ! private static PrintWriter logStream; ! ! ! private ExampleSet trainSet; // the training ExampleSet ! private ExampleSet testSet; // the test ExampleSet ! private Booster m_booster; // used to get theoretical bound and m_margins ! /** ! * a public variable that stores the logging level for this run. The variable ! * should be checked before each call to log(). Calls to log should be of the ! * form</br> ! * <tt> ! if(Monitor.logLevel> 5) Monitor.log("log message"); ! </tt> ! */ ! public static int logLevel= 0; ! public static void init_log(Configuration config) throws IOException { ! String stem= config.getString("S", "data"); ! logOutputFilename= config.getString("log", stem + ".log"); ! logLevel= config.getInt("loglevel", 2); ! if (logLevel < 2) { ! logStream= new PrintWriter(System.out); ! } else { ! logStream= ! new PrintWriter(new BufferedWriter(new FileWriter(logOutputFilename))); ! } ! startTime= new Date(); // remember time at start to report it later } ! /** a central place to print debugging logs */ ! public static void log(Object message) { ! logStream.println(message); ! } ! /** close the logging file */ ! public static void closeLog() { ! logStream.close(); ! } ! /** ! * The constructor ! * ! * @param config a configuration object with the run-time parameters ! * @param trainSet the training set (to calcualte training error) ! * @param testSet the test set ! * @param m_booster the m_booster (to compute m_margins) ! */ ! public Monitor(Booster booster, ControllerConfiguration config) { ! trainSet= config.getTrainSet(); ! testSet= config.getTestSet(); ! m_booster= booster; ! outputStem= config.getString("S", "noname_out"); ! infoFilename= config.getString("info", outputStem + ".info"); ! ! trainScoresOutputFilename= outputStem + ".train.scores"; ! testScoresOutputFilename= outputStem + ".test.scores"; ! trainMarginOutputFilename= outputStem + ".train.margin"; ! testMarginOutputFilename= outputStem + ".test.margin"; ! ! samplingOutputFilename= outputStem + ".sampling"; ! try { ! infoStream= ! new PrintWriter( ! new BufferedWriter(new FileWriter(outputStem + ".info"))); ! infoStream.println("Command line parameters: " + config.getString("args")); ! infoStream.println(); ! infoStream.println("Configuration parameters:\n" + config); ! infoStream.println(""); ! infoStream.println("FILENAMES"); ! infoStream.println("specFilename = " + config.getSpecFileName()); ! infoStream.println("trainFilename = " + config.getTrainFileName()); ! infoStream.println("testFilename = " + config.getTestFileName()); ! infoStream.println("trainScoresOutputFilename = " ! +trainScoresOutputFilename); ! infoStream.println("testScoresOutputFilename = " + ! testScoresOutputFilename); ! infoStream.println("trainMarginOutputFilename = " ! +trainMarginOutputFilename); ! infoStream.println("testMarginOutputFilename = " ! +testMarginOutputFilename); ! infoStream.println("resultOutputFilename = " + ! config.getResultOutputFileName()); ! infoStream.println("samplingOutputFilename = " + samplingOutputFilename); ! infoStream.println("logOutputFilename = " + logOutputFilename); ! infoStream.println(""); ! infoStream.println("Train set size = " + trainSet.getExampleNo()); ! infoStream.println("Test set size = " + testSet.getExampleNo()); ! infoStream.println(""); ! scoresPrintRate= config.getInt("a", 0); ! marginPrintRate= scoresPrintRate; ! if (scoresPrintRate != 0) { ! trainScoresStream= new PrintWriter(new BufferedWriter( ! new FileWriter(trainScoresOutputFilename))); ! testScoresStream= new PrintWriter(new BufferedWriter( ! new FileWriter(testScoresOutputFilename))); ! samplingStream= new PrintWriter(new BufferedWriter( ! new FileWriter(samplingOutputFilename))); ! logLabels(); ! // output train and test m_labels onto the samplingStream ! samplingStream.close(); ! } ! if (marginPrintRate != 0) { ! trainMarginStream= new PrintWriter( ! new BufferedWriter( ! new FileWriter(trainMarginOutputFilename))); ! testMarginStream= new PrintWriter( ! new BufferedWriter( ! new FileWriter(testMarginOutputFilename))); ! } ! afterInitTime= new Date(); ! infoStream.println("Init Start time = " + startTime); ! infoStream.println("Learn Start time = " + afterInitTime); ! infoStream.println("iter \tbound \ttrain \ttest"); ! infoStream.flush(); ! } catch (IOException e) { ! throw new RuntimeException( ! "monitor failed to open file for output\n" + e.getMessage()); ! } } ! /** print the m_labels of trainSet and testSet onto samplingStream */ ! private void logLabels() { ! ArrayList labels= trainSet.getBinaryLabels(); ! samplingStream.println("train labels, elements=" + labels.size()); ! for (int i= 0; i < labels.size(); i++) { ! samplingStream.println(((Boolean) labels.get(i)).booleanValue() ? "+1" : "-1"); ! } ! labels.clear(); // release memory ! labels= testSet.getBinaryLabels(); ! samplingStream.println("test labels, elements=" + labels.size()); ! for (int i= 0; i < labels.size(); i++) { ! samplingStream.println(((Boolean) labels.get(i)).booleanValue() ? "+1" : "-1"); ! } ! labels.clear(); // release memory ! labels= null; } ! ! /** generate logs for current boosting iteration */ ! public void logIteration(int iter, Predictor combined, Predictor base) { ! double trainError= trainSet.calcError(iter, combined, base); ! double testError= testSet.calcError(iter, combined, base); ! double theoryBound= m_booster.getTheoryBound(); ! NumberFormat f= new DecimalFormat("0.000"); ! infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" ! + f.format(trainError) + "\t" + f.format(testError)); ! infoStream.flush(); ! logScores(iter, combined, base); ! logMargins(iter, combined, base); ! infoStream.println(); } ! /** output the scores distribution of the training set */ ! private void logScores(int iter, Predictor combined, Predictor base) { ! if (scoresPrintRate == 0 || // never print scores ! (scoresPrintRate > 0 && scoresPrintRate != iter)) ! // or print scores only on iteration scoresPrintRate ! return; ! if (scoresPrintRate == -1) { ! // print score when highest order digit in iter changes. ! double m= ! java.lang.Math.floor( ! java.lang.Math.log(iter) / java.lang.Math.log(10.0)); ! int t= (int) java.lang.Math.pow(10.0, m); ! if (iter == 0) ! t= 1; // fix bug in "pow" ! if ((iter % t) != 0) ! return; ! } ! infoStream.print(" \t# output scores #"); ! // output training scores ! // double m_margins[] = m_booster.getMargins(); // get m_margins from the ! // m_booster ! ArrayList trainScores= trainSet.calcScores(iter, combined, base); ! trainScoresStream.println( ! "iteration=" + iter + ", elements=" + trainScores.size()); ! for (int i= 0; i < trainScores.size(); i++) ! trainScoresStream.println((Double) trainScores.get(i)); ! trainScores= null; // release memory ! // output test scores ! ArrayList testScores= testSet.calcScores(iter, combined, base); ! testScoresStream.println( ! "iteration=" + iter + ", elements=" + testScores.size()); ! for (int i= 0; i < testScores.size(); i++) ! testScoresStream.println((Double) testScores.get(i)); ! testScores.clear(); // release memory ! testScores= null; ! } ! ! ! /** output the scores distribution of the training set */ ! private void logMargins(int iter, Predictor combined, Predictor base) { ! if (marginPrintRate == 0 || // never print scores ! (marginPrintRate > 0 && scoresPrintRate != iter)) ! // or print scores only on iteration scoresPrintRate ! return; ! if (marginPrintRate == -1) { ! // print score when highest order digit in iter changes. ! double m= ! java.lang.Math.floor( ! java.lang.Math.log(iter) / java.lang.Math.log(10.0)); ! int t= (int) java.lang.Math.pow(10.0, m); ! if (iter == 0) ! t= 1; // fix bug in "pow" ! if ((iter % t) != 0) ! return; ! } ! infoStream.print(" \t# output margins #"); ! // output training scores ! // double m_margins[] = m_booster.getMargins(); // get m_margins from the ! // m_booster ! ArrayList trainMargin= trainSet.calcMargins(iter, combined, base); ! trainMarginStream.println( ! "iteration=" + iter + ", elements=" + trainMargin.size()); ! for (int i= 0; i < trainMargin.size(); i++) ! trainMarginStream.println((Double) trainMargin.get(i)); ! trainMargin= null; // release memory ! // output test scores ! ArrayList testMargin= testSet.calcMargins(iter, combined, base); ! testMarginStream.println( ! "iteration=" + iter + ", elements=" + testMargin.size()); ! for (int i= 0; i < testMargin.size(); i++) ! testMarginStream.println((Double) testMargin.get(i)); ! testMargin.clear(); // release memory ! testMargin= null; } ! ! ! ! /** close the monitor output files */ ! public void close() throws IOException { ! endTime= new Date(); ! infoStream.println("End time=" + endTime); ! infoStream.close(); ! if (trainScoresStream != null) ! trainScoresStream.close(); ! if (testScoresStream != null) ! testScoresStream.close(); ! if (trainMarginStream != null) ! trainMarginStream.close(); ! if (testMarginStream != null) ! testMarginStream.close(); ! log("finished closing output files"); ! } } |
From: Aaron A. <aa...@us...> - 2007-05-29 05:04:03
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16590/booster Modified Files: AbstractBooster.java MulticlassWrapMH.java Log Message: multiclass and multilabel are handled a little differently when outputting margins. Index: MulticlassWrapMH.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/MulticlassWrapMH.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MulticlassWrapMH.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- MulticlassWrapMH.java 29 May 2007 05:03:57 -0000 1.2 *************** *** 23,29 **** class MulticlassWrapMH extends AbstractBooster { ! private AbstractBooster booster; // underlying booster ! private int num_classes; // number of labels /** --- 23,35 ---- class MulticlassWrapMH extends AbstractBooster { + + /** The underlying m_booster */ + private AbstractBooster m_booster; + + /** The number of labels */ + private int m_numLabels; ! /** The number of labels */ ! private boolean m_isMultiLabel; /** *************** *** 32,43 **** * @param k total number of m_labels */ ! MulticlassWrapMH(AbstractBooster booster, int k) { ! this.booster = booster; ! num_classes = k; } public String toString() { ! if (booster==null) { ! String msg = "MulticlassWrapMH.toString: booster is null"; if (Monitor.logLevel>3) { Monitor.log(msg); --- 38,50 ---- * @param k total number of m_labels */ ! MulticlassWrapMH(AbstractBooster booster, int numLabels, boolean isMultiLabel) { ! m_booster = booster; ! m_numLabels = numLabels; ! m_isMultiLabel = isMultiLabel; } public String toString() { ! if (m_booster==null) { ! String msg = "MulticlassWrapMH.toString: m_booster is null"; if (Monitor.logLevel>3) { Monitor.log(msg); *************** *** 46,51 **** } ! return ("MulticlassWrapMH. # of classes = " + num_classes + ! ".\nUnderlying booster:\n" + booster); } --- 53,58 ---- } ! return ("MulticlassWrapMH. # of classes = " + m_numLabels + ! ".\nUnderlying m_booster:\n" + m_booster); } *************** *** 58,64 **** */ public void addExample(int index, Label label, double weight) { ! int s = index * num_classes; ! for (int j = 0; j < num_classes; j++) { ! booster.addExample(s+j, new Label(label.getMultiValue(j) ? 1 : 0), --- 65,71 ---- */ public void addExample(int index, Label label, double weight) { ! int s = index * m_numLabels; ! for (int j = 0; j < m_numLabels; j++) { ! m_booster.addExample(s+j, new Label(label.getMultiValue(j) ? 1 : 0), *************** *** 68,76 **** public void finalizeData() { ! booster.finalizeData(); } public void clear() { ! booster.clear(); } --- 75,83 ---- public void finalizeData() { ! m_booster.finalizeData(); } public void clear() { ! m_booster.clear(); } *************** *** 87,91 **** */ public double calculateWeight(double margin) { ! return booster.calculateWeight(margin); } --- 94,98 ---- */ public double calculateWeight(double margin) { ! return m_booster.calculateWeight(margin); } *************** *** 93,104 **** public void update(Prediction[] preds, int[][] index) { int num_preds = preds.length; ! Prediction[] upreds = new Prediction[num_preds * num_classes]; ! int[][] uindex = new int[index.length * num_classes][]; int i, j, t, k; ! // create array of predictions to pass to underlying booster t = 0; for (i = 0; i < num_preds; i++) { ! for (j = 0; j < num_classes; j++) { upreds[t] = ((MultiPrediction) preds[i]).preds[j]; t++; --- 100,112 ---- public void update(Prediction[] preds, int[][] index) { int num_preds = preds.length; ! Prediction[] upreds = new Prediction[num_preds * m_numLabels]; ! int[][] uindex = new int[index.length * m_numLabels][]; int i, j, t, k; ! ! // create array of predictions to pass to underlying booster t = 0; for (i = 0; i < num_preds; i++) { ! for (j = 0; j < m_numLabels; j++) { upreds[t] = ((MultiPrediction) preds[i]).preds[j]; t++; *************** *** 109,129 **** t = 0; for (i = 0; i < index.length; i++) { ! for (j = 0; j < num_classes; j++) { uindex[t] = new int[index[i].length]; for (k = 0; k < index[i].length; k++) ! uindex[t][k] = index[i][k] * num_classes + j; t++; } } ! booster.update(upreds, uindex); } /** ! * computes theoretical bound as (num_classes/2) * theoretical * bound for underlying booster. This computation may not be * correct in all cases. */ public double getTheoryBound() { ! return 0.5 * num_classes * booster.getTheoryBound(); } --- 117,137 ---- t = 0; for (i = 0; i < index.length; i++) { ! for (j = 0; j < m_numLabels; j++) { uindex[t] = new int[index[i].length]; for (k = 0; k < index[i].length; k++) ! uindex[t][k] = index[i][k] * m_numLabels + j; t++; } } ! m_booster.update(upreds, uindex); } /** ! * computes theoretical bound as (m_numLabels/2) * theoretical * bound for underlying booster. This computation may not be * correct in all cases. */ public double getTheoryBound() { ! return 0.5 * m_numLabels * m_booster.getTheoryBound(); } *************** *** 133,137 **** */ public double[] getMargins() { ! return booster.getMargins(); } --- 141,145 ---- */ public double[] getMargins() { ! return m_booster.getMargins(); } *************** *** 141,158 **** */ public Prediction[] getPredictions(Bag[] b, int[][] exampleIndex) { ! Bag[] ubags = new Bag[b.length * num_classes]; for (int i = 0; i < b.length; i++) ! for (int j = 0; j < num_classes; j++) ! ubags[i * num_classes + j] = ((MultiBag) b[i]).bags[j]; ! Prediction[] upreds = booster.getPredictions(ubags, exampleIndex); Prediction[] preds = new Prediction[b.length]; for (int i = 0; i < b.length; i++) { preds[i] = new MultiPrediction(); ! for (int j = 0; j < num_classes; j++) ((MultiPrediction) preds[i]).preds[j] = ! upreds[i * num_classes + j]; } return preds; --- 149,166 ---- */ public Prediction[] getPredictions(Bag[] b, int[][] exampleIndex) { ! Bag[] ubags = new Bag[b.length * m_numLabels]; for (int i = 0; i < b.length; i++) ! for (int j = 0; j < m_numLabels; j++) ! ubags[i * m_numLabels + j] = ((MultiBag) b[i]).bags[j]; ! Prediction[] upreds = m_booster.getPredictions(ubags, exampleIndex); Prediction[] preds = new Prediction[b.length]; for (int i = 0; i < b.length; i++) { preds[i] = new MultiPrediction(); ! for (int j = 0; j < m_numLabels; j++) ((MultiPrediction) preds[i]).preds[j] = ! upreds[i * m_numLabels + j]; } return preds; *************** *** 167,177 **** public double getLoss(Bag[] b) { ! Bag[] ubags = new Bag[b.length * num_classes]; for (int i = 0; i < b.length; i++) ! for (int j = 0; j < num_classes; j++) ! ubags[i * num_classes + j] = ((MultiBag) b[i]).bags[j]; ! return booster.getLoss(ubags); } --- 175,185 ---- public double getLoss(Bag[] b) { ! Bag[] ubags = new Bag[b.length * m_numLabels]; for (int i = 0; i < b.length; i++) ! for (int j = 0; j < m_numLabels; j++) ! ubags[i * m_numLabels + j] = ((MultiBag) b[i]).bags[j]; ! return m_booster.getLoss(ubags); } *************** *** 186,197 **** private MultiBag() { ! bags = new Bag[num_classes]; ! for (int j = 0; j < num_classes; j++) ! bags[j] = booster.newBag(); } public String toString() { String s = "MultiBag.\n"; ! for (int j = 0; j < num_classes; j++) s += "bag " + j + ":\n" + bags[j]; return s; --- 194,205 ---- private MultiBag() { ! bags = new Bag[m_numLabels]; ! for (int j = 0; j < m_numLabels; j++) ! bags[j] = m_booster.newBag(); } public String toString() { String s = "MultiBag.\n"; ! for (int j = 0; j < m_numLabels; j++) s += "bag " + j + ":\n" + bags[j]; return s; *************** *** 199,208 **** public void reset() { ! for (int j = 0; j < num_classes; j++) bags[j].reset(); } public boolean isWeightless() { ! for (int j = 0; j < num_classes; j++) if (! bags[j].isWeightless() ) { return false; --- 207,216 ---- public void reset() { ! for (int j = 0; j < m_numLabels; j++) bags[j].reset(); } public boolean isWeightless() { ! for (int j = 0; j < m_numLabels; j++) if (! bags[j].isWeightless() ) { return false; *************** *** 212,223 **** public void addExample(int index) { ! int s = index * num_classes; ! for (int j = 0; j < num_classes; j++) bags[j].addExample(s + j); } public void subtractExample(int index) { ! int s = index * num_classes; ! for (int j = 0; j < num_classes; j++) bags[j].subtractExample(s + j); } --- 220,231 ---- public void addExample(int index) { ! int s = index * m_numLabels; ! for (int j = 0; j < m_numLabels; j++) bags[j].addExample(s + j); } public void subtractExample(int index) { ! int s = index * m_numLabels; ! for (int j = 0; j < m_numLabels; j++) bags[j].subtractExample(s + j); } *************** *** 227,233 **** int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * num_classes; bags[0].addExampleList(s); ! for (int j = 1; j < num_classes; j++) { for (i = 0; i < l.length; i++) s[i]++; --- 235,241 ---- int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * m_numLabels; bags[0].addExampleList(s); ! for (int j = 1; j < m_numLabels; j++) { for (i = 0; i < l.length; i++) s[i]++; *************** *** 240,246 **** int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * num_classes; bags[0].subtractExampleList(s); ! for (int j = 1; j < num_classes; j++) { for (i = 0; i < l.length; i++) s[i]++; --- 248,254 ---- int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * m_numLabels; bags[0].subtractExampleList(s); ! for (int j = 1; j < m_numLabels; j++) { for (i = 0; i < l.length; i++) s[i]++; *************** *** 251,255 **** public void addBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < num_classes; j++) bags[j].addBag(other.bags[j]); } --- 259,263 ---- public void addBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < m_numLabels; j++) bags[j].addBag(other.bags[j]); } *************** *** 257,261 **** public void subtractBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < num_classes; j++) bags[j].subtractBag(other.bags[j]); } --- 265,269 ---- public void subtractBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < m_numLabels; j++) bags[j].subtractBag(other.bags[j]); } *************** *** 263,273 **** public void copyBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < num_classes; j++) bags[j].copyBag(other.bags[j]); } public void refresh(int index) { ! int s = index * num_classes; ! for (int j = 0; j < num_classes; j++) bags[j].refresh(s + j); } --- 271,281 ---- public void copyBag(Bag b) { MultiBag other = (MultiBag) b; ! for (int j = 0; j < m_numLabels; j++) bags[j].copyBag(other.bags[j]); } public void refresh(int index) { ! int s = index * m_numLabels; ! for (int j = 0; j < m_numLabels; j++) bags[j].refresh(s + j); } *************** *** 277,283 **** int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * num_classes; bags[0].refreshList(s); ! for (int j = 1; j < num_classes; j++) { for (i = 0; i < l.length; i++) s[i]++; --- 285,291 ---- int[] s = new int[l.length]; for (i = 0; i < l.length; i++) ! s[i] = l[i] * m_numLabels; bags[0].refreshList(s); ! for (int j = 1; j < m_numLabels; j++) { for (i = 0; i < l.length; i++) s[i]++; *************** *** 292,296 **** public double getLoss() { double loss = 0.0; ! for (int j = 0; j < num_classes; j++) loss += bags[j].getLoss(); return loss; --- 300,304 ---- public double getLoss() { double loss = 0.0; ! for (int j = 0; j < m_numLabels; j++) loss += bags[j].getLoss(); return loss; *************** *** 300,304 **** throws jboost.NotSupportedException { double loss = 0.0; ! for (int j = 0; j < num_classes; j++) loss += bags[j].getLoss(s); return loss; --- 308,312 ---- throws jboost.NotSupportedException { double loss = 0.0; ! for (int j = 0; j < m_numLabels; j++) loss += bags[j].getLoss(s); return loss; *************** *** 311,314 **** --- 319,325 ---- * underlying booster, one for each class. */ class MultiPrediction extends Prediction { + /** + * The predictions made. Has same length as the number of classes. + */ private Prediction[] preds; *************** *** 317,321 **** */ private MultiPrediction() { ! preds = new Prediction[num_classes]; } --- 328,332 ---- */ private MultiPrediction() { ! preds = new Prediction[m_numLabels]; } *************** *** 323,327 **** MultiPrediction newpred = new MultiPrediction(); ! for (int j = 0; j < num_classes; j++) { newpred.preds[j] = (Prediction) preds[j].clone(); } --- 334,338 ---- MultiPrediction newpred = new MultiPrediction(); ! for (int j = 0; j < m_numLabels; j++) { newpred.preds[j] = (Prediction) preds[j].clone(); } *************** *** 330,334 **** public Prediction add(Prediction p) { ! for (int j = 0; j < num_classes; j++) { preds[j].add(((MultiPrediction) p).preds[j]); } --- 341,345 ---- public Prediction add(Prediction p) { ! for (int j = 0; j < m_numLabels; j++) { preds[j].add(((MultiPrediction) p).preds[j]); } *************** *** 337,341 **** public Prediction scale(double w) { ! for (int j = 0; j < num_classes; j++) preds[j].scale(w); return this; --- 348,352 ---- public Prediction scale(double w) { ! for (int j = 0; j < m_numLabels; j++) preds[j].scale(w); return this; *************** *** 343,347 **** public Prediction add(double w, Prediction p) { ! for (int j = 0; j < num_classes; j++) { preds[j].add(w, ((MultiPrediction) p).preds[j]); } --- 354,358 ---- public Prediction add(double w, Prediction p) { ! for (int j = 0; j < m_numLabels; j++) { preds[j].add(w, ((MultiPrediction) p).preds[j]); } *************** *** 350,357 **** public double[] getMargins(Label l) { ! double[] ret = new double[num_classes]; ! for (int j = 0; j < num_classes; j++) { ! ret[j] = preds[j].getMargins(new Label(l.getMultiValue(j) ? ! 1 : 0))[0]; } return ret; --- 361,380 ---- public double[] getMargins(Label l) { ! double[] ret; ! if (m_isMultiLabel) { ! ret = new double[m_numLabels]; ! } else { ! ret = new double[1]; ! } ! for (int j = 0; j < m_numLabels; j++) { ! if (m_isMultiLabel) { ! ret[j] = preds[j].getMargins(new Label(l.getMultiValue(j) ? ! 1 : 0))[0]; ! } else { ! if (l.getMultiValue(j)){ ! ret[0] = preds[j].getMargins(new Label(l.getMultiValue(j) ? ! 1 : 0))[0]; ! } ! } } return ret; *************** *** 359,366 **** public double[] getClassScores() { ! double[] scores = new double[num_classes]; double[] uscore; ! for (int j = 0; j < num_classes; j++) { uscore = preds[j].getClassScores(); scores[j] = uscore[1]; --- 382,389 ---- public double[] getClassScores() { ! double[] scores = new double[m_numLabels]; double[] uscore; ! for (int j = 0; j < m_numLabels; j++) { uscore = preds[j].getClassScores(); scores[j] = uscore[1]; *************** *** 377,381 **** boolean retval= true; MultiPrediction other= (MultiPrediction) p; ! for (int k=0; k < num_classes; k++) { if (!preds[k].equals(other.preds[k])) { retval= false; --- 400,404 ---- boolean retval= true; MultiPrediction other= (MultiPrediction) p; ! for (int k=0; k < m_numLabels; k++) { if (!preds[k].equals(other.preds[k])) { retval= false; *************** *** 387,392 **** public String toString() { String s = "MultiPrediction.\n"; ! for (int j = 0; j < num_classes; j++) ! s += "prediction " + j + preds[j] + "\n"; return s; } --- 410,415 ---- public String toString() { String s = "MultiPrediction.\n"; ! for (int j = 0; j < m_numLabels; j++) ! s += "prediction " + j + ": " + preds[j] + "\n"; return s; } *************** *** 394,398 **** public String shortText() { String s = "[,"+preds[0]; ! for (int j = 0; j < num_classes; j++) s += ","+preds[j]; return s+"]"; --- 417,421 ---- public String shortText() { String s = "[,"+preds[0]; ! for (int j = 0; j < m_numLabels; j++) s += ","+preds[j]; return s+"]"; *************** *** 402,417 **** String code = ""; ! code += "typedef double Prediction_t[" + num_classes + "];\n"; code += "#define reset_pred() { \\\n"; ! for (int i = 0; i < num_classes; i++) code += " p["+i+"] = 0.0; \\\n"; code += " }\n"; code += "#define add_pred("; ! for (int i = 0; i < num_classes; i++) code += (i == 0 ? "" : ",") + "X" + i; code += ") { \\\n"; ! for (int i = 0; i < num_classes; i++) code += " p["+i+"] += X"+i+"; \\\n"; code += " }\n"; --- 425,440 ---- String code = ""; ! code += "typedef double Prediction_t[" + m_numLabels + "];\n"; code += "#define reset_pred() { \\\n"; ! for (int i = 0; i < m_numLabels; i++) code += " p["+i+"] = 0.0; \\\n"; code += " }\n"; code += "#define add_pred("; ! for (int i = 0; i < m_numLabels; i++) code += (i == 0 ? "" : ",") + "X" + i; code += ") { \\\n"; ! for (int i = 0; i < m_numLabels; i++) code += " p["+i+"] += X"+i+"; \\\n"; code += " }\n"; *************** *** 419,423 **** code += "#define finalize_pred() \\\n"; code += " (r ? ( \\\n"; ! for (int i = 0; i < num_classes; i++) code += " r["+i+"] = p["+i+"], \\\n"; code += " p[0]) : p[0])\n"; --- 442,446 ---- code += "#define finalize_pred() \\\n"; code += " (r ? ( \\\n"; ! for (int i = 0; i < m_numLabels; i++) code += " r["+i+"] = p["+i+"], \\\n"; code += " p[0]) : p[0])\n"; *************** *** 430,442 **** code += "" ! + " static private double[] p = new double[" + num_classes + "];\n" + " static private void reset_pred() {\n" + " java.util.Arrays.fill(p, 0.0);\n" + " }\n" + " static private void add_pred("; ! for (int i = 0; i < num_classes; i++) code += (i == 0 ? "" : ",") + "double x" + i; code += ") {\n"; ! for (int i = 0; i < num_classes; i++) code += " p["+i+"] += x"+i+";\n"; code += "" --- 453,465 ---- code += "" ! + " static private double[] p = new double[" + m_numLabels + "];\n" + " static private void reset_pred() {\n" + " java.util.Arrays.fill(p, 0.0);\n" + " }\n" + " static private void add_pred("; ! for (int i = 0; i < m_numLabels; i++) code += (i == 0 ? "" : ",") + "double x" + i; code += ") {\n"; ! for (int i = 0; i < m_numLabels; i++) code += " p["+i+"] += x"+i+";\n"; code += "" *************** *** 457,461 **** try { AbstractBooster ada = ! new DebugWrap(new MulticlassWrapMH(new DebugWrap(new AdaBoost(0.0)), 2)); for(int i=0; i< 10; i++) { --- 480,484 ---- try { AbstractBooster ada = ! new DebugWrap(new MulticlassWrapMH(new DebugWrap(new AdaBoost(0.0)), 2, true)); for(int i=0; i< 10; i++) { Index: AbstractBooster.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/AbstractBooster.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractBooster.java 19 May 2007 01:57:57 -0000 1.2 --- AbstractBooster.java 29 May 2007 05:03:57 -0000 1.3 *************** *** 81,85 **** // If we have a multilable or multiclass problem, we need to wrap it. if (num_labels > 2 || isMultiLabel) { ! result= new MulticlassWrapMH(result, num_labels); } --- 81,85 ---- // If we have a multilable or multiclass problem, we need to wrap it. if (num_labels > 2 || isMultiLabel) { ! result= new MulticlassWrapMH(result, num_labels, isMultiLabel); } |
From: Aaron A. <aa...@us...> - 2007-05-27 11:24:53
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28067 Modified Files: build.xml Log Message: added better copy and delete things Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** build.xml 19 May 2007 21:42:41 -0000 1.4 --- build.xml 27 May 2007 11:24:49 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- <property name="dir.dist" value="dist"/> <property name="dir.doc" value="doc"/> + <property name="dir.demo" value="demo"/> <property name="dir.lib" value="lib"/> <property name="dir.scripts" value="scripts"/> *************** *** 57,66 **** --- 58,70 ---- <target name="clean-all" depends="clean" description="Remove all generated files."> + <!-- <delete> <fileset dir="." includes="**/*.info,**/*.scores,**/*.tree,**/*.sampling,**/*.log,**/*.serialized"/> </delete> + --> <delete dir="${dir.doc}/css"/> <delete dir="${dir.doc}/images"/> <delete dir="${dir.doc}/diagrams"/> + <delete dir="${dir.doc}/javadoc"/> <delete> <fileset dir="." includes="${dir.doc}/*.html" /> *************** *** 122,125 **** --- 126,131 ---- <mkdir dir="${jboost.home}/jboost-${jboost.version}" /> <mkdir dir="${jboost.home}/jboost-${jboost.version}/scripts" /> + <mkdir dir="${jboost.home}/jboost-${jboost.version}/demo" /> + <exec executable="./doc/get_doc.sh" /> *************** *** 130,133 **** --- 136,140 ---- <include name="images/" /> <include name="diagrams/" /> + <include name="javadoc/" /> </fileset> </move> *************** *** 137,141 **** <arg value="-r" /> <arg value="${jboost.home}/src" /> - <arg value="${jboost.home}/demo" /> <arg value="${jboost.home}/doc" /> <arg value="${jboost.home}/dist" /> --- 144,147 ---- *************** *** 143,146 **** --- 149,153 ---- <arg value="${jboost.home}/lib" /> <arg value="${jboost.home}/README" /> + <arg value="${jboost.home}/LICENSE" /> <arg value="${jboost.home}/CHANGES" /> <arg value="${jboost.home}/jboost" /> *************** *** 155,158 **** --- 162,188 ---- </fileset> </copy> + + <copy todir="${jboost.home}/jboost-${jboost.version}/demo/" > + <fileset dir="${dir.demo}"> + <include name="*.data" /> + <include name="*.train" /> + <include name="*.test" /> + <include name="*.spec" /> + </fileset> + </copy> + + + <exec executable="find"> + <arg value="${jboost.home}/jboost-${jboost.version}" /> + <arg value="-type" /> + <arg value="d" /> + <arg value="-name" /> + <arg value="CVS" /> + <arg value="-exec" /> + <arg value="rm" /> + <arg value="-r" /> + <arg value="{}" /> + <arg value=";" /> + </exec> |
From: Aaron A. <aa...@us...> - 2007-05-27 11:24:35
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28030 Modified Files: jboost Log Message: fixed path error Index: jboost =================================================================== RCS file: /cvsroot/jboost/jboost/jboost,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** jboost 17 May 2007 07:55:16 -0000 1.1 --- jboost 27 May 2007 11:24:32 -0000 1.2 *************** *** 2,6 **** PWD=`pwd` ! JBOOST_HOME=`echo "$PWD/$0" | sed 's/\/run_jboost\.sh//'` CLASSPATH="$JBOOST_HOME/lib/concurrent.jar:$CLASSPATH" CLASSPATH="$JBOOST_HOME/dist/jboost.jar:$CLASSPATH" --- 2,6 ---- PWD=`pwd` ! JBOOST_HOME=`echo "$PWD/$0" | sed 's/\/jboost$//'` CLASSPATH="$JBOOST_HOME/lib/concurrent.jar:$CLASSPATH" CLASSPATH="$JBOOST_HOME/dist/jboost.jar:$CLASSPATH" |
From: Aaron A. <aa...@us...> - 2007-05-27 11:24:10
|
Update of /cvsroot/jboost/jboost/src/jboost/atree In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27944/src/jboost/atree Modified Files: InstrumentedAlternatingTree.java Log Message: BrownBoost options added Index: InstrumentedAlternatingTree.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/InstrumentedAlternatingTree.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** InstrumentedAlternatingTree.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- InstrumentedAlternatingTree.java 27 May 2007 11:24:07 -0000 1.2 *************** *** 13,16 **** --- 13,17 ---- import jboost.booster.Bag; import jboost.booster.Booster; + import jboost.booster.BrownBoost; import jboost.booster.Prediction; import jboost.controller.Configuration; *************** *** 575,578 **** --- 576,588 ---- return lastBasePredictor; } + + public boolean boosterIsFinished() { + if(m_booster instanceof BrownBoost){ + BrownBoost b = (BrownBoost) m_booster; + return b.isFinished(); + } + return false; + } + //---------------------------------- Un-Implemented ----------------------------------------// public void addExample(Example e) { |
From: Aaron A. <aa...@us...> - 2007-05-27 11:23:29
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27526/src/jboost/booster Modified Files: AbstractBoosterTest.java BoosterTestSuite.java BrownBoost.java BrownBoostTest.java Log Message: BrownBoost implemented w/some tests Index: AbstractBoosterTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/AbstractBoosterTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AbstractBoosterTest.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- AbstractBoosterTest.java 27 May 2007 11:23:23 -0000 1.2 *************** *** 32,36 **** public AbstractBoosterTest(String arg0) { super(arg0); - } --- 32,35 ---- Index: BoosterTestSuite.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/BoosterTestSuite.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BoosterTestSuite.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- BoosterTestSuite.java 27 May 2007 11:23:23 -0000 1.2 *************** *** 23,29 **** suite.addTest(new TestSuite(AdaBoostTest.class)); suite.addTest(new TestSuite(LogLossBoostTest.class)); ! suite.addTest(new TestSuite(YabaBoostTest.class)); suite.addTest(new TestSuite(BrownBoostTest.class)); ! // suite.addTest(new TestSuite(MulticlassWrapMHTest.class)); //$JUnit-END$ return suite; --- 23,29 ---- suite.addTest(new TestSuite(AdaBoostTest.class)); suite.addTest(new TestSuite(LogLossBoostTest.class)); ! //suite.addTest(new TestSuite(YabaBoostTest.class)); suite.addTest(new TestSuite(BrownBoostTest.class)); ! //suite.addTest(new TestSuite(MulticlassWrapMHTest.class)); //$JUnit-END$ return suite; Index: BrownBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/BrownBoost.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BrownBoost.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- BrownBoost.java 27 May 2007 11:23:23 -0000 1.2 *************** *** 53,57 **** m_s = m_c; m_initialPotential = (1-erf(Math.sqrt(m_c)))/2; ! System.out.println("BrownBoost:\n \t m_c: " + m_c + "\n \t intial potential: " + m_initialPotential); } --- 53,67 ---- m_s = m_c; m_initialPotential = (1-erf(Math.sqrt(m_c)))/2; ! //System.out.println("BrownBoost:\n \t m_c: " + m_c + "\n \t intial potential: " + m_initialPotential); ! } ! ! ! public double getInitialPotential(){ ! return m_initialPotential; ! } ! ! ! public boolean isFinished(){ ! return m_s <= 0; } *************** *** 196,200 **** double dj = margin + bj*alpha + m_s - t; double wj = Math.exp(-(dj*dj)/m_c); ! vars.W += wj; vars.U += wj*dj*bj; --- 206,211 ---- double dj = margin + bj*alpha + m_s - t; double wj = Math.exp(-(dj*dj)/m_c); ! ! /* vars.W += wj; vars.U += wj*dj*bj; *************** *** 204,207 **** --- 215,231 ---- vars.E += erf(dj / Math.sqrt(m_c)) - erf(aj / Math.sqrt(m_c)); vars.Potential += (1-erf( dj /Math.sqrt(m_c)))/2; + */ + + + + double new_margin = margin + bj*alpha; + double new_time_remaining = m_s - t; + double new_weight = calculateWeight(new_margin, new_time_remaining); + double new_potential = calculatePotential(new_margin, new_time_remaining); + double orig_potential = calculatePotential(margin, m_s); + + vars.E += orig_potential - new_potential; // - orig_potential; + vars.B += new_weight * bj; + vars.Potential += calculatePotential(new_margin, new_time_remaining) / m_hypPredictions.length; //System.out.println("Example: " + j + ", Step: " + step + ", Label: " + label + ", Margin: " + margin + ", Pred: " + pred); *************** *** 211,214 **** --- 235,240 ---- } + + protected double solve_constraints(double hyp_err) *************** *** 229,236 **** double new_t = 0.0; - /* ! int k = 0; ! while(k < 200){ k += 1; --- 255,261 ---- double new_t = 0.0; /* ! int k = 0; ! while(k < 200){ k += 1; *************** *** 243,252 **** // then we're done! if (vars.B < EPS && vars.E < EPS){ ! System.out.println("Solved constrains by minimizing B and E."); ! break; } ! if (Math.abs(det) < EPS){ ! System.out.println("DETERMINANT IS TOO SMALL -- SUGGESTS JACOBIAN IS ALMOST SINGULAR!!!"); } --- 268,277 ---- // then we're done! if (vars.B < EPS && vars.E < EPS){ ! System.out.println("Solved constrains by minimizing B and E."); ! break; } ! if (Math.abs(det) < EPS){ ! System.out.println("DETERMINANT IS TOO SMALL -- SUGGESTS JACOBIAN IS ALMOST SINGULAR!!!"); } *************** *** 257,282 **** EPS = 0.001; if (vars.E < EPS && vars.W < EPS){ ! System.out.println("Solved constrains by minimizing E and W."); ! break; } EPS = 0.0001; if (Math.abs(alpha-new_alpha) < EPS){ ! System.out.println("Solved constraints by similar old and new alpha."); ! break; } alpha = new_alpha; t = new_t; ! } ! if (k>=100){ System.err.println("WE DIDN'T ACTUAL FINISH ANYTHING!!! WE JUST TIMED OUT!!!"); ! } ! */ double nr_alpha = alpha; double nr_t = t; ! //System.out.println("Newton-Raphson gives alpha=" + nr_alpha + ", t=" + nr_t); ! // try binary search // find the maximal value for t for which there exists a value --- 282,310 ---- EPS = 0.001; if (vars.E < EPS && vars.W < EPS){ ! System.out.println("Solved constrains by minimizing E and W."); ! break; } EPS = 0.0001; if (Math.abs(alpha-new_alpha) < EPS){ ! System.out.println("Solved constraints by similar old and new alpha."); ! break; } alpha = new_alpha; t = new_t; ! } ! if (k>=100){ System.err.println("WE DIDN'T ACTUAL FINISH ANYTHING!!! WE JUST TIMED OUT!!!"); ! } ! double nr_alpha = alpha; double nr_t = t; ! System.out.println("Newton-Raphson gives alpha=" + nr_alpha + ", t=" + nr_t); ! */ ! ! ! // try binary search // find the maximal value for t for which there exists a value *************** *** 285,336 **** //System.out.println("try binary search"); - double t_step = 0.1; - alpha=-1;//0; - t=-1;//0; - - int NUM_ITERATIONS_WITH_T_OVER_S = 10; - int count_t_large = 0; - - double EPS = 0.00001; - while(Math.abs(t_step) > EPS) { - t+=t_step; ! // TODO: correct this condition. ! if(t>m_s){ ! t = m_s; ! t_step = -t_step/2; ! count_t_large += 1; ! if(count_t_large > NUM_ITERATIONS_WITH_T_OVER_S){ break; } } - - System.out.print("\nt: " + t); - double alpha_step = 0.1; - while(Math.abs(alpha_step) > EPS) { - alpha += alpha_step; - System.out.print(" alpha: " + alpha); - vars = calc_constraints (alpha, t); - if(sign(vars.B) != sign(alpha_step)) alpha_step /= -2; // reverse alpha search direction - if(Math.abs(vars.B) < EPS) break; // found a good enough value for alpha - } - if(sign(vars.E) != sign(t_step)) t_step /= -2; // reverse t search direction - System.out.print("\n(alpha:" + alpha + ", t:" + t + ") is, gamma + pot_diff = |" - + vars.B + "| + |" + vars.E + "| = " - + (Math.abs(vars.B) + Math.abs(vars.E))); - } ! double bs_alpha = alpha; ! double bs_t = t; ! System.out.println("\nBinary Search gives alpha=" + bs_alpha + ", t=" + bs_t); ! //System.out.println("Difference is bs_alpha-nr_alpha=" + (bs_alpha - nr_alpha) + ", bs_t - nr_t" + (bs_t - nr_t)); ! alpha = bs_alpha; t = bs_t; if(t<0) { ! //System.err.println("\nERROR: The value of t: " + t); ! //System.err.println("ERROR: Bad solution for t<0"); m_s = m_oldS; return(0.0); --- 313,416 ---- //System.out.println("try binary search"); ! double t_step = 0.1; ! t=0.3; ! alpha=0; ! ! int NUM_ITERATIONS_FINISH_GAME = 10; ! int count_t_over_s = 0; ! ! double lastE = 0; ! ! double STEP_EPS = 0.00001; ! double CORR_EPS = 0.001; ! ! boolean first_iter = true; ! while(Math.abs(t_step) > STEP_EPS) { ! if(Math.abs(t_step) > m_s){ ! t_step = m_s/2 * sign(t_step); ! } ! ! t+=t_step; ! ! if (t >= m_s) { ! t = m_s - STEP_EPS; ! t_step = -t_step; ! count_t_over_s++; ! // if we keep going over m_s, the game is probably done ! if(count_t_over_s > NUM_ITERATIONS_FINISH_GAME){ ! t = m_s + 0.001; // m_s is updated after loop break; } + continue; } ! if (t < STEP_EPS) { ! t = STEP_EPS; ! t_step = -t_step; ! continue; ! } ! ! alpha = 0; ! //System.out.print("\nt: " + t); ! double alpha_step = 0.1; ! while(Math.abs(alpha_step) > STEP_EPS) { ! ! alpha += alpha_step; ! //System.out.print(" alpha: " + alpha); ! ! ! if(alpha < 0) { ! alpha = STEP_EPS; ! alpha_step = -alpha_step/2; ! continue; ! } ! ! // calculate constraints for values of alpha and t ! vars = calc_constraints (alpha, t); ! ! // reverse alpha search direction ! if(sign(vars.B) != sign(alpha_step)) alpha_step /= -2; ! if(Math.abs(vars.B) < CORR_EPS) break; ! /* ! if (alpha > 5) { ! alpha = 0.1; ! vars = calc_constraints (alpha, t); ! break; ! } ! */ ! } ! ! /* ! System.out.println("(alpha:" + alpha + ", t:" + t + ") is, gamma + pot_diff = |" ! + vars.B + "| + |" + vars.E + "| = " ! + (Math.abs(vars.B) + Math.abs(vars.E))); ! */ ! ! // reverse t search direction ! if(sign(vars.E) != sign(t_step)) t_step /= -2; ! } ! ! // The bisection (binary search) alpha and t ! double bs_alpha = alpha; ! double bs_t = t; ! ! ! /* ! System.out.println("\nBinary Search gives alpha=" + bs_alpha ! + ", t=" + bs_t + ", s=" + m_s ! + ", pot_diff=" + vars.E ! + ", pot=" + vars.Potential); ! */ ! alpha = bs_alpha; t = bs_t; + System.out.format("\tBrownBoost: alpha=%.4f, t=%.4f, time left=%.4f, " + + "potential=%.4f\n", alpha, t, m_s, vars.Potential); if(t<0) { ! System.err.println("\nERROR: The value of t: " + t); ! System.err.println("ERROR: Bad solution for t<0"); m_s = m_oldS; return(0.0); *************** *** 343,346 **** --- 423,428 ---- } + + /** *************** *** 426,430 **** public double calculatePotential(double margin, double time_remaining) { double s = time_remaining; ! return (1-erf((margin+s)/m_c))/2; } --- 508,512 ---- public double calculatePotential(double margin, double time_remaining) { double s = time_remaining; ! return (1-erf((margin+s)/Math.sqrt(m_c)))/2; } *************** *** 536,539 **** --- 618,622 ---- gamma /= total_weight; potential /= m_margins.length; + /* System.out.println("---------------------------------------"); System.out.println("---------------------------------------"); *************** *** 541,544 **** --- 624,629 ---- System.out.print(", potential (unweighted):" + potential); System.out.print(", hyp error (unweighted):" + hyp_err + "\n"); + System.out.println(""); + */ /* Index: BrownBoostTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/BrownBoostTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BrownBoostTest.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- BrownBoostTest.java 27 May 2007 11:23:23 -0000 1.2 *************** *** 27,37 **** --- 27,43 ---- protected void setUp() throws Exception { m_odd= new BrownBoost(); + ((BrownBoost)m_odd).setRuntime(1.0); m_even= new BrownBoost(); + ((BrownBoost)m_even).setRuntime(1.0); m_allTrue= new BrownBoost(); + ((BrownBoost)m_allTrue).setRuntime(1.0); m_allFalse= new BrownBoost(); + ((BrownBoost)m_allFalse).setRuntime(1.0); m_brownBoost= new BrownBoost(); + ((BrownBoost)m_brownBoost).setRuntime(1.0); m_solitaires= new BrownBoost[COUNT]; for (int i=0; i < COUNT; i++) { m_solitaires[i]= new BrownBoost(); + ((BrownBoost)m_solitaires[i]).setRuntime(1.0); } super.setUp(); *************** *** 80,83 **** --- 86,90 ---- //TODO Implement update(). // fill in booster + Bag bags[]; int[] indices= new int[COUNT]; int[] ones= new int[COUNT/2]; *************** *** 96,101 **** /* m_brownBoost.finalizeData(); ! Prediction p1= m_brownBoost.getPrediction(m_brownBoost.newBag(zeroes)); ! m_brownBoost.update(new Prediction[] {p1}, new int[][] {zeroes}); for (int i=0; i < zeroes.length; i++) { --- 103,111 ---- /* m_brownBoost.finalizeData(); ! int[][] partition = new int[][] {zeroes}; ! bags = new Bag[1]; ! bags[0] = m_brownBoost.newBag(zeroes); ! Prediction[] p1= ((BrownBoost)m_brownBoost).getPredictions(bags, partition); ! m_brownBoost.update(p1, partition); for (int i=0; i < zeroes.length; i++) { *************** *** 104,116 **** int index= zeroes[j]; double weight= m_brownBoost.m_weights[index]; ! double margin= m_brownBoost.m_oldMargins[index]; ! double s = m_brownBoost.m_oldS; double c = m_brownBoost.m_c; ! if(Double.isNaN(weight)){ ! System.err.println("Warning: weight is NaN!"); ! assertEquals(-1,1,0.0001); ! continue; ! } ! assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.00001); } } --- 114,124 ---- int index= zeroes[j]; double weight= m_brownBoost.m_weights[index]; ! double margin= m_brownBoost.m_margins[index]; ! double s = m_brownBoost.m_s; double c = m_brownBoost.m_c; ! System.out.println("weight, margin, s, c : " + weight ! + ", " + margin ! + ", " + s + ", " + c); ! assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.0001); } } *************** *** 118,123 **** for (int i=0; i < ones.length; i++) { ones[i]= indices[COUNT/2 + i]; ! p1= m_brownBoost.getPrediction(m_brownBoost.newBag(ones)); ! m_brownBoost.update(new Prediction[] {p1}, new int[][] {ones}); for (int j=0; j < ones.length; j++) { int index= ones[j]; --- 126,134 ---- for (int i=0; i < ones.length; i++) { ones[i]= indices[COUNT/2 + i]; ! bags = new Bag[1]; ! bags[0] = m_brownBoost.newBag(ones); ! int[][] parition = new int[][] {ones}; ! p1 = ((BrownBoost)m_brownBoost).getPredictions(bags, partition); ! m_brownBoost.update(p1, parition); for (int j=0; j < ones.length; j++) { int index= ones[j]; *************** *** 130,134 **** continue; } ! assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.00001); } } --- 141,145 ---- continue; } ! assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.001); } } *************** *** 169,175 **** final public void testErf() { - System.out.println("erf(0.5):"+BrownBoost.erf(0.5)); - System.out.println("erf(1):"+BrownBoost.erf(1)); - System.out.println("erf(2):"+BrownBoost.erf(2)); assertEquals(BrownBoost.erf(0.5), .5204998, 0.0001); assertEquals(BrownBoost.erf(1.0), .8427007, 0.0001); --- 180,183 ---- |
From: Aaron A. <aa...@us...> - 2007-05-27 11:22:43
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14727 Modified Files: CHANGES README Log Message: Minor changes Index: README =================================================================== RCS file: /cvsroot/jboost/jboost/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README 16 May 2007 04:06:02 -0000 1.1.1.1 --- README 27 May 2007 11:22:40 -0000 1.2 *************** *** 10,17 **** For bash, this can be accomplished via ! $> export CLASSPATH="./dist/jboost.jar:./lib/concurrent.jar" For tcsh, this can be accomplished via ! $> setenv CLASSPATH "./dist/jboost.jar:./lib/concurrent.jar" --- 10,17 ---- For bash, this can be accomplished via ! $> export CLASSPATH="JBOOST_HOME/dist/jboost.jar:JBOOST_HOME/lib/concurrent.jar" For tcsh, this can be accomplished via ! $> setenv CLASSPATH "JBOOST_HOME/dist/jboost.jar:JBOOST_HOME/lib/concurrent.jar" *************** *** 70,76 **** $> java -Xmx100M jboost.controller.Controller -S stem <other_options> ! The option '-Xmx100M' tells java to use 100 megabytes of memory, a ! number that can obviously be changed. stem is the name of the data ! files, and <other_options> can be found in the 'manpage' file. If everything works correctly, jboost will generate two files --- 70,76 ---- $> java -Xmx100M jboost.controller.Controller -S stem <other_options> ! The option '-Xmx100M' tells java to use 100 megabytes of memory. 'stem' ! is the name of the data files, and <other_options> can be found by ! running jboost without arguments. If everything works correctly, jboost will generate two files Index: CHANGES =================================================================== RCS file: /cvsroot/jboost/jboost/CHANGES,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CHANGES 16 May 2007 04:06:02 -0000 1.1.1.1 --- CHANGES 27 May 2007 11:22:40 -0000 1.2 *************** *** 2,5 **** --- 2,25 ---- -------------------- + + Release 1.3 + + =============== + + - BrownBoost released + - Added a few README files + - Fixed path bug in jboost wrapper and nfold.py + - Minor improvements to margin.py and error.py + - Added options outputting serialized trees + + + + Release 1.2 + + =============== + + - Added a few README files + - Added a lot of documentation + - There's now a JBoost website + - The website can be downloaded before destribution using the get_doc.sh + script found in the /doc directory + + + Release 1.1 + =============== *************** *** 9,16 **** - Print usage help - Print version - - Added a lot of documentation - - There's now a JBoost website - - The website can be downloaded before destribution using the get_doc.sh - script found in the /doc directory - Added two new boosting algorithms: BrownBoost and YabaBoost - The project is now on SourceForge --- 29,32 ---- |
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3586/src/jboost/controller Modified Files: Configuration.java Controller.java ControllerConfiguration.java ControllerTest.java weightedjboost.config Added Files: jboost.config Log Message: Serialized Tree and BrownBoost options added Index: ControllerConfiguration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/ControllerConfiguration.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ControllerConfiguration.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ControllerConfiguration.java 27 May 2007 11:20:23 -0000 1.2 *************** *** 45,49 **** public static final String MATLAB_OUTPUT_FILENAME="matlabCodeOutputFileName"; public static final String SERIALIZED_OUTPUT_FILENAME="serializationOutputFileName"; ! public static final String SERIALIZED_INPUT="controller.serialized.input"; public static final String SAMPLE_TRAINING_DATA="controller.sampling"; public static final String SAMPLE_THRESHOLD_WEIGHT="controller.threshold.weight"; --- 45,49 ---- public static final String MATLAB_OUTPUT_FILENAME="matlabCodeOutputFileName"; public static final String SERIALIZED_OUTPUT_FILENAME="serializationOutputFileName"; ! public static final String SERIALIZED_INPUT="serialTreeInput"; public static final String SAMPLE_TRAINING_DATA="controller.sampling"; public static final String SAMPLE_THRESHOLD_WEIGHT="controller.threshold.weight"; *************** *** 55,58 **** --- 55,59 ---- public static final String YABA_C2="c2"; public static final String YABA_THETA="theta"; + public static final String BROWN_BOOST_POTENTIAL="brownBoostPotential"; public static final String DEFAULT_BOOSTER = "AdaBoost"; *************** *** 77,81 **** addOption(JAVA_OUTPUT_FILENAME, getString("j", null)); addOption(MATLAB_OUTPUT_FILENAME, getString("m", null)); ! addOption(SERIALIZED_OUTPUT_FILENAME, getString("controller.serialized.output", null)); addOption(N_THREADS, getString("p", null)); addOption(BOOSTER_RUNTIME, getString("r", "1.0")); --- 78,83 ---- addOption(JAVA_OUTPUT_FILENAME, getString("j", null)); addOption(MATLAB_OUTPUT_FILENAME, getString("m", null)); ! addOption(SERIALIZED_OUTPUT_FILENAME, getString("serialTreeOutput", null)); ! addOption(SERIALIZED_INPUT, getString("serialTreeInput", null)); addOption(N_THREADS, getString("p", null)); addOption(BOOSTER_RUNTIME, getString("r", "1.0")); *************** *** 85,88 **** --- 87,91 ---- addOption(YABA_C2, getString("c2", null)); addOption(YABA_THETA, getString("theta", null)); + addOption(BROWN_BOOST_POTENTIAL, getString("potential", null)); } *************** *** 218,221 **** --- 221,231 ---- /** + * @return Returns the name of the serialized input file + */ + public String getSerializationInputFileName() { + return getString(SERIALIZED_INPUT); + } + + /** * @return Returns the specified number of threads */ *************** *** 247,249 **** --- 257,276 ---- return true; } + + + + /** + * @return should we print potential and exit? + */ + public boolean getPrintPotential() { + String str = getString(BROWN_BOOST_POTENTIAL); + if (str == null) { + return false; + } + return true; + } + + + + } Index: weightedjboost.config =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/weightedjboost.config,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** weightedjboost.config 16 May 2007 04:06:02 -0000 1.1.1.1 --- weightedjboost.config 27 May 2007 11:20:24 -0000 1.2 *************** *** 3,7 **** -t src/jboost/controller/weighteddata.train -a -1 ! -controller.serialized.output src/jboost/controller/weightedatree.serialized -O src/jboost/controller/weighted.output.tree -j Predict.java --- 3,7 ---- -t src/jboost/controller/weighteddata.train -a -1 ! -serialTreeOutput src/jboost/controller/weightedatree.serialized -O src/jboost/controller/weighted.output.tree -j Predict.java --- NEW FILE: jboost.config --- -n src/jboost/controller/data.spec -T src/jboost/controller/data.test -t src/jboost/controller/data.train -a -1 -serialTreeOutput src/jboost/controller/atree.serialized Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Controller.java 16 May 2007 21:16:29 -0000 1.2 --- Controller.java 27 May 2007 11:20:23 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- import jboost.atree.InstrumentedAlternatingTree; import jboost.booster.AbstractBooster; + import jboost.booster.BrownBoost; import jboost.booster.Booster; import jboost.booster.Prediction; *************** *** 51,677 **** public class Controller { [...1240 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(); ! } } } Index: Configuration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Configuration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Configuration.java 19 May 2007 01:57:57 -0000 1.2 --- Configuration.java 27 May 2007 11:20:23 -0000 1.3 *************** *** 62,68 **** + "\t-p N Specify number of threads (default: 1)\n" + "\t-CONFIG The name of the configuration file (default \"jboost.config\")\n" ! + "\t All options (below) can be specified in this file.\n" + "\t-V Print version and exit\n" - + "\t All options (below) can be specified in this file.\n" + "\n" + "** Data File Options:\n" --- 62,68 ---- + "\t-p N Specify number of threads (default: 1)\n" + "\t-CONFIG The name of the configuration file (default \"jboost.config\")\n" [...1048 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: ControllerTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/ControllerTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ControllerTest.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ControllerTest.java 27 May 2007 11:20:23 -0000 1.2 *************** *** 127,131 **** m_controller.outputLearningResults(); // set config option for loading tree ! m_config.addOption("controller.serialized.input","src/jboost/controller/atree.serialized"); m_controller.startLearning(); // do some sort of comparison? --- 127,131 ---- m_controller.outputLearningResults(); // set config option for loading tree ! m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); m_controller.startLearning(); // do some sort of comparison? *************** *** 150,154 **** setUp(); m_config.addOption("numRounds", Integer.toString(rounds/2)); ! m_config.addOption("controller.serialized.input","src/jboost/controller/atree.serialized"); m_controller.startLearning(); InstrumentedAlternatingTree firstTree= m_controller.getTree(); --- 150,154 ---- setUp(); m_config.addOption("numRounds", Integer.toString(rounds/2)); ! m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); m_controller.startLearning(); InstrumentedAlternatingTree firstTree= m_controller.getTree(); *************** *** 185,189 **** m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("controller.serialized.input","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); --- 185,189 ---- m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 228,232 **** m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("controller.serialized.input","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); --- 228,232 ---- m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 264,268 **** m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("controller.serialized.output","src/jboost/controller/multilabelatree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); --- 264,268 ---- m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("serialTreeOutput","src/jboost/controller/multilabelatree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 271,275 **** m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("controller.serialized.input","src/jboost/controller/multilabelatree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); --- 271,275 ---- m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("serialTreeInput","src/jboost/controller/multilabelatree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 341,345 **** m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("controller.serialized.input","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); --- 341,345 ---- m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); ! m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); m_controller= new Controller(m_config); m_controller.startLearning(); |
From: Aaron A. <aa...@us...> - 2007-05-27 11:19:55
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3137/scripts Modified Files: nfold.py Log Message: Fixed path bug, reverted to CLASSPATH dependence Index: nfold.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/nfold.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nfold.py 19 May 2007 01:57:56 -0000 1.3 --- nfold.py 27 May 2007 11:19:49 -0000 1.4 *************** *** 25,40 **** def learner(atreeoption, k, rounds): # XXX: put in description! - pwd = os.getcwd() - caller = sys.argv[0] - end = caller.rfind('/') - jboost_command = '../jboost' - if(end > 0): - jboost_command = pwd + '/../' + caller[:end+1] + '/../jboost' - config= os.getenv('JBOOST_CONFIG') ! command = jboost_command + ' -p 3 -a -2 -S trial'+str(k)+' -n trial.spec -ATreeType '+ atreeoption +' -numRounds ' + str(rounds) if (config != None): ! command = command + ' -CONFIG ' + config ! print command error= os.system(command) --- 25,35 ---- def learner(atreeoption, k, rounds): # XXX: put in description! config= os.getenv('JBOOST_CONFIG') ! command = 'java -Xmx1000M -cp ' + os.getenv('CLASSPATH') \ ! + ' jboost.controller.Controller -p 3 -a -2 -S trial' + str(k) \ ! + ' -n trial.spec -ATreeType '+ atreeoption +' -numRounds ' + str(rounds) if (config != None): ! command = command + ' -CONFIG ' + config ! print command error= os.system(command) |
From: Aaron A. <aa...@us...> - 2007-05-27 03:57:30
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11698/scripts Modified Files: margin.py Log Message: minor improvments Index: margin.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/margin.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** margin.py 19 May 2007 01:57:56 -0000 1.4 --- margin.py 27 May 2007 03:57:27 -0000 1.5 *************** *** 102,113 **** ! ! outlines = [] ! ! outlines.append('set terminal png notransparent small\n') ! outlines.append('set output \'margin.png\'\n') ! outlines.append('set xlabel "Margin"\n') ! outlines.append('set ylabel "Cumulative Distribution"\n') ! outlines.append('set title "' + datafile + ' Error"\n') out = '' out += 'plot ' --- 102,113 ---- ! epsoutlines = [] ! epsoutlines.append('set terminal post\n') ! epsoutlines.append('set output \'margin.eps\'\n') ! epsoutlines.append('set title "' + datafile + ' Margins" font "Times,20"\n') ! epsoutlines.append('set key left top\n') ! epsoutlines.append('set size 0.8, 0.8\n') ! epsoutlines.append('set xlabel "Margin" font "Times,20"\n') ! epsoutlines.append('set ylabel "Cumulative Distribution" font "Times,20"\n') out = '' out += 'plot ' *************** *** 117,124 **** out = out[:-1] out += '\n' ! outlines.append(out) ! f = open('margin.gnuplot', 'w') ! f.writelines(outlines) f.close() --- 117,134 ---- out = out[:-1] out += '\n' ! epsoutlines.append(out) ! pngoutlines = epsoutlines[:] ! pngoutlines[0] = 'set terminal png notransparent small\n' ! pngoutlines[1] = 'set output \'margin.png\'\n' ! ! ! ! f = open('margin.png.gnuplot', 'w') ! f.writelines(pngoutlines) ! f.close() ! ! f = open('margin.eps.gnuplot', 'w') ! f.writelines(epsoutlines) f.close() *************** *** 204,208 **** try: opts, args= getopt.getopt(sys.argv[1:], '', ['scores=','data=','spec=','labels=', 'iteration=', 'sample']) ! except getopt.GetoptError: usage() sys.exit(2) --- 214,219 ---- try: opts, args= getopt.getopt(sys.argv[1:], '', ['scores=','data=','spec=','labels=', 'iteration=', 'sample']) ! except getopt.GetoptError, inst: ! print 'Received an illegal argument:', inst usage() sys.exit(2) *************** *** 221,225 **** iteration = arg elif (opt == '--sample'): ! sample = true --- 232,236 ---- iteration = arg elif (opt == '--sample'): ! sample = True |
From: Aaron A. <aa...@us...> - 2007-05-27 03:57:30
|
Update of /cvsroot/jboost/jboost/doc In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11698/doc Modified Files: get_doc.sh Log Message: minor improvments Index: get_doc.sh =================================================================== RCS file: /cvsroot/jboost/jboost/doc/get_doc.sh,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** get_doc.sh 16 May 2007 04:06:02 -0000 1.1.1.1 --- get_doc.sh 27 May 2007 03:57:27 -0000 1.2 *************** *** 2,9 **** DIR="users/aarvey/jboost" ! rm -rf css images wget -r -o wget.log http://${SITE}/${DIR} ! mv ${SITE}/${DIR}/* . rm -rf ${SITE} --- 2,9 ---- DIR="users/aarvey/jboost" ! rm -rf css images wget -r -o wget.log http://${SITE}/${DIR} ! mv ${SITE}/${DIR}/* . rm -rf ${SITE} |
From: Aaron A. <aa...@us...> - 2007-05-27 02:38:40
|
Update of /cvsroot/jboost/jboost/demo In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11561 Added Files: README Removed Files: yababoost.dump Log Message: removed yababoost.dump and added a README file --- yababoost.dump DELETED --- --- NEW FILE: README --- These files are for testing JBoost. Below is a brief description of the datasets. -------------------------- Stem A simple multiclass example demonstrating the types of features that JBoost can handle. ---------------------------- UCI FILES Original files for letter and spambase can be obtained from the UCI Machine Learning repository: http://www.ics.uci.edu/~mlearn/MLSummary.html For documentation, see * http://www.ics.uci.edu/~mlearn/databases/spambase/spambase.DOCUMENTATION * ftp://ftp.ics.uci.edu/pub/machine-learning-databases/spambase/spambase.names * ftp://ftp.ics.uci.edu/pub/machine-learning-databases/letter-recognition/letter-recognition.names --------------------------- Noisy Line The noisy line dataset is an artificial construction to test BrownBoost's resistance to noisy data. The function that generated the training set is: +1 if x < .5 (w/prob 90%) f(x) = -1 if x > .5 (w/prob 90%) The test set is the deterministic version of the function +1 if x < .5 f(x) = -1 if x > .5 |