From: Aaron A. <aa...@us...> - 2007-09-18 03:26:03
|
Update of /cvsroot/jboost/jboost/src/jboost/examples In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9842/examples Modified Files: ExampleSet.java Log Message: New log file format. Index: ExampleSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleSet.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ExampleSet.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ExampleSet.java 18 Sep 2007 03:25:59 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ package jboost.examples; *************** *** 32,35 **** --- 33,40 ---- private boolean isBinary=true; // identifies the data as binary-labeled + /** last iteration on which calc* was called */ + private int lastIter = -2; + private Prediction[] prediction = null; + /** default constructor */ public ExampleSet(){ *************** *** 76,79 **** --- 81,89 ---- else return exampleSet.length; } + + /** get no of examples */ + public int size() { + return getExampleNo(); + } /** get example no. i */ *************** *** 137,142 **** Example x = exampleSet[i]; double[] tmp = prediction[i].getMargins(x.getLabel()); ! for(int j=0; j<tmp.length; j++) ! margins.add(new Double(tmp[j])); } } --- 147,151 ---- Example x = exampleSet[i]; double[] tmp = prediction[i].getMargins(x.getLabel()); ! margins.add(tmp); } } *************** *** 162,173 **** int i=0; try{ for(i=0; i<size; i++) { ! double[] tmp = prediction[i].getClassScores(); ! if(isBinary) // for binary m_labels, keep only one score ! scores.add(new Double(tmp[0])); ! else ! for(int j=0; j<tmp.length; j++) ! scores.add(new Double(tmp[j])); } } --- 171,185 ---- int i=0; + double[] tmp = null; + double tmp0 = 0; try{ for(i=0; i<size; i++) { ! tmp = prediction[i].getClassScores(); ! if(isBinary) { // for binary m_labels, keep only one score ! tmp0 = tmp[0]; ! tmp = new double[1]; ! tmp[0] = tmp0; ! } ! scores.add(tmp); } } *************** *** 182,187 **** } ! private int lastIter = -2; // last iteration on which calc* was called ! private Prediction[] prediction = null; /** updates the saved predictions --- 194,199 ---- } ! ! /** updates the saved predictions *************** *** 191,194 **** --- 203,208 ---- Predictor combined, Predictor base) { + + if (base != null) { if (curIter == lastIter) *************** *** 202,208 **** } } for (int i = 0; i < exampleSet.length; i++) prediction[i] = ! combined.predict(exampleSet[i].getInstance()); lastIter = curIter; } --- 216,225 ---- } } + + for (int i = 0; i < exampleSet.length; i++) prediction[i] = ! combined.predict(exampleSet[i].getInstance(),curIter); ! lastIter = curIter; } *************** *** 219,230 **** int i=0; try{ for(i=0; i<size; i++) { Label l = exampleSet[i].getLabel(); ! if(isBinary) ! labels.add(new Boolean(l.getMultiValue(0))); ! else ! for(int j=0; j<noOfLabels; j++) ! labels.add(new Boolean(l.getMultiValue(j))); } } --- 236,253 ---- int i=0; + Boolean[] tmp = null; try{ for(i=0; i<size; i++) { Label l = exampleSet[i].getLabel(); ! if(isBinary) { ! tmp = new Boolean[1]; ! tmp[0] = new Boolean(l.getMultiValue(0)); ! } else { ! tmp = new Boolean[noOfLabels]; ! for(int j=0; j<noOfLabels; j++) { ! tmp[j] = new Boolean(l.getMultiValue(j)); ! } ! } ! labels.add(tmp); } } |