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: Sunsern C. <sch...@us...> - 2009-06-08 23:41:17
|
Update of /cvsroot/jboost/jboost/scripts In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/scripts Modified Files: Tag: jboost-2_0 AddRandomIndex.py VisualizeScores.py Log Message: jboost 2.0 Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -C2 -d -r1.9 -r1.9.2.1 *** VisualizeScores.py 12 Mar 2009 23:42:40 -0000 1.9 --- VisualizeScores.py 8 Jun 2009 23:40:49 -0000 1.9.2.1 *************** *** 1,5 **** #!/usr/bin/python ! import sys, os, os.path, re, math, glob def usage(): --- 1,5 ---- #!/usr/bin/python ! import getopt, sys, os, os.path, re, math, glob def usage(): *************** *** 11,30 **** def main(): ! args = sys.argv[1:] ! ! globpath = None ! if len(args) == 1: ! globpath = args[0] ! else: usage() sys.exit(2) ! testfiles = glob.glob(globpath + "*.test.boosting.info") ! trainfiles = glob.glob(globpath + "*.train.boosting.info") ! #print testfiles ! #print trainfiles ! cmd = "java jboost.visualization.HistogramFrame " + str(len(testfiles)) + " " for f in testfiles: cmd = cmd + f + " " --- 11,49 ---- def main(): ! ! carry = 0 ! ! try: ! opts, args = getopt.getopt(sys.argv[1:],'hc',[]) ! except getopt.GetoptError: ! print 'Error: Illegal arguments' usage() sys.exit(2) ! for o, a in opts: ! if o in ('-h'): ! usage() ! sys.exit() ! elif o in ('-c'): ! carry = 1 ! else: ! assert False, "unhandled option" ! if len(args) < 1: ! usage() ! sys.exit(1) ! globpath = args[0] ! ! testfiles = glob.glob(globpath + "*.test.boosting.info") ! trainfiles = glob.glob(globpath + "*.train.boosting.info") ! infofiles = glob.glob(globpath + "*.info") ! ! for f in testfiles: ! infofiles.remove(f) ! for f in trainfiles: ! infofiles.remove(f) ! ! cmd = "java jboost.visualization.HistogramFrame " + str(carry) + " " + str(len(testfiles)) + " " for f in testfiles: cmd = cmd + f + " " *************** *** 32,36 **** for f in trainfiles: cmd = cmd + f + " " ! os.system(cmd) --- 51,57 ---- for f in trainfiles: cmd = cmd + f + " " ! cmd = cmd + str(len(infofiles)) + " " ! for f in infofiles: ! cmd = cmd + f + " " os.system(cmd) Index: AddRandomIndex.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/AddRandomIndex.py,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** AddRandomIndex.py 17 Jan 2009 02:00:31 -0000 1.2 --- AddRandomIndex.py 8 Jun 2009 23:40:49 -0000 1.2.2.1 *************** *** 74,78 **** i=0 for idx,line in enumerate(features): ! if line.startswith(('\n','exampleTerminator','attributeTerminator','maxBadExa','maxBadAtt')): i=i+1 else: --- 74,78 ---- i=0 for idx,line in enumerate(features): ! if line.startswith(('\n','\r\n','exampleTerminator','attributeTerminator','maxBadExa','maxBadAtt')): i=i+1 else: |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:41:17
|
Update of /cvsroot/jboost/jboost/src/jboost/util In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/util Modified Files: Tag: jboost-2_0 BaseCountWorker.java ExecutorSinglet.java Log Message: jboost 2.0 Index: BaseCountWorker.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/util/BaseCountWorker.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** BaseCountWorker.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- BaseCountWorker.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 1,5 **** package jboost.util; ! import EDU.oswego.cs.dl.util.concurrent.CountDown; /** --- 1,5 ---- package jboost.util; ! import java.util.concurrent.CountDownLatch; /** *************** *** 10,16 **** */ public abstract class BaseCountWorker implements Runnable { ! CountDown count; ! public BaseCountWorker(CountDown count) { this.count=count; } --- 10,16 ---- */ public abstract class BaseCountWorker implements Runnable { ! CountDownLatch count; ! public BaseCountWorker(CountDownLatch count) { this.count=count; } *************** *** 22,26 **** doWork(); } finally { ! count.release(); } --- 22,26 ---- doWork(); } finally { ! count.countDown(); } Index: ExecutorSinglet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/util/ExecutorSinglet.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** ExecutorSinglet.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ExecutorSinglet.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 1,6 **** package jboost.util; ! import EDU.oswego.cs.dl.util.concurrent.DirectExecutor; ! import EDU.oswego.cs.dl.util.concurrent.Executor; /** --- 1,7 ---- package jboost.util; ! import java.util.concurrent.Executor; ! import java.util.concurrent.Executors; ! /** *************** *** 10,14 **** */ public class ExecutorSinglet { ! static Executor e=new DirectExecutor(); public static Executor getExecutor() { --- 11,16 ---- */ public class ExecutorSinglet { ! ! static Executor e = Executors.newFixedThreadPool(1); public static Executor getExecutor() { *************** *** 19,21 **** --- 21,24 ---- e=ex; } + } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:41:12
|
Update of /cvsroot/jboost/jboost/src/jboost/examples In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/examples Modified Files: Tag: jboost-2_0 AttributeDescription.java Example.java ExampleDescription.java ExampleSet.java LabelDescription.java TextDescription.java WeightDescription.java Log Message: jboost 2.0 Index: LabelDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/LabelDescription.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** LabelDescription.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- LabelDescription.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 12,32 **** */ public class LabelDescription extends FiniteDescription { ! LabelDescription(String name, Configuration c, List okValues) throws ClassNotFoundException { ! super(name,c,okValues); ! attributeClass = Class.forName("jboost.examples.LabelDescription"); ! multiLabel = c.getBool("multiLabel", false); ! } ! private boolean multiLabel; ! public boolean isMultiLabel() { ! return multiLabel; ! } ! public String toString() { ! return super.toString() + " multiLabel: " + multiLabel; ! } ! /* public String toString(Attribute attr) throws Exception { String retval=new String(); --- 12,32 ---- */ public class LabelDescription extends FiniteDescription { ! LabelDescription(String name, Configuration c, List okValues) throws ClassNotFoundException { ! super(name,c,okValues); ! attributeClass = Class.forName("jboost.examples.LabelDescription"); ! multiLabel = c.getBool("multiLabel", false); ! } ! private boolean multiLabel; ! public boolean isMultiLabel() { ! return multiLabel; ! } ! public String toString() { ! return super.toString() + " multiLabel: " + multiLabel; ! } ! /* public String toString(Attribute attr) throws Exception { String retval=new String(); *************** *** 46,81 **** return(retval); } ! */ ! /** Reads a MultiFinite attribute ! * Note that it is currently based on String but should use StringBuffer ! * Also note that right now it can only deal with one value. ! */ ! public Attribute str2Att(String string) throws BadAttException { ! if(string == null) return new Label(null); ! StringTokenizer st = new StringTokenizer(string); ! if (!multiLabel && (st.countTokens() != 1)) ! throw new BadAttException((st.countTokens() == 0 ! ? "Zero" ! : "Multiple") ! + " labels found when expecting single label: "+string); ! String s; ! boolean v[] = new boolean[getNoOfValues()]; ! while(st.hasMoreElements()) { ! s = st.nextToken(); ! if(!caseSignificant) ! s = s.toLowerCase(); ! if(!punctuationSignificant) ! s = StringOp.removePunctuation(s); ! if(map.containsKey(s)) ! v[((Integer) map.get(s)).intValue()] = true; ! else if(map.containsKey("*")) ! v[((Integer) map.get("*")).intValue()] = true; ! else ! throw(new BadAttException("Unknown label: "+s ! +" when not allowed.")); } - return new Label(v); - } } --- 46,81 ---- return(retval); } ! */ ! /** Reads a MultiFinite attribute ! * Note that it is currently based on String but should use StringBuffer ! * Also note that right now it can only deal with one value. ! */ ! public Attribute str2Att(String string) throws BadAttException { ! if(string == null) return new Label(null); ! StringTokenizer st = new StringTokenizer(string); ! if (!multiLabel && (st.countTokens() != 1)) ! throw new BadAttException((st.countTokens() == 0 ! ? "Zero" ! : "Multiple") ! + " labels found when expecting single label: "+string); ! String s; ! boolean v[] = new boolean[getNoOfValues()]; ! while(st.hasMoreElements()) { ! s = st.nextToken(); ! if(!caseSignificant) ! s = s.toLowerCase(); ! if(!punctuationSignificant) ! s = StringOp.removePunctuation(s); ! if(map.containsKey(s)) ! v[((Integer) map.get(s)).intValue()] = true; ! else if(map.containsKey("*")) ! v[((Integer) map.get("*")).intValue()] = true; ! else ! throw(new BadAttException("Unknown label: "+s ! +" when not allowed.")); ! } ! return new Label(v); } } Index: Example.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/Example.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** Example.java 11 Sep 2008 21:25:45 -0000 1.2 --- Example.java 8 Jun 2009 23:40:49 -0000 1.2.2.1 *************** *** 13,20 **** /** a textual comment */ protected String m_comment; /** a pointer to the exampleDescription */ protected ExampleDescription m_exampleDescription; - /** * Default ctor --- 13,21 ---- /** a textual comment */ protected String m_comment; + /** INDEX */ + protected int m_index; /** a pointer to the exampleDescription */ protected ExampleDescription m_exampleDescription; /** * Default ctor *************** *** 23,30 **** * @param ed */ ! public Example(Attribute[] attArray, Label label, double weight, ExampleDescription ed) { m_instance = new Instance(attArray); m_label=label; m_weight= weight; m_exampleDescription = ed; } --- 24,32 ---- * @param ed */ ! public Example(Attribute[] attArray, int index, Label label, double weight, ExampleDescription ed) { m_instance = new Instance(attArray); m_label=label; m_weight= weight; + m_index = index; m_exampleDescription = ed; } *************** *** 36,40 **** */ public Example(Attribute[] attArray, Label label) { ! this(attArray,label, 1.0, null); } --- 38,42 ---- */ public Example(Attribute[] attArray, Label label) { ! this(attArray,- 1, label, 1.0, null); } *************** *** 62,66 **** } ! /** * Get the weight of this example --- 64,83 ---- } ! /** ! * Get the INDEX of this example ! * @return INDEX ! */ ! public int getIndex() { ! return m_index; ! } ! ! /** ! * Set the INDEX of this example ! * @param INDEX ! */ ! public void setIndex(int index) { ! m_index= index; ! } ! /** * Get the weight of this example Index: TextDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/TextDescription.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** TextDescription.java 16 Feb 2008 00:02:19 -0000 1.2 --- TextDescription.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 19,44 **** */ public class TextDescription extends AttributeDescription { ! TextDescription(String name, Configuration c) throws ClassNotFoundException { ! attributeName = name; ! attributeClass = Class.forName("jboost.examples.SetAttribute"); ! // get configuration parameters ! crucial=c.getBool("crucial",false); ! ignoreAttribute=c.getBool("ignoreAttribute",false); ! caseSignificant=c.getBool("caseSignificant",false); ! existence=c.getBool("existence",false); ! ngramsize=c.getInt("ngramsize",1); ! ngramtype = c.getString("ngramtype", "full").toLowerCase(); ! if (ngramsize < 1) // these should probably be SpecFileExceptions ! throw new RuntimeException("Illegal ngramsize received for attribute " ! + name); ! if (!(ngramtype.equals("fixed") || ! ngramtype.equals("full") || ! ngramtype.equals("sparse"))) ! throw new RuntimeException("Illegal ngram type for attribute " ! + name); ! } ! /** Reads a text attribute. Main method, str2Att, converts text to an arrya of integers. The integers reflect the order in which the word appeared in --- 19,44 ---- */ public class TextDescription extends AttributeDescription { ! TextDescription(String name, Configuration c) throws ClassNotFoundException { ! attributeName = name; ! attributeClass = Class.forName("jboost.examples.SetAttribute"); ! // get configuration parameters ! crucial=c.getBool("crucial",false); ! ignoreAttribute=c.getBool("ignoreAttribute",false); ! caseSignificant=c.getBool("caseSignificant",false); ! existence=c.getBool("existence",false); ! ngramsize=c.getInt("ngramsize",1); ! ngramtype = c.getString("ngramtype", "full").toLowerCase(); ! if (ngramsize < 1) // these should probably be SpecFileExceptions ! throw new RuntimeException("Illegal ngramsize received for attribute " ! + name); ! if (!(ngramtype.equals("fixed") || ! ngramtype.equals("full") || ! ngramtype.equals("sparse"))) ! throw new RuntimeException("Illegal ngram type for attribute " ! + name); ! } ! /** Reads a text attribute. Main method, str2Att, converts text to an arrya of integers. The integers reflect the order in which the word appeared in *************** *** 67,234 **** wordList - the unique least that appeared int this document, int order. ! */ ! public Attribute str2Att(String string) throws BadAttException { ! try{if(string == null) return new SetAttribute(null,this);} ! catch(RepeatedElementException e){ ! throw new RuntimeException ! ("TextDescription.str2Att: got a RepeatedElementException " ! +"on a null set !!"); ! } ! string=string.trim(); ! if(string.length()==0) { ! try { return(new SetAttribute(new int[0])); } ! catch(RepeatedElementException e) { ! throw new RuntimeException ! ("RepeatedElementException in TextDescription.str2Att"); ! } ! } ! WordTable wt = WordTable.globalTable; ! // going over words int string and mapping each to an int ! HashMap locMap = new HashMap(); ! // locMap - maps every word that appeared in local document to an ! // object cotaining the number of times the word appeared int ! // current document. ! int numLocWords = 0; // Number of words seen so far int text ! String word; // word to process next ! ArrayList wordList = new ArrayList(); ! // the unique "words" that appeared in this document, where a ! // word may actually be an ngram ! Enumeration st; ! if (ngramtype.equals("sparse")) ! st = new SparseNgram(string, ngramsize); ! else if (ngramtype.equals("full")) ! st = new FullNgram(string, ngramsize); ! else // fixed ngram ! st = new FixedNgram(string, ngramsize); ! try { ! String[] wordArr = string.split(" "); ! //while ( st.hasMoreElements()) { ! for (int i=0; i<wordArr.length; i++) { ! //word = (String) st.nextElement(); ! word = wordArr[i]; ! // if(Monitor.logLevel>3) Monitor.log("DIAG TextAttReader.str2Att: word=" +word); ! if (wt.frozen && !wt.map.containsKey(word)) ! continue; ! if (locMap.containsKey(word)) { // word appeared in curr text ! ((LocWord)locMap.get(word)).inc(); } ! else { // word not in curr text ! locMap.put(word, new LocWord()); ! if (!wt.frozen && !wt.map.containsKey(word)) { // string is nowhere ! if(Monitor.logLevel>30) ! Monitor.log("adding to wordTable word:"+word ! +", token="+wt.size); ! wt.map.put(word, new GloWord(wt.size)); //put new key ! wt.words.add(word); ! wt.size++; ! } ! wordList.add(word); ! numLocWords++; } ! ((GloWord)wt.map.get(word)).inc(); ! } } ! catch (Exception e) { ! if(Monitor.logLevel>3) Monitor.log(e.getMessage()+e); ! throw new BadAttException("Error reading: "+string,0,0); } - int[] wordTokenArr = new int[numLocWords]; - for (int i=0; i<numLocWords; i++) - wordTokenArr[i] =((GloWord)wt.map.get(wordList.get(i))).getToken(); ! Attribute setAttribute = null; ! try{setAttribute = new SetAttribute(wordTokenArr,this);} ! catch(Exception e) { ! e.printStackTrace(); ! if(Monitor.logLevel>3) ! Monitor.log(e.getMessage()+e); ! throw new BadAttException("Error reading: "+string+"\n"+e,0,0); } - return setAttribute; - } ! private int ngramsize; ! private String ngramtype; ! public String getAttributeValue(int i) { ! return (String)WordTable.globalTable.words.get(i); ! } ! public String toString() { ! String retval=new String(attributeName); ! retval+=" "+attributeClass.getName(); ! retval+=" crucial: "+crucial; ! retval+=" ignoreAttribute: "+ignoreAttribute; ! retval+=" caseSignificant: "+caseSignificant; ! retval+=" existence: "+existence; ! retval+=" ngramsize: "+ngramsize; ! retval+=" ngramtype: "+ngramtype; ! return(retval); ! } ! ! public String toString(Attribute attr) { ! if(attr.isDefined()==false) return("UNDEFINED"); ! String retval=new String(); ! int[] tok=((SetAttribute)attr).getList(); ! // This should be improved when the reader is integrated. ! if(tok==null) return(null); ! ! int lineLength=0; ! for(int i=0; i<tok.length; i++) { ! String s=(String) getAttributeValue(tok[i]); ! if(s.startsWith("1 ")) // if this is a simple one word token ! // then remove the prefix ! s=s.substring(2); ! retval += s; ! if(i<tok.length-1) retval+=","; ! lineLength += s.length()+1; ! if(lineLength > 80) { ! lineLength=0; ! retval+="\n"; ! } } - - return(retval); - } ! static public void setTokenSet(String[] t) { ! if (WordTable.globalTable.size > 0) ! throw new RuntimeException("attempted to call TextDescription." ! +"setTokenSet with a nonempty hash " ! +"table"); ! for (int i = 0; i < t.length; i++) { ! if (WordTable.globalTable.map.containsKey(t[i])) ! throw new IllegalArgumentException("tokens passed to " ! +"TextDescription.setTokenSet must all be unique"); ! WordTable.globalTable.map.put(t[i], new GloWord(i)); ! WordTable.globalTable.words.add(t[i]); } ! WordTable.globalTable.size = t.length; ! WordTable.globalTable.frozen = true; ! } ! } /** contains the global token of a word and number of times it appeared in all documents ! */ class GloWord extends LocWord{ ! private int token; ! public GloWord() {this.token=0;} ! public GloWord(int token) {this.token = token;} ! public int getToken() {return token;} } /** contains the number of times a word appeared in current document*/ class LocWord implements Serializable{ ! int numApp; // number of times word appeared ! public LocWord() {this.numApp = 1;} ! public void inc() {numApp++;} ! public int getNumApp() {return numApp;} } ! ! --- 67,234 ---- wordList - the unique least that appeared int this document, int order. ! */ ! public Attribute str2Att(String string) throws BadAttException { ! try{if(string == null) return new SetAttribute(null,this);} ! catch(RepeatedElementException e){ ! throw new RuntimeException ! ("TextDescription.str2Att: got a RepeatedElementException " ! +"on a null set !!"); ! } ! string=string.trim(); ! if(string.length()==0) { ! try { return(new SetAttribute(new int[0])); } ! catch(RepeatedElementException e) { ! throw new RuntimeException ! ("RepeatedElementException in TextDescription.str2Att"); ! } ! } ! WordTable wt = WordTable.globalTable; ! // going over words int string and mapping each to an int ! HashMap locMap = new HashMap(); ! // locMap - maps every word that appeared in local document to an ! // object cotaining the number of times the word appeared int ! // current document. ! int numLocWords = 0; // Number of words seen so far int text ! String word; // word to process next ! ArrayList wordList = new ArrayList(); ! // the unique "words" that appeared in this document, where a ! // word may actually be an ngram ! Enumeration st; ! if (ngramtype.equals("sparse")) ! st = new SparseNgram(string, ngramsize); ! else if (ngramtype.equals("full")) ! st = new FullNgram(string, ngramsize); ! else // fixed ngram ! st = new FixedNgram(string, ngramsize); ! try { ! String[] wordArr = string.split(" "); ! //while ( st.hasMoreElements()) { ! for (int i=0; i<wordArr.length; i++) { ! //word = (String) st.nextElement(); ! word = wordArr[i]; ! // if(Monitor.logLevel>3) Monitor.log("DIAG TextAttReader.str2Att: word=" +word); ! if (wt.frozen && !wt.map.containsKey(word)) ! continue; ! if (locMap.containsKey(word)) { // word appeared in curr text ! ((LocWord)locMap.get(word)).inc(); ! } ! else { // word not in curr text ! locMap.put(word, new LocWord()); ! if (!wt.frozen && !wt.map.containsKey(word)) { // string is nowhere ! if(Monitor.logLevel>30) ! Monitor.log("adding to wordTable word:"+word ! +", token="+wt.size); ! wt.map.put(word, new GloWord(wt.size)); //put new key ! wt.words.add(word); ! wt.size++; ! } ! wordList.add(word); ! numLocWords++; ! } ! ((GloWord)wt.map.get(word)).inc(); ! } } ! catch (Exception e) { ! if(Monitor.logLevel>3) Monitor.log(e.getMessage()+e); ! throw new BadAttException("Error reading: "+string,0,0); } ! int[] wordTokenArr = new int[numLocWords]; ! for (int i=0; i<numLocWords; i++) ! wordTokenArr[i] =((GloWord)wt.map.get(wordList.get(i))).getToken(); ! ! Attribute setAttribute = null; ! try{setAttribute = new SetAttribute(wordTokenArr,this);} ! catch(Exception e) { ! e.printStackTrace(); ! if(Monitor.logLevel>3) ! Monitor.log(e.getMessage()+e); ! throw new BadAttException("Error reading: "+string+"\n"+e,0,0); ! } ! return setAttribute; } ! ! private int ngramsize; ! private String ngramtype; ! ! public String getAttributeValue(int i) { ! return (String)WordTable.globalTable.words.get(i); } ! public String toString() { ! String retval=new String(attributeName); ! retval+=" "+attributeClass.getName(); ! retval+=" crucial: "+crucial; ! retval+=" ignoreAttribute: "+ignoreAttribute; ! retval+=" caseSignificant: "+caseSignificant; ! retval+=" existence: "+existence; ! retval+=" ngramsize: "+ngramsize; ! retval+=" ngramtype: "+ngramtype; ! return(retval); } ! public String toString(Attribute attr) { ! if(attr.isDefined()==false) return("UNDEFINED"); ! String retval=new String(); ! int[] tok=((SetAttribute)attr).getList(); ! // This should be improved when the reader is integrated. ! if(tok==null) return(null); ! int lineLength=0; ! for(int i=0; i<tok.length; i++) { ! String s=(String) getAttributeValue(tok[i]); ! if(s.startsWith("1 ")) // if this is a simple one word token ! // then remove the prefix ! s=s.substring(2); ! retval += s; ! if(i<tok.length-1) retval+=","; ! lineLength += s.length()+1; ! if(lineLength > 80) { ! lineLength=0; ! retval+="\n"; ! } ! } ! return(retval); } ! static public void setTokenSet(String[] t) { ! if (WordTable.globalTable.size > 0) ! throw new RuntimeException("attempted to call TextDescription." ! +"setTokenSet with a nonempty hash " ! +"table"); ! for (int i = 0; i < t.length; i++) { ! if (WordTable.globalTable.map.containsKey(t[i])) ! throw new IllegalArgumentException("tokens passed to " ! +"TextDescription.setTokenSet must all be unique"); ! WordTable.globalTable.map.put(t[i], new GloWord(i)); ! WordTable.globalTable.words.add(t[i]); ! } ! WordTable.globalTable.size = t.length; ! WordTable.globalTable.frozen = true; } ! } /** contains the global token of a word and number of times it appeared in all documents ! */ class GloWord extends LocWord{ ! private int token; ! public GloWord() {this.token=0;} ! public GloWord(int token) {this.token = token;} ! public int getToken() {return token;} } /** contains the number of times a word appeared in current document*/ class LocWord implements Serializable{ ! int numApp; // number of times word appeared ! public LocWord() {this.numApp = 1;} ! public void inc() {numApp++;} ! public int getNumApp() {return numApp;} } ! ! Index: AttributeDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/AttributeDescription.java,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** AttributeDescription.java 23 Oct 2007 22:44:54 -0000 1.3 --- AttributeDescription.java 8 Jun 2009 23:40:49 -0000 1.3.4.1 *************** *** 33,37 **** if (name.equals(DataStream.LABELS_ATTR)) retval=new LabelDescription(name,options,okValues); else if (name.equals(DataStream.WEIGHT_ATTR)) retval= new WeightDescription(name, options); ! //else if (name.equals(DataStream.ID_ATTR)) retval= new IdDescription(name, options); else if(type.equals("number")) retval=new NumberDescription(name,options); else if(type.equals("string")) retval=new StringDescription(name,options); --- 33,37 ---- if (name.equals(DataStream.LABELS_ATTR)) retval=new LabelDescription(name,options,okValues); else if (name.equals(DataStream.WEIGHT_ATTR)) retval= new WeightDescription(name, options); ! else if (name.equals(DataStream.INDEX_ATTR)) retval= new IndexDescription(name, options); else if(type.equals("number")) retval=new NumberDescription(name,options); else if(type.equals("string")) retval=new StringDescription(name,options); Index: ExampleSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleSet.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** ExampleSet.java 3 Jan 2009 05:13:32 -0000 1.4 --- ExampleSet.java 8 Jun 2009 23:40:49 -0000 1.4.2.1 *************** *** 19,24 **** * The content of the ExampleSet */ private Example[] exampleSet; - public final String IndexName="INDEX"; // Indicates that a field is just an index, use to track individual examples in the log files. - private int indexLocation=-1; // The number of the attribute that stores the index. /** --- 19,22 ---- *************** *** 61,73 **** isBinary = (noOfLabels==2 && !multiLabel); - // Find out if there is an attribute whose name is IndexName. This attribute is used to relate examples in different datasets. - for(int i=0; i<exampleDescription.getNoOfAttributes(); i++) { - String name = exampleDescription.getAttributeDescription(i).getAttributeName(); - if(name.equals(IndexName)) { - indexLocation=i; - break; - } - //System.out.printf("ExampleSet.indexLocation=%d%n", indexLocation); - } } --- 59,62 ---- *************** *** 222,226 **** Predictor base) { - if (base != null) { if (curIter == lastIter) --- 211,214 ---- *************** *** 235,242 **** } - for (int i = 0; i < exampleSet.length; i++) prediction[i] = ! combined.predict(exampleSet[i].getInstance(),curIter); lastIter = curIter; --- 223,230 ---- } for (int i = 0; i < exampleSet.length; i++) prediction[i] = ! //combined.predict(exampleSet[i].getInstance(),curIter); ! combined.predict(exampleSet[i].getInstance()); lastIter = curIter; *************** *** 291,295 **** /** check if there is an attribute whose name is "INDEX" **/ public boolean hasIndex() { ! return indexLocation>-1; } --- 279,283 ---- /** check if there is an attribute whose name is "INDEX" **/ public boolean hasIndex() { ! return exampleDescription.getIndexDescription() != null; } *************** *** 298,302 **** double[] indexes = new double[exampleSet.length]; for(int i=0; i<indexes.length; i++) { ! indexes[i]=((RealAttribute) exampleSet[i].getAttribute(indexLocation)).getValue(); } return indexes; --- 286,290 ---- double[] indexes = new double[exampleSet.length]; for(int i=0; i<indexes.length; i++) { ! indexes[i]=(double) exampleSet[i].getIndex(); } return indexes; Index: ExampleDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleDescription.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** ExampleDescription.java 2 Oct 2007 20:34:56 -0000 1.2 --- ExampleDescription.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 11,21 **** /** An AttributeDescription for the labels */ ! private LabelDescription label; /** An AttributeDescription for the example weights */ ! private WeightDescription weight; /** a description of each attribute */ ! private Vector attribute; /** the index of the example attribute that contains the label */ --- 11,24 ---- /** An AttributeDescription for the labels */ ! private LabelDescription m_label; /** An AttributeDescription for the example weights */ ! private WeightDescription m_weight; ! ! /** An AttributeDescription for INDEX */ ! private IndexDescription m_index; /** a description of each attribute */ ! private Vector m_attribute; /** the index of the example attribute that contains the label */ *************** *** 25,44 **** private int m_weightIndex; /** Flag for using private sampling weights */ private boolean m_useSamplingWeights; - - - /** * Defaul constructor */ public ExampleDescription() { ! attribute=new Vector(); ! label= null; ! weight= null; m_useSamplingWeights= false; m_labelIndex= -1; m_weightIndex= -1; } --- 28,64 ---- private int m_weightIndex; + /** the index of the example attribute that contains INDEX */ + private int m_indexIndex; + /** Flag for using private sampling weights */ private boolean m_useSamplingWeights; /** * Defaul constructor */ public ExampleDescription() { ! m_attribute=new Vector(); ! m_label= null; ! m_weight= null; ! m_index= null; m_useSamplingWeights= false; m_labelIndex= -1; m_weightIndex= -1; + m_indexIndex= -1; + } + + /** + * Sets the index description. + */ + public void setIndex(AttributeDescription ad) { + m_index=(IndexDescription) ad; + } + + /** + * Sets the index description. + */ + public void setIndex(AttributeDescription ad, int index) { + m_index=(IndexDescription) ad; + m_indexIndex= index; } *************** *** 47,51 **** */ public void setLabel(AttributeDescription ad) { ! label=(LabelDescription) ad; } --- 67,71 ---- */ public void setLabel(AttributeDescription ad) { ! m_label=(LabelDescription) ad; } *************** *** 54,58 **** */ public void setLabel(AttributeDescription ad, int index) { ! label=(LabelDescription) ad; m_labelIndex= index; } --- 74,78 ---- */ public void setLabel(AttributeDescription ad, int index) { ! m_label=(LabelDescription) ad; m_labelIndex= index; } *************** *** 72,80 **** } /** * Assign the weight description */ public void setWeight(AttributeDescription weightDescription) { ! weight= (WeightDescription) weightDescription; } --- 92,108 ---- } + /** + * Return the index of the INDEX + */ + public int getIndexIndex() { + return m_indexIndex; + } + + /** * Assign the weight description */ public void setWeight(AttributeDescription weightDescription) { ! m_weight= (WeightDescription) weightDescription; } *************** *** 83,87 **** */ public void setWeight(AttributeDescription weightDescription, int index) { ! weight= (WeightDescription) weightDescription; m_weightIndex= index; } --- 111,115 ---- */ public void setWeight(AttributeDescription weightDescription, int index) { ! m_weight= (WeightDescription) weightDescription; m_weightIndex= index; } *************** *** 91,97 **** */ public WeightDescription getWeightDescription() { ! return weight; } /** * If true, then the examples with this description will contain --- 119,134 ---- */ public WeightDescription getWeightDescription() { ! return m_weight; } + + /** + * Return the Index Description + */ + public IndexDescription getIndexDescription() { + return m_index; + } + + /** * If true, then the examples with this description will contain *************** *** 113,117 **** /** Add an attribute description. */ public void addAttribute(AttributeDescription ad) { ! attribute.add(ad); } --- 150,154 ---- /** Add an attribute description. */ public void addAttribute(AttributeDescription ad) { ! m_attribute.add(ad); } *************** *** 124,132 **** Label l= e.getLabel(); Instance ins= e.getInstance(); ! retval += label.toString(l); int i=0; int s=ins.getSize(); for(i=0; i < s; i++) { ! retval += ((AttributeDescription) attribute.get(i)).toString(e.getAttribute(i)); } return(retval); --- 161,169 ---- Label l= e.getLabel(); Instance ins= e.getInstance(); ! retval += m_label.toString(l); int i=0; int s=ins.getSize(); for(i=0; i < s; i++) { ! retval += ((AttributeDescription) m_attribute.get(i)).toString(e.getAttribute(i)); } return(retval); *************** *** 137,154 **** public String toString() { String retval=new String(); ! for(int i=0; i<attribute.size(); i++) ! retval += (AttributeDescription) attribute.get(i) + "\n"; ! retval += label + "\n"; return(retval); } public LabelDescription getLabelDescription() { ! return(label); } public AttributeDescription[] getAttributes() { ! AttributeDescription[] retval=new AttributeDescription[attribute.size()]; for(int i=0;i<retval.length;i++) { ! retval[i]=(AttributeDescription)attribute.get(i); } return(retval); --- 174,191 ---- public String toString() { String retval=new String(); ! for(int i=0; i<m_attribute.size(); i++) ! retval += (AttributeDescription) m_attribute.get(i) + "\n"; ! retval += m_label + "\n"; return(retval); } public LabelDescription getLabelDescription() { ! return(m_label); } public AttributeDescription[] getAttributes() { ! AttributeDescription[] retval=new AttributeDescription[m_attribute.size()]; for(int i=0;i<retval.length;i++) { ! retval[i]=(AttributeDescription)m_attribute.get(i); } return(retval); *************** *** 160,168 **** */ public int getNoOfAttributes() { ! return attribute.size(); } public AttributeDescription getAttributeDescription(int i) { ! return (AttributeDescription) attribute.get(i); } --- 197,205 ---- */ public int getNoOfAttributes() { ! return m_attribute.size(); } public AttributeDescription getAttributeDescription(int i) { ! return (AttributeDescription) m_attribute.get(i); } Index: WeightDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/WeightDescription.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** WeightDescription.java 2 Oct 2007 20:34:56 -0000 1.2 --- WeightDescription.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 9,13 **** public class WeightDescription extends NumberDescription { ! public static final double MAX_WEIGHT = 1; WeightDescription(String name, Configuration config) --- 9,13 ---- public class WeightDescription extends NumberDescription { ! public static final double MAX_WEIGHT = 1; WeightDescription(String name, Configuration config) *************** *** 40,47 **** --- 40,49 ---- throw new BadAttException("The weight: " + weight + " is less than 0",0,0); } + /* if (att > MAX_WEIGHT) { att= MAX_WEIGHT; throw new BadAttException("The weight: " + weight + " is larger than MAX_WEIGHT=" + MAX_WEIGHT,0,0); } + */ } } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:41:12
|
Update of /cvsroot/jboost/jboost/dist In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/dist Modified Files: Tag: jboost-2_0 jboost.jar Log Message: jboost 2.0 Index: jboost.jar =================================================================== RCS file: /cvsroot/jboost/jboost/dist/jboost.jar,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 Binary files /tmp/cvsHSr6Bk and /tmp/cvs7qMrCa differ |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:58
|
Update of /cvsroot/jboost/jboost/src/jboost/learner In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/learner Modified Files: Tag: jboost-2_0 EqualitySplitterBuilder.java InequalitySplitter.java InequalitySplitterBuilder.java SetSplitterBuilder.java StumpSplitterBuilderFamily.java Log Message: jboost 2.0 Index: StumpSplitterBuilderFamily.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/StumpSplitterBuilderFamily.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** StumpSplitterBuilderFamily.java 24 Jan 2008 22:48:54 -0000 1.2 --- StumpSplitterBuilderFamily.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 2,13 **** import java.util.Vector; import jboost.booster.Booster; import jboost.controller.Configuration; import jboost.examples.AttributeDescription; import jboost.examples.DiscreteAttribute; import jboost.examples.ExampleDescription; import jboost.examples.RealAttribute; import jboost.examples.SetAttribute; - import jboost.examples.*; import jboost.monitor.Monitor; --- 2,15 ---- import java.util.Vector; + import jboost.booster.Booster; import jboost.controller.Configuration; import jboost.examples.AttributeDescription; + import jboost.examples.BooleanAttribute; import jboost.examples.DiscreteAttribute; import jboost.examples.ExampleDescription; + import jboost.examples.IntegerAttribute; import jboost.examples.RealAttribute; import jboost.examples.SetAttribute; import jboost.monitor.Monitor; Index: SetSplitterBuilder.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/SetSplitterBuilder.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** SetSplitterBuilder.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- SetSplitterBuilder.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 5,19 **** import jboost.CandidateSplit; import jboost.NotSupportedException; - import jboost.booster.Bag; import jboost.booster.AbstractBooster; import jboost.booster.Booster; import jboost.examples.Attribute; import jboost.examples.AttributeDescription; - import jboost.examples.DiscreteAttribute; import jboost.examples.Example; - import jboost.examples.Label; import jboost.examples.SetAttribute; import jboost.examples.WordTable; - import jboost.monitor.Monitor; /** --- 5,16 ---- import jboost.CandidateSplit; import jboost.NotSupportedException; import jboost.booster.AbstractBooster; + import jboost.booster.Bag; import jboost.booster.Booster; import jboost.examples.Attribute; import jboost.examples.AttributeDescription; import jboost.examples.Example; import jboost.examples.SetAttribute; import jboost.examples.WordTable; /** Index: EqualitySplitterBuilder.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/EqualitySplitterBuilder.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** EqualitySplitterBuilder.java 7 Apr 2008 16:29:27 -0000 1.2 --- EqualitySplitterBuilder.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 4,12 **** import java.util.Vector; - //import sun.tools.tree.CastExpression; - import jboost.CandidateSplit; import jboost.booster.Bag; - import jboost.booster.AbstractBooster; import jboost.booster.Booster; import jboost.examples.Attribute; --- 4,9 ---- *************** *** 14,22 **** import jboost.examples.DiscreteAttribute; import jboost.examples.Example; - import jboost.examples.ExampleDescription; - import jboost.examples.Label; - import jboost.monitor.Monitor; - import jboost.tokenizer.DataStream; - import jboost.tokenizer.jboost_DataStream; /** --- 11,14 ---- Index: InequalitySplitter.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/InequalitySplitter.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** InequalitySplitter.java 24 Jan 2008 22:48:54 -0000 1.2 --- InequalitySplitter.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 4,9 **** import jboost.examples.AttributeDescription; import jboost.examples.Instance; import jboost.examples.RealAttribute; - import jboost.examples.*; /** --- 4,9 ---- import jboost.examples.AttributeDescription; import jboost.examples.Instance; + import jboost.examples.IntegerAttribute; import jboost.examples.RealAttribute; /** Index: InequalitySplitterBuilder.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/learner/InequalitySplitterBuilder.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** InequalitySplitterBuilder.java 17 Nov 2008 22:31:13 -0000 1.4 --- InequalitySplitterBuilder.java 8 Jun 2009 23:40:49 -0000 1.4.2.1 *************** *** 3,6 **** --- 3,7 ---- import java.util.Collections; import java.util.List; + import jboost.CandidateSplit; import jboost.NotSupportedException; *************** *** 9,18 **** import jboost.examples.Attribute; import jboost.examples.AttributeDescription; - import jboost.examples.DiscreteAttribute; import jboost.examples.Example; import jboost.examples.Label; - import jboost.examples.*; import jboost.examples.RealAttribute; - import jboost.monitor.Monitor; --- 10,17 ---- import jboost.examples.Attribute; import jboost.examples.AttributeDescription; import jboost.examples.Example; + import jboost.examples.IntegerAttribute; import jboost.examples.Label; import jboost.examples.RealAttribute; *************** *** 217,264 **** * @returns The partition of the data or null if the splitter is not compatible. */ public int[][] split(Splitter sp) { ! if (attributeIndex != sp.getIndex()) ! return (null); ! double threshold= ((InequalitySplitter) sp).getThreshold(); ! int[][] result= new int[2][]; ! if (sortedListOwner) { ! int cutIndex; // locate the place where the ! // list should be cut into two ! for (cutIndex= 0; cutIndex < sortedIndices.length; cutIndex++) { ! if (indexedValues[sortedIndices[cutIndex]] > threshold) ! break; ! } ! result[0]= new int[cutIndex]; // create first list ! for (int j= 0; j < cutIndex; j++) ! result[0][j]= sortedIndices[j]; ! result[1]= new int[sortedIndices.length - cutIndex]; ! // create second list ! for (int j= cutIndex; j < sortedIndices.length; j++) ! result[1][j - cutIndex]= sortedIndices[j]; ! } else { ! int[] l= new int[noOfElements]; ! // temporary storage for list of elements ! int j= 0; ! int cutIndex= -1; ! int index= 0; ! for (int i= 0; i < sortedIndices.length; i++) { ! index= sortedIndices[i]; ! if (examplesMask[index]) { ! if ((cutIndex == -1) && (indexedValues[index] > threshold)) ! cutIndex= j; ! l[j++]= index; ! } ! } ! if (cutIndex==-1) { ! System.out.println(this); ! } ! result[0]= new int[cutIndex]; // create first list ! int noGreater= j; ! result[1]= new int[noGreater - cutIndex]; // create second list ! for (j= 0; j < cutIndex; j++) ! result[0][j]= l[j]; ! for (; j < noGreater; j++) ! result[1][j - cutIndex]= l[j]; } ! return result; } --- 216,272 ---- * @returns The partition of the data or null if the splitter is not compatible. */ public int[][] split(Splitter sp) { ! if (attributeIndex != sp.getIndex()) ! return (null); ! double threshold= ((InequalitySplitter) sp).getThreshold(); ! int[][] result= new int[2][]; ! if (sortedListOwner) { ! int cutIndex; // locate the place where the ! // list should be cut into two ! for (cutIndex= 0; cutIndex < sortedIndices.length; cutIndex++) { ! if (indexedValues[sortedIndices[cutIndex]] > threshold) ! break; } ! result[0]= new int[cutIndex]; // create first list ! for (int j= 0; j < cutIndex; j++) ! result[0][j]= sortedIndices[j]; ! result[1]= new int[sortedIndices.length - cutIndex]; ! // create second list ! for (int j= cutIndex; j < sortedIndices.length; j++) ! result[1][j - cutIndex]= sortedIndices[j]; ! } else { ! int[] l= new int[noOfElements]; ! // temporary storage for list of elements ! int j= 0; ! int cutIndex= -1; ! int index= 0; ! for (int i= 0; i < sortedIndices.length; i++) { ! index= sortedIndices[i]; ! if (examplesMask[index]) { ! if ((cutIndex == -1) && (indexedValues[index] > threshold)) ! cutIndex= j; ! l[j++]= index; ! } ! } ! ! if (cutIndex==-1) { ! System.out.println(this); ! result[0] = new int[0]; ! int noGreater= j; ! result[1] = new int[noGreater]; ! for (j=0;j<noGreater;j++) { ! result[1][j] = l[j]; ! } ! } ! else { ! result[0]= new int[cutIndex]; // create first list ! int noGreater= j; ! result[1]= new int[noGreater - cutIndex]; // create second list ! for (j= 0; j < cutIndex; j++) ! result[0][j]= l[j]; ! for (; j < noGreater; j++) ! result[1][j - cutIndex]= l[j]; ! } ! } ! return result; } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:54
|
Update of /cvsroot/jboost/jboost/src/jboost In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost Modified Files: Tag: jboost-2_0 AllTests.java ComplexLearner.java NotSupportedException.java Log Message: jboost 2.0 Index: ComplexLearner.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/ComplexLearner.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** ComplexLearner.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ComplexLearner.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 3,7 **** import java.util.Vector; - import jboost.booster.AbstractBooster; import jboost.booster.Booster; import jboost.controller.Configuration; --- 3,6 ---- Index: NotSupportedException.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/NotSupportedException.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** NotSupportedException.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- NotSupportedException.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 1,17 **** package jboost; ! /** an Exception that is used to alert that a particular method is not ! supported for this class */ public class NotSupportedException extends Exception { - public NotSupportedException(String m, String c) { - message = "The class "+c - +" does not support the method "+m+"\n"; - } ! public String getMessage() {return message;} ! private String message; ! } --- 1,24 ---- package jboost; ! /** ! * an Exception that is used to alert that a particular method is not supported ! * for this class ! */ public class NotSupportedException extends Exception { ! private static final long serialVersionUID = -3925862347277553481L; ! public NotSupportedException(String m, String c) { ! message = "The class " + c + " does not support the method " + m + "\n"; ! } + public NotSupportedException(String m) { + message = m + "\n"; + } + public String getMessage() { + return message; + } + private String message; + } Index: AllTests.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/AllTests.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** AllTests.java 2 Oct 2007 02:17:14 -0000 1.2 --- AllTests.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 5,11 **** package jboost; import jboost.booster.BoosterTestSuite; import jboost.controller.ControllerTestSuite; - import jboost.atree.AtreeTestSuite; import junit.framework.Test; import junit.framework.TestSuite; --- 5,11 ---- package jboost; + import jboost.atree.AtreeTestSuite; import jboost.booster.BoosterTestSuite; import jboost.controller.ControllerTestSuite; import junit.framework.Test; import junit.framework.TestSuite; |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:54
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/controller Modified Files: Tag: jboost-2_0 Configuration.java Controller.java ControllerTest.java SplitEvaluatorWorker.java Log Message: jboost 2.0 Index: ControllerTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/ControllerTest.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** ControllerTest.java 15 Aug 2008 21:38:13 -0000 1.3 --- ControllerTest.java 8 Jun 2009 23:40:49 -0000 1.3.2.1 *************** *** 9,13 **** import jboost.booster.AdaBoost; import jboost.booster.LogLossBoost; - import jboost.booster.BrownBoost; import jboost.monitor.Monitor; import junit.framework.TestCase; --- 9,12 ---- *************** *** 25,30 **** protected void setUp() throws Exception { super.setUp(); ! String[] args= {"-CONFIG", System.getProperty("jboost.home") + ! File.separatorChar + "src/jboost/controller/jboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); --- 24,28 ---- protected void setUp() throws Exception { super.setUp(); ! String[] args= {"-CONFIG", "src/jboost/controller/jboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); *************** *** 35,40 **** protected void setUpWeighted() throws Exception { ! String[] args= {"-CONFIG", System.getProperty("jboost.home") + ! File.separatorChar + "src/jboost/controller/weightedjboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); --- 33,37 ---- protected void setUpWeighted() throws Exception { ! String[] args= {"-CONFIG", "src/jboost/controller/weightedjboost.config"}; System.out.println(args[1]); m_config= new Configuration(null, args); *************** *** 71,92 **** assertTrue(boosterClass.isInstance(adaboost)); } - - /** - * Test building the Brown booster - */ - public final void testBrownBooster() { - // change booster type - m_config.addOption("booster_type", "jboost.booster.BrownBoost"); - try { - m_controller= new Controller(m_config); - } catch (Exception e) { - e.printStackTrace(); - System.err.println(e.toString()); - fail("Unexepected Exception"); - } - Class boosterClass= m_controller.getBooster().getClass(); - BrownBoost brown = new BrownBoost(); - assertTrue(boosterClass.isInstance(brown)); - } /** --- 68,71 ---- *************** *** 118,122 **** /** - <<<<<<< ControllerTest.java * Test the read/write tree functionality */ --- 97,100 ---- *************** *** 157,160 **** --- 135,139 ---- setUp(); m_config.addOption("numRounds", Integer.toString(rounds)); + m_config.addOption("serialTreeInput",null); m_controller.startLearning(); InstrumentedAlternatingTree secondTree= m_controller.getTree(); *************** *** 175,179 **** public final void testLogLossBoostCycle() { try { ! int rounds= 100; // learn for 40 rounds, write to file, reload and learn for 40 more rounds m_config.addOption("numRounds", Integer.toString(rounds/2)); --- 154,158 ---- public final void testLogLossBoostCycle() { try { ! int rounds= 80; // learn for 40 rounds, write to file, reload and learn for 40 more rounds m_config.addOption("numRounds", Integer.toString(rounds/2)); *************** *** 182,186 **** m_controller.startLearning(); m_controller.outputLearningResults(); ! m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); --- 161,166 ---- m_controller.startLearning(); m_controller.outputLearningResults(); ! ! setUp(); m_config.addOption("numRounds", Integer.toString(rounds/2)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); *************** *** 191,196 **** --- 171,178 ---- // reset the controller and learn for 80 rounds + setUp(); m_config.addOption("numRounds", Integer.toString(rounds)); m_config.addOption("booster_type", "jboost.booster.LogLossBoost"); + m_config.addOption("serialTreeInput",null); m_controller= new Controller(m_config); m_controller.startLearning(); *************** *** 198,202 **** System.out.println(firstTree.toString()); System.out.println(secondTree.toString()); ! // assertTrue(firstTree.toString().equals(secondTree.toString())); } catch (Exception e) { e.printStackTrace(); --- 180,184 ---- System.out.println(firstTree.toString()); System.out.println(secondTree.toString()); ! //assertTrue(firstTree.toString().equals(secondTree.toString())); } catch (Exception e) { e.printStackTrace(); *************** *** 205,208 **** --- 187,248 ---- } + /** + * Test demo files using RobustBoost + * Write out serialized tree, then re-read and continue boosting. + * Compare output to non-serialized tree + */ + public final void testRobustBoostCycle() { + try { + int rounds= 40; + // learn for 40 rounds, write to file, reload and learn for 40 more rounds + m_config.addOption("numRounds", Integer.toString(rounds/2)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_controller= new Controller(m_config); + m_controller.startLearning(); + m_controller.outputLearningResults(); + double[] a1 = m_controller.getMarginsDistribution(); + + m_config.addOption("numRounds", Integer.toString(rounds/2)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0.41584"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_config.addOption("serialTreeInput","src/jboost/controller/atree.serialized"); + m_controller= new Controller(m_config); + m_controller.initializeTree(); + double[] a2 = m_controller.getMarginsDistribution(); + m_controller.executeMainLoop(); + + for (int i=0;i<a1.length;i++) { + assertEquals(a1[i],a2[i],1e-7); + } + + InstrumentedAlternatingTree firstTree= m_controller.getTree(); + + // reset the controller and learn for 80 rounds + m_config.addOption("numRounds", Integer.toString(rounds)); + m_config.addOption("booster_type", "jboost.booster.RobustBoost"); + m_config.addOption("rb_t", "0"); + m_config.addOption("rb_epsilon", "0.1"); + m_config.addOption("rb_theta", "0.0"); + m_config.addOption("rb_sigma_f", "0.01"); + m_config.addOption("serialTreeInput", null); + m_controller= new Controller(m_config); + m_controller.startLearning(); + InstrumentedAlternatingTree secondTree= m_controller.getTree(); + System.out.println(firstTree.toString()); + System.out.println(secondTree.toString()); + // assertTrue(firstTree.toString().equals(secondTree.toString())); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + /** *************** *** 311,315 **** m_controller.outputLearningResults(); m_config.addOption(Configuration.SERIALIZED_INPUT,"src/jboost/controller/weightedatree.serialized"); ! m_config.addOption(Configuration.SAMPLE_TRAINING_DATA, "true"); m_config.addOption(Configuration.SAMPLE_THRESHOLD_WEIGHT, "0.005"); m_controller= new Controller(m_config); --- 351,355 ---- m_controller.outputLearningResults(); m_config.addOption(Configuration.SERIALIZED_INPUT,"src/jboost/controller/weightedatree.serialized"); ! //m_config.addOption(Configuration.SAMPLE_TRAINING_DATA, "true"); m_config.addOption(Configuration.SAMPLE_THRESHOLD_WEIGHT, "0.005"); m_controller= new Controller(m_config); Index: SplitEvaluatorWorker.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/SplitEvaluatorWorker.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** SplitEvaluatorWorker.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- SplitEvaluatorWorker.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 1,7 **** package jboost.controller; import jboost.CandidateSplit; import jboost.util.BaseCountWorker; - import EDU.oswego.cs.dl.util.concurrent.CountDown; /** --- 1,8 ---- package jboost.controller; + import java.util.concurrent.CountDownLatch; + import jboost.CandidateSplit; import jboost.util.BaseCountWorker; /** *************** *** 15,19 **** int pos; ! public SplitEvaluatorWorker(CandidateSplit split, double[] losses, int pos, CountDown count) { super(count); this.split=split; --- 16,20 ---- int pos; ! public SplitEvaluatorWorker(CandidateSplit split, double[] losses, int pos, CountDownLatch count) { super(count); this.split=split; Index: Configuration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Configuration.java,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** Configuration.java 12 Mar 2009 23:42:04 -0000 1.14 --- Configuration.java 8 Jun 2009 23:40:49 -0000 1.14.2.1 *************** *** 2,7 **** import java.io.BufferedReader; - import java.io.FileNotFoundException; import java.io.File; import java.io.IOException; import java.util.HashMap; --- 2,7 ---- import java.io.BufferedReader; import java.io.File; [...1719 lines suppressed...] ! public Command(String n, String v) { ! name = n; ! value = v; ! } ! public String getValue() { ! checkCount++; ! return (value); ! } ! ! public int getCount() { ! return (checkCount); ! } + public String toString() { + String retval = new String("-"); + retval += name + " " + value; + return (retval); + } + } Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** Controller.java 12 Mar 2009 23:42:04 -0000 1.17 --- Controller.java 8 Jun 2009 23:40:49 -0000 1.17.2.1 *************** *** 1,3 **** --- 1,4 ---- package jboost.controller; + import java.io.BufferedWriter; import java.io.FileInputStream; *************** *** 11,14 **** --- 12,21 ---- import java.util.Iterator; import java.util.Vector; [...1452 lines suppressed...] ! : m_config ! .getSpecFileName()), ! m_exampleDescription); ! else throw new RuntimeException( ! "Controller.generateCode: Unrecognized language:" ! + language); ! PrintWriter codeOutputStream = ! new PrintWriter( ! new BufferedWriter(new FileWriter(codeOutputFileName))); ! codeOutputStream.println(code); ! codeOutputStream.close(); ! } ! catch (Exception e) { ! System.err.println("Exception occured while attempting to write " ! + language + " code"); ! System.err.println("Message:" + e); ! e.printStackTrace(); ! } ! } } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:54
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/visualization Modified Files: Tag: jboost-2_0 DataSet.java HistogramFrame.java Log Message: jboost 2.0 Index: DataSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/DataSet.java,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** DataSet.java 12 Mar 2009 23:42:04 -0000 1.7 --- DataSet.java 8 Jun 2009 23:40:49 -0000 1.7.2.1 *************** *** 30,34 **** private XYIntervalSeries[] fluctRangeSeries; ! private double minScore,maxScore; private int total_pos,total_neg; private int neg_label=-1,pos_label=+1; --- 30,37 ---- private XYIntervalSeries[] fluctRangeSeries; ! //private double minScore,maxScore; ! private double[] minScores, maxScores; ! private double[] minRanges, maxRanges; ! private int total_pos,total_neg; private int neg_label=-1,pos_label=+1; *************** *** 37,40 **** --- 40,49 ---- this.iterList = iterList; data = new ArrayList<ArrayList<DataElement>>(); + minScores = new double[iterList.length]; + maxScores = new double[iterList.length]; + + minRanges = new double[iterList.length]; + maxRanges = new double[iterList.length]; + for(int i=0; i<iterList.length; i++) { data.add(new ArrayList<DataElement>()); *************** *** 53,58 **** --- 62,75 ---- } public DataSet(int size,int iterations) { + data = new ArrayList<ArrayList<DataElement>>(); iterList = new String[iterations]; + + minScores = new double[iterations]; + maxScores = new double[iterations]; + + minRanges = new double[iterations]; + maxRanges = new double[iterations]; + initFluctSeries(iterations); *************** *** 96,100 **** //System.out.printf("data.size = %d%n", size); for(int i=0; i<size; i++) { ! addScoresList(data.get(i),i); //System.out.printf("finished pre-processing %d%n",i); } --- 113,158 ---- //System.out.printf("data.size = %d%n", size); for(int i=0; i<size; i++) { ! ! ArrayList<DataElement> d=data.get(i); ! addScoresList(d,i); ! ! // d should already be sorted ! ! int bottom = 1*(d.size()-1)/100; ! int top = 99*(d.size()-1)/100; ! ! minRanges[i] = d.get(bottom).value; ! maxRanges[i] = d.get(top).value; ! ! maxRanges[i] = Math.max(Math.abs(minRanges[i]), Math.abs(maxRanges[i])); ! minRanges[i] = -maxRanges[i]; ! ! if (minRanges[i] > -1 || maxRanges[i] < 1) { ! minRanges[i] = -1; ! maxRanges[i] = 1; ! } ! ! if (i > 0 && minRanges[i] > minRanges[i-1]) minRanges[i] = minRanges[i-1]; ! if (i > 0 && maxRanges[i] < maxRanges[i-1]) maxRanges[i] = maxRanges[i-1]; ! ! double min = d.get(0).value; ! double max = d.get(d.size()-1).value; ! ! ! minScores[i] = min; ! maxScores[i] = max; ! ! maxScores[i] = Math.max(Math.abs(maxScores[i]),Math.abs(minScores[i])); ! minScores[i] = -maxScores[i]; ! ! if (minScores[i] > -1 || maxScores[i] < 1) { ! minScores[i] = -1; ! maxScores[i] = 1; ! } ! ! if (i > 0 && minScores[i] > minScores[i-1]) minScores[i] = minScores[i-1]; ! if (i > 0 && maxScores[i] < maxScores[i-1]) maxScores[i] = maxScores[i-1]; ! ! //System.out.printf("finished pre-processing %d%n",i); } *************** *** 120,126 **** if(index==0) { ! minScore = scores.get(0).value; ! maxScore = scores.get(scores.size()-1).value; ! for(int i=0; i<a.length; i++) { DataElement e = ((DataElement) a[i]); --- 178,182 ---- if(index==0) { ! for(int i=0; i<a.length; i++) { DataElement e = ((DataElement) a[i]); *************** *** 134,140 **** //System.out.printf("total_neg=%d, total_pos=%d%n",total_neg,total_pos); - } else { - minScore = Math.min(minScore,scores.get(0).value); - maxScore = Math.max(maxScore,scores.get(scores.size()-1).value); } --- 190,193 ---- *************** *** 154,163 **** } ! public double getMin() { ! return minScore; } ! public double getMax() { ! return maxScore; } --- 207,224 ---- } ! public double getMin(int iter) { ! return minScores[iter]; } ! public double getMax(int iter) { ! return maxScores[iter]; ! } ! ! public double getMinRange(int iter) { ! return minRanges[iter]; ! } ! ! public double getMaxRange(int iter) { ! return maxRanges[iter]; } *************** *** 165,170 **** double[] h = new double[bins]; ! double step = (maxScore-minScore)/bins; ! double s=minScore+step; double prev = total_pos; if(label != pos_label) prev = total_neg; --- 226,232 ---- double[] h = new double[bins]; ! ! double step = (maxScores[iteration]-minScores[iteration])/bins; ! double s=minScores[iteration]+step; double prev = total_pos; if(label != pos_label) prev = total_neg; *************** *** 249,261 **** public XYSeries generateRoC(int neg_label, int pos_label) { ! XYSeries roc = new XYSeries("ROC"); ! ! Object[] a = (Object[]) data.get(iteration).toArray(); ! for(int i=a.length-1; i >= 0; i--) { ! DataElement e = ((DataElement) a[i]); ! roc.add(e.falsePositives/total_neg, e.truePositives/total_pos); ! } ! return roc; } --- 311,323 ---- public XYSeries generateRoC(int neg_label, int pos_label) { ! XYSeries roc = new XYSeries("ROC"); ! Object[] a = (Object[]) data.get(iteration).toArray(); ! ! for(int i=a.length-1; i >= 0; i--) { ! DataElement e = ((DataElement) a[i]); ! roc.add(e.falsePositives/total_neg, e.truePositives/total_pos); ! } ! return roc; } *************** *** 309,314 **** DataSet test = new DataSet(1000,3); - System.out.printf("range of scores = [%f,%f]%n",test.minScore,test.maxScore); - test.generateRoC(-1,1); double[] a = test.getFPTP(5.0); --- 371,374 ---- Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** HistogramFrame.java 16 Mar 2009 19:43:29 -0000 1.8 --- HistogramFrame.java 8 Jun 2009 23:40:49 -0000 1.8.2.1 *************** *** 1,28 **** package jboost.visualization; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import java.awt.event.ItemEvent; - import java.awt.event.ItemListener; [...2317 lines suppressed...] + post("updating RoC..."); + XYSeries rocSeries = rawData.generateRoC(negLabel,posLabel); + rocDataset.removeSeries(0); + rocDataset.addSeries(rocSeries); + post("updating marker..."); + updateUpperMarker(); + updateLowerMarker(); + post("done"); + } + + + private void post(String s) { + System.out.println(s); + } + + } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:53
|
Update of /cvsroot/jboost/jboost/src/jboost/atree In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/atree Modified Files: Tag: jboost-2_0 AlternatingTreeTest.java InstrumentedAlternatingTree.java InstrumentedAlternatingTreeTest.java PredictorNode.java SplitterBuilderWorker.java SplitterNode.java Log Message: jboost 2.0 Index: InstrumentedAlternatingTreeTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/InstrumentedAlternatingTreeTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** InstrumentedAlternatingTreeTest.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- InstrumentedAlternatingTreeTest.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 7,11 **** import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; - import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; --- 7,10 ---- Index: PredictorNode.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/PredictorNode.java,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** PredictorNode.java 7 Apr 2008 17:09:06 -0000 1.3 --- PredictorNode.java 8 Jun 2009 23:40:49 -0000 1.3.4.1 *************** *** 5,9 **** import jboost.booster.Prediction; - import jboost.booster.NormalizedPrediction; import jboost.examples.Instance; import jboost.learner.IncompAttException; --- 5,8 ---- *************** *** 125,129 **** for(int i=0;i<pn.splitterNodes.size();i++){ tmp = ((SplitterNode)pn.splitterNodes.elementAt(i)).predictNode(instance); ! tmp = findPrediction(instance, iter, tmp); if (tmp==null) { // The node is not down there or this instance does --- 124,130 ---- for(int i=0;i<pn.splitterNodes.size();i++){ tmp = ((SplitterNode)pn.splitterNodes.elementAt(i)).predictNode(instance); ! ! if (tmp!=null) tmp = findPrediction(instance, iter, tmp); ! if (tmp==null) { // The node is not down there or this instance does *************** *** 189,196 **** /** Add a prediction to its prediction value */ public void addToPrediction(Prediction p) { - if (p instanceof NormalizedPrediction) { - System.err.println("Cannot add normalized prediction to existing node"); - System.exit(2); - } prediction.add(p); } --- 190,193 ---- Index: AlternatingTreeTest.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/AlternatingTreeTest.java,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** AlternatingTreeTest.java 2 Oct 2007 02:28:06 -0000 1.1 --- AlternatingTreeTest.java 8 Jun 2009 23:40:49 -0000 1.1.4.1 *************** *** 6,10 **** import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; - import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; --- 6,9 ---- Index: SplitterBuilderWorker.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/SplitterBuilderWorker.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.4.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1 *** SplitterBuilderWorker.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- SplitterBuilderWorker.java 8 Jun 2009 23:40:49 -0000 1.1.1.1.4.1 *************** *** 2,5 **** --- 2,6 ---- import java.util.Vector; + import java.util.concurrent.CountDownLatch; import jboost.CandidateSplit; *************** *** 7,11 **** import jboost.monitor.Monitor; import jboost.util.BaseCountWorker; - import EDU.oswego.cs.dl.util.concurrent.CountDown; /** --- 8,11 ---- *************** *** 19,23 **** Vector splitters; ! public SplitterBuilderWorker(PredictorNodeSB pSB, Vector splitters, CountDown count) { super(count); this.pSB=pSB; --- 19,23 ---- Vector splitters; ! public SplitterBuilderWorker(PredictorNodeSB pSB, Vector splitters, CountDownLatch count) { super(count); this.pSB=pSB; Index: SplitterNode.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/SplitterNode.java,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** SplitterNode.java 2 Oct 2007 02:28:06 -0000 1.2 --- SplitterNode.java 8 Jun 2009 23:40:49 -0000 1.2.4.1 *************** *** 1,7 **** package jboost.atree; - import java.io.IOException; - import java.io.ObjectInputStream; - import java.io.ObjectOutputStream; import java.io.Serializable; --- 1,4 ---- Index: InstrumentedAlternatingTree.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/InstrumentedAlternatingTree.java,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -C2 -d -r1.9 -r1.9.2.1 *** InstrumentedAlternatingTree.java 19 Feb 2009 14:20:25 -0000 1.9 --- InstrumentedAlternatingTree.java 8 Jun 2009 23:40:49 -0000 1.9.2.1 *************** *** 5,8 **** --- 5,11 ---- import java.util.Iterator; import java.util.Vector; + import java.util.concurrent.CountDownLatch; + import java.util.concurrent.Executor; + import java.util.concurrent.RejectedExecutionException; import jboost.CandidateSplit; *************** *** 13,23 **** import jboost.booster.Bag; import jboost.booster.Booster; - import jboost.booster.BrownBoost; - import jboost.booster.MulticlassWrapMH; import jboost.booster.Prediction; - import jboost.booster.NormalizedPrediction; import jboost.booster.RobustBinaryPrediction; import jboost.booster.RobustBoost; - import jboost.booster.MulticlassWrapMH.MultiPrediction; import jboost.controller.Configuration; import jboost.controller.ConfigurationException; --- 16,22 ---- *************** *** 27,32 **** import jboost.monitor.Monitor; import jboost.util.ExecutorSinglet; ! import EDU.oswego.cs.dl.util.concurrent.CountDown; ! import EDU.oswego.cs.dl.util.concurrent.Executor; --- 26,30 ---- import jboost.monitor.Monitor; import jboost.util.ExecutorSinglet; ! *************** *** 38,41 **** --- 36,40 ---- */ + @SuppressWarnings("unchecked") public class InstrumentedAlternatingTree extends ComplexLearner { *************** *** 94,98 **** * @param config The configuration information. */ ! public InstrumentedAlternatingTree(Vector sb, Booster b, int[] ex, Configuration config) { --- 93,98 ---- * @param config The configuration information. */ ! ! public InstrumentedAlternatingTree(Vector sb, Booster b, int[] ex, Configuration config) { *************** *** 108,113 **** throws InstrumentException, NotSupportedException { ! init(splitterbuilders, booster, examples, config); ! createRoot(); instrumentAlternatingTree(tree); } --- 108,113 ---- throws InstrumentException, NotSupportedException { ! init(splitterbuilders, booster, examples, config); ! createRoot(tree.getRoot()); instrumentAlternatingTree(tree); } *************** *** 189,192 **** --- 189,201 ---- } + + private void createRoot(PredictorNode root) { + PredictorNode predictorNode= new PredictorNode(root.prediction, "R", + 0, null, null, 0); + + m_predictors.add(predictorNode); + } + + /** * Suggest a list of Candidate Splitters *************** *** 224,237 **** // create a synchronization barrier that counts the number // of processed splitter builders ! CountDown sbCount=new CountDown(m_splitterBuilders.size()); Vector splitters=new Vector(m_splitterBuilders.size()); for (Iterator i = m_splitterBuilders.iterator(); i.hasNext(); ) { PredictorNodeSB pSB=(PredictorNodeSB)i.next(); if (m_treeType == AtreeType.ADD_ROOT && pSB.pNode != 0) { ! while(sbCount.currentCount()!=0) { ! sbCount.release(); } break; --- 233,248 ---- // create a synchronization barrier that counts the number // of processed splitter builders ! CountDownLatch sbCount=new CountDownLatch(m_splitterBuilders.size()); Vector splitters=new Vector(m_splitterBuilders.size()); for (Iterator i = m_splitterBuilders.iterator(); i.hasNext(); ) { + //System.out.println("Creating new SplitterBuilderWorker and run it ... "); + PredictorNodeSB pSB=(PredictorNodeSB)i.next(); if (m_treeType == AtreeType.ADD_ROOT && pSB.pNode != 0) { ! while(sbCount.getCount()!=0) { ! sbCount.countDown(); } break; *************** *** 242,246 **** m_predictors.get(pSB.pNode)).getSplitterNodeNo(); if (childCount > 0) { ! sbCount.release(); continue; } --- 253,257 ---- m_predictors.get(pSB.pNode)).getSplitterNodeNo(); if (childCount > 0) { ! sbCount.countDown(); continue; } *************** *** 251,264 **** m_predictors.get(pSB.pNode)).getSplitterNodeNo(); if (childCount > 0) { ! sbCount.release(); continue; } } SplitterBuilderWorker sbw= new SplitterBuilderWorker(pSB,splitters,sbCount); try { pe.execute(sbw); ! } catch (InterruptedException ie) { System.err.println("exception ocurred while handing off the " + "splitter job to the pool: " --- 262,278 ---- m_predictors.get(pSB.pNode)).getSplitterNodeNo(); if (childCount > 0) { ! sbCount.countDown(); continue; } } + //System.out.println("Create new SplitterBuilderWorker and run it ... "); + SplitterBuilderWorker sbw= new SplitterBuilderWorker(pSB,splitters,sbCount); + try { pe.execute(sbw); ! } catch (RejectedExecutionException ie) { System.err.println("exception ocurred while handing off the " + "splitter job to the pool: " *************** *** 268,278 **** } // wait on all threads to finish try { ! sbCount.acquire(); } catch(InterruptedException ie) { ! if(sbCount.currentCount()!=0) { System.err.println("interrupted exception occurred, but the " ! + "sbCount is " + sbCount.currentCount()); } }; --- 282,294 ---- } + //System.out.println("Waiting on all threads to finish..."); + // wait on all threads to finish try { ! sbCount.await(); } catch(InterruptedException ie) { ! if(sbCount.getCount()!=0) { System.err.println("interrupted exception occurred, but the " ! + "sbCount is " + sbCount.getCount()); } }; *************** *** 281,323 **** } ! /** ! * Build a splitter using a single splitter buildier ! * @param retval ! * @throws NotSupportedException ! */ ! private void buildSplitter(PredictorNodeSB pSB, Vector splitters) ! throws NotSupportedException { ! CandidateSplit split; ! ! double trivLoss; ! long start; ! long stop; ! ! // Create bag containing all m_examples reaching this node: ! // tmpBag = m_booster.newBag(makeIndices((boolean []) ! // m_masks.get(pSB.pNode))); Compute loss for trivial split: ! // trivLoss = m_booster.getLoss(new Bag[] {tmpBag}); ! // TODO: ! // need to fix so that splits worse than trivial are not ! // added. In the meantime, allow all splits. ! trivLoss= Double.MAX_VALUE; ! start= System.currentTimeMillis(); ! int j=0; ! for (j= 0; j < pSB.SB.length; j++) { ! split= pSB.SB[j].build(); ! ! // only add candidates with loss better than trivial split ! // TODO: figure out what to do if no splits better ! // than trivial ! if (split != null && split.getLoss() < trivLoss) ! splitters.add(new AtreeCandidateSplit(pSB.pNode, split)); ! } ! stop= System.currentTimeMillis(); ! if (Monitor.logLevel > 3) { ! Monitor.log("It took an average of " + (stop-start)/(j*1000.0) + ! " seconds to build " + j + " splitterbuilders."); ! } ! } ! /** --- 297,301 ---- } ! /** *************** *** 333,341 **** m_booster.update(pred, partition); - if (pred.length > 0 && pred[0] instanceof NormalizedPrediction) { - System.err.println("Cannot update root with mixed binary pred"); - System.exit(2); - } - ((PredictorNode) m_predictors.get(0)).addToPrediction(pred[0]); if (pred==null) { --- 311,314 ---- *************** *** 398,402 **** SplitterBuilder[] childArray= new SplitterBuilder[parentArray.length]; for (int j= 0; j < parentArray.length; j++) { ! childArray[j]= parentArray[j].spawn(examplesMask, partition[i].length); } PredictorNodeSB pnSB= new PredictorNodeSB(pInt[i], childArray); --- 371,375 ---- SplitterBuilder[] childArray= new SplitterBuilder[parentArray.length]; for (int j= 0; j < parentArray.length; j++) { ! childArray[j]= parentArray[j].spawn(examplesMask, partition[i].length); } PredictorNodeSB pnSB= new PredictorNodeSB(pInt[i], childArray); *************** *** 446,450 **** for (int i=0; i < predictions.length; i++) { ! // RobustBoost needs to scale all of the previous // hyphothesis by exp(-dt) --- 419,423 ---- for (int i=0; i < predictions.length; i++) { ! // RobustBoost needs to scale all of the previous // hyphothesis by exp(-dt) *************** *** 455,458 **** --- 428,435 ---- double exp_negative_dt = Math.exp(-dt) ; + for (int j=0; j < i; j++) { + predictions[j].scale(exp_negative_dt); + } + // for each prediction before this one for (int nodeidx=0;nodeidx < m_predictors.size();nodeidx++) { *************** *** 467,511 **** } } - // multiclass case - else if (m_booster instanceof MulticlassWrapMH) { - Booster b = ((MulticlassWrapMH)m_booster).m_booster; - if (b instanceof RobustBoost) { - for (int i=0; i < predictions.length; i++) { - - if (predictions[i] instanceof MultiPrediction) { - - Prediction[] preds = ((MultiPrediction)predictions[i]).preds; - - for (int j=0;j<preds.length;j++) { - - if (preds[j] instanceof RobustBinaryPrediction) { - - // for every RobustBinaryPrediction added before this one - // we scale all of them by exp(-dt) - double dt = ((RobustBinaryPrediction)preds[j]).getDt(); - double exp_negative_dt = Math.exp(-dt) ; - - // for each prediction before this one - for (int nodeidx=0;nodeidx < m_predictors.size();nodeidx++) { - PredictorNode cpn = (PredictorNode)m_predictors.get(nodeidx); - cpn.prediction.scale(exp_negative_dt); - } - - } - else { - throw new RuntimeException("RobustBinaryPrediction is expected. This should never happen!"); - } - } - } - else { - throw new RuntimeException("RobustBinaryPrediction is expected. This should never happen!"); - } - } - } - } - - //--------------------------------// ! if (node != null && (predictions.length > 0 && !(predictions[0] instanceof NormalizedPrediction)) ) { for (int i=0; i < node.predictorNodes.length; i++) { node.predictorNodes[i].addToPrediction(predictions[i]); --- 444,449 ---- } } ! if (node != null && predictions.length > 0) { for (int i=0; i < node.predictorNodes.length; i++) { node.predictorNodes[i].addToPrediction(predictions[i]); *************** *** 566,570 **** Splitter splitter= acand.getSplitter(); PredictorNode parent= (PredictorNode) m_predictors.get(acand.getPredictorNode()); ! m_booster.update(predictions, partition); if (parent==null) { System.err.println("Adding candidate and the parent is null!"); --- 504,510 ---- Splitter splitter= acand.getSplitter(); PredictorNode parent= (PredictorNode) m_predictors.get(acand.getPredictorNode()); ! ! //m_booster.update(predictions, partition); ! if (parent==null) { System.err.println("Adding candidate and the parent is null!"); *************** *** 657,690 **** } - /** Adjusts the predictions of all of the existing {@link PredictorNode}s in - * the tree. */ - public void adjustPredictions() { - int[][] examples= null; - boolean[] exMask= null; - int count= 0; - PredictorNode[] pn= null; - int s= m_splitters.size(); - int[] pNodes= null; - Bag[] b= null; - int nodeNo= 0; - Prediction[] p= null; - for (int i= 0; i < s; i++) { - pNodes= (int[]) m_splitters.get(i); - pn= new PredictorNode[pNodes.length]; - examples= new int[pNodes.length][]; - b= new Bag[pNodes.length]; - for (int j= 0; j < pNodes.length; j++) { - nodeNo= pNodes[j]; - exMask= (boolean[]) m_masks.get(nodeNo); - pn[j]= (PredictorNode) m_predictors.get(nodeNo); - examples[j]= makeIndices(exMask); - b[j]= m_booster.newBag(examples[j]); - } - p= m_booster.getPredictions(b,examples); - m_booster.update(p, examples); - for (int j= 0; i < pNodes.length; j++) - pn[j].addToPrediction(p[j]); - } - } /** Produces a string describing this tree. */ public String toString() { --- 597,600 ---- *************** *** 699,718 **** public boolean boosterIsFinished() { - if (m_booster instanceof BrownBoost){ - BrownBoost b = (BrownBoost) m_booster; - return b.isFinished(); - } ! if (m_booster instanceof RobustBoost){ RobustBoost b = (RobustBoost) m_booster; return b.isFinished(); } ! if (m_booster instanceof MulticlassWrapMH) { ! if (((MulticlassWrapMH)m_booster).m_booster instanceof RobustBoost) { ! RobustBoost b = (RobustBoost)(((MulticlassWrapMH)m_booster).m_booster); ! return b.isFinished(); ! } ! } double EPS = 1e-50; --- 609,619 ---- public boolean boosterIsFinished() { ! if (m_booster instanceof RobustBoost){ RobustBoost b = (RobustBoost) m_booster; return b.isFinished(); } ! double EPS = 1e-50; *************** *** 786,803 **** - /** Make a integer array of m_examples given an ExampleMask */ - private int[] makeIndices(boolean[] exMask) { - int[] examples= null; - int count= 0; - for (int j= 0; j < exMask.length; j++) - if (exMask[j] == true) - count++; - examples= new int[count]; - count= 0; - for (int j= 0; j < exMask.length; j++) - if (exMask[j] == true) - examples[count++]= j; - return (examples); - } /** the last base predictor added to the tree */ private Predictor lastBasePredictor= null; --- 687,690 ---- |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:53
|
Update of /cvsroot/jboost/jboost In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232 Modified Files: Tag: jboost-2_0 build.xml Log Message: jboost 2.0 Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** build.xml 9 Feb 2009 22:32:09 -0000 1.11 --- build.xml 8 Jun 2009 23:40:49 -0000 1.11.2.1 *************** *** 2,9 **** <project name="jboost Buildfile" default="jar" basedir="."> ! <!-- Properties --> ! <property environment="env"/> <property name="dir.src" value="src"/> <property name="dir.lib" value="lib"/> --- 2,10 ---- <project name="jboost Buildfile" default="jar" basedir="."> ! <!-- Properties --> ! <property environment="env"/> + <property name="jboost.version" value="2.0r7"/> <property name="dir.src" value="src"/> <property name="dir.lib" value="lib"/> *************** *** 15,41 **** <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> - <property name="jboost.version" value="1.4.1"/> <property name="test.class.name" value="jboost.AllTests"/> <path id="test.classpath"> ! <pathelement location="${dir.dist}" /> ! <pathelement location="${dir.lib}" /> ! <fileset dir="${dir.dist}"> ! <include name="*.jar"/> ! </fileset> ! <fileset dir="${dir.lib}"> ! <include name="*.jar"/> ! </fileset> </path> <!-- Targets --> ! <target name="prepare"> <mkdir dir="${dir.build}"/> <mkdir dir="${dir.dist}"/> ! <mkdir dir="${dir.javadoc}"/> ! ! <dirname property="jboost.home" file="build.xml"/> </target> <target name="clean" --- 16,40 ---- <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> <property name="test.class.name" value="jboost.AllTests"/> <path id="test.classpath"> ! <pathelement location="${dir.dist}" /> ! <pathelement location="${dir.lib}" /> ! <fileset dir="${dir.dist}"> ! <include name="*.jar"/> ! </fileset> ! <fileset dir="${dir.lib}"> ! <include name="*.jar"/> ! </fileset> </path> <!-- Targets --> ! <target name="prepare"> <mkdir dir="${dir.build}"/> <mkdir dir="${dir.dist}"/> ! <dirname property="jboost.home" file="build.xml"/> </target> + <target name="clean" *************** *** 50,65 **** <delete file="jboost-${jboost.version}.exe" /> <delete> ! <fileset dir="." includes="**/*~"/> </delete> </target> ! ! <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"/> --- 49,64 ---- <delete file="jboost-${jboost.version}.exe" /> <delete> ! <fileset dir="." includes="**/*~"/> </delete> </target> ! <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"/> *************** *** 68,229 **** <delete dir="${dir.doc}/javadoc"/> <delete> ! <fileset dir="." includes="${dir.doc}/*.html" /> </delete> </target> - <target name="compile" depends="prepare" description="Compile all source code."> <javac srcdir="${dir.src}" ! classpath="${dir.lib}/junit.jar:${dir.lib}/concurrent.jar:${dir.lib}/jfreechart-1.0.10.jar:${dir.lib}/jcommon-1.0.8.jar:${dir.lib}/swing-layout-1.0.jar" destdir="${dir.build}" ! debug="on" ! executable="/usr/java/jdk1.3/bin/javac" ! /> </target> <target name="jar" depends="compile" description="Generates jboost.jar in the 'dist' directory."> <jar jarfile="${dir.dist}/jboost.jar" basedir="${dir.build}"> ! <manifest> ! <attribute name="Main-Class" value="jboost.controller.Controller"/> ! </manifest> ! </jar> </target> <target name="javadoc" depends="prepare" description="create documentation"> <javadoc packagenames="jboost,jboost.*" ! excludepackagenames="jboost.monitor" ! sourcepath="${dir.src}" ! destdir="${dir.javadoc}" ! author="true" ! version="true" ! use="true" ! windowtitle="JBoost API"> ! <packageset dir="${dir.src}" defaultexcludes="yes"> ! <exclude name="**/*Test*"/> ! </packageset> ! </javadoc> </target> <target name="test-all" depends="jar" ! description="run all junit tests"> <echo message="Set jboost.home=${jboost.home}"/> ! <junit fork="yes" haltonfailure="yes"> ! <jvmarg value="-Djboost.home=${jboost.home}"/> ! <test name="${test.class.name}"/> ! <formatter type="plain" usefile="false"/> ! <classpath refid="test.classpath" /> ! </junit> </target> <target name="dist" depends="jar" ! description="create distribution file"> ! ! <delete dir="${jboost.home}/jboost-${jboost.version}" /> ! <delete dir="${jboost.home}/doc/css" /> ! <delete dir="${jboost.home}/doc/diagrams" /> ! <delete dir="${jboost.home}/doc/images" /> ! <delete dir="${jboost.home}/doc/javadoc" /> ! <echo message="Building version ${jboost.version}"/> ! <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" /> ! <move todir="${jboost.home}/doc" > ! <fileset dir="${jboost.home}"> ! <include name="*.html" /> ! <include name="css/" /> ! <include name="images/" /> ! <include name="diagrams/" /> ! <include name="javadoc/" /> ! </fileset> ! </move> ! <exec executable="cp" > ! <arg value="-r" /> ! <arg value="${jboost.home}/src" /> ! <arg value="${jboost.home}/doc" /> ! <arg value="${jboost.home}/dist" /> ! <arg value="${jboost.home}/build.xml" /> ! <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" /> ! <arg value="${jboost.home}/jboost.bat" /> ! <arg value="${jboost.home}/jboost-${jboost.version}" /> ! </exec> ! <copy todir="${jboost.home}/jboost-${jboost.version}/scripts/" > ! <fileset dir="${dir.scripts}"> ! <include name="*.py" /> ! <include name="*.pl" /> ! <include name="*.README" /> ! </fileset> ! </copy> ! ! <copy todir="${jboost.home}/jboost-${jboost.version}/demo/" > ! <fileset dir="${dir.demo}"> ! <include name="README" /> ! <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> ! ! <!-- ! <tar destfile="jboost-${jboost.version}.tar"> ! <tarfileset dir="jboost-${jboost.version}" prefix="jboost-${jboost.version}"/> ! </tar> ! <gzip zipfile="jboost-${jboost.version}.tgz" src="jboost-${jboost.version}.tar"/> ! --> ! ! <exec executable="tar" > ! <arg value="cpzf" /> ! <arg value="jboost-${jboost.version}.tgz" /> ! <arg value="jboost-${jboost.version}" /> ! </exec> ! ! ! ! <zip destfile="jboost-${jboost.version}.zip"> ! <zipfileset dir="jboost-${jboost.version}" prefix="jboost-${jboost.version}"/> ! </zip> ! ! ! <concat destfile="jboost-${jboost.version}.exe" force="yes" binary="true"> ! <filelist dir="." files="${dir.lib}/unzipsfx.exe,jboost-${jboost.version}.zip"/> ! </concat> ! <exec executable="zip" > ! <arg value="-A" /> ! <arg value="jboost-${jboost.version}.exe" /> ! </exec> </target> ! <target name="post-sf" depends="dist" description="ftp files to sourceforge"> --- 67,223 ---- <delete dir="${dir.doc}/javadoc"/> <delete> ! <fileset dir="." includes="${dir.doc}/*.html" /> </delete> </target> <target name="compile" depends="prepare" description="Compile all source code."> <javac srcdir="${dir.src}" ! classpath="${dir.lib}/junit.jar:${dir.lib}/jfreechart-1.0.10.jar:${dir.lib}/jcommon-1.0.8.jar" destdir="${dir.build}" ! debug="on" /> </target> + <target name="jar" depends="compile" description="Generates jboost.jar in the 'dist' directory."> <jar jarfile="${dir.dist}/jboost.jar" basedir="${dir.build}"> ! <manifest> ! <attribute name="Main-Class" value="jboost.controller.Controller"/> ! </manifest> ! </jar> </target> + <target name="javadoc" depends="prepare" description="create documentation"> + <mkdir dir="${dir.javadoc}"/> <javadoc packagenames="jboost,jboost.*" ! excludepackagenames="jboost.monitor" ! sourcepath="${dir.src}" ! destdir="${dir.javadoc}" ! author="true" ! version="true" ! use="true" ! windowtitle="JBoost API"> ! <packageset dir="${dir.src}" defaultexcludes="yes"> ! <exclude name="**/*Test*"/> ! </packageset> ! </javadoc> </target> + <target name="test-all" depends="jar" ! description="run all junit tests"> <echo message="Set jboost.home=${jboost.home}"/> ! <junit fork="yes" haltonfailure="yes"> ! <jvmarg value="-Djboost.home=${jboost.home}"/> ! <test name="${test.class.name}"/> ! <formatter type="plain" usefile="false"/> ! <classpath refid="test.classpath" /> ! </junit> </target> <target name="dist" depends="jar" ! description="create distribution file"> ! <delete dir="${jboost.home}/jboost-${jboost.version}" /> ! <delete dir="${jboost.home}/doc/css" /> ! <delete dir="${jboost.home}/doc/diagrams" /> ! <delete dir="${jboost.home}/doc/images" /> ! <delete dir="${jboost.home}/doc/javadoc" /> + <echo message="Building version ${jboost.version}"/> + <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" /> --> ! <move todir="${jboost.home}/doc" > ! <fileset dir="${jboost.home}"> ! <include name="*.html" /> ! <include name="css/" /> ! <include name="images/" /> ! <include name="diagrams/" /> ! <include name="javadoc/" /> ! </fileset> ! </move> + <exec executable="cp" > + <arg value="-r" /> + <arg value="${jboost.home}/src" /> + <arg value="${jboost.home}/doc" /> + <arg value="${jboost.home}/dist" /> + <arg value="${jboost.home}/build.xml" /> + <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" /> + <arg value="${jboost.home}/jboost.bat" /> + <arg value="${jboost.home}/jboost-${jboost.version}" /> + </exec> + + <copy todir="${jboost.home}/jboost-${jboost.version}/scripts/" > + <fileset dir="${dir.scripts}"> + <include name="*.py" /> + <include name="*.pl" /> + <include name="*.README" /> + <include name="MultiClass/*" /> + </fileset> + </copy> ! <copy todir="${jboost.home}/jboost-${jboost.version}/scripts/MultiClass/" > ! <fileset dir="${dir.scripts}/MultiClass"> ! </fileset> ! </copy> ! ! <copy todir="${jboost.home}/jboost-${jboost.version}/demo/" > ! <fileset dir="${dir.demo}"> ! <include name="README" /> ! <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> ! <exec executable="tar" > ! <arg value="cpzf" /> ! <arg value="jboost-${jboost.version}.tgz" /> ! <arg value="jboost-${jboost.version}" /> ! </exec> ! ! <zip destfile="jboost-${jboost.version}.zip"> ! <zipfileset dir="jboost-${jboost.version}" prefix="jboost-${jboost.version}"/> ! </zip> ! <concat destfile="jboost-${jboost.version}.exe" force="yes" binary="true"> ! <filelist dir="." files="${dir.lib}/unzipsfx.exe,jboost-${jboost.version}.zip"/> ! </concat> + <exec executable="zip" > + <arg value="-A" /> + <arg value="jboost-${jboost.version}.exe" /> + </exec> </target> ! ! <!-- TODO: UPDATE THIS --> <target name="post-sf" depends="dist" description="ftp files to sourceforge"> *************** *** 244,257 **** </target> - - <target name="cross-validation" depends="jar" - description="run n-fold cross-validation"> - <mkdir dir="${dir.analysis}"/> - <exec executable="${dir.scripts}/nfold.py"> - <env key="CLASSPATH" value="${dir.dist}/jboost.jar"/> - <arg line="--folds=${analysis.folds} --rounds=${analysis.rounds} - --data=${analysis.data} --spec=${analysis.spec} --dir=${dir.analysis} ${analysis.generate}" /> - </exec> - </target> </project> --- 238,241 ---- |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:53
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/src/jboost/monitor Modified Files: Tag: jboost-2_0 Monitor.java Log Message: jboost 2.0 Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -C2 -d -r1.13 -r1.13.2.1 *** Monitor.java 19 Feb 2009 14:23:29 -0000 1.13 --- Monitor.java 8 Jun 2009 23:40:49 -0000 1.13.2.1 *************** *** 1,4 **** --- 1,5 ---- package jboost.monitor; import java.io.BufferedWriter; + import java.io.ByteArrayOutputStream; import java.io.FileWriter; import java.io.IOException; *************** *** 8,18 **** import java.util.ArrayList; import java.util.Date; import jboost.Predictor; import jboost.booster.Booster; - import jboost.booster.BrownBoost; - import jboost.booster.MulticlassWrapMH; import jboost.booster.RobustBoost; import jboost.controller.Configuration; - import jboost.controller.Configuration; import jboost.examples.ExampleSet; --- 9,17 ---- import java.util.ArrayList; import java.util.Date; + import jboost.Predictor; import jboost.booster.Booster; import jboost.booster.RobustBoost; import jboost.controller.Configuration; import jboost.examples.ExampleSet; *************** *** 24,27 **** --- 23,27 ---- */ public class Monitor { + private static Date startTime; private static Date afterInitTime; *************** *** 40,46 **** private PrintWriter trainBoostingStream; private String trainBoostingFilename; private PrintWriter testBoostingStream; private String testBoostingFilename; ! /** a stream for logging resampling activity private PrintWriter samplingStream; --- 40,50 ---- private PrintWriter trainBoostingStream; private String trainBoostingFilename; + private ByteArrayOutputStream trainBoostingBuffer; private PrintWriter testBoostingStream; private String testBoostingFilename; ! private ByteArrayOutputStream testBoostingBuffer; ! ! ! /** a stream for logging resampling activity private PrintWriter samplingStream; *************** *** 111,115 **** infoStream.println(); infoStream.println("Configuration parameters:\n" + config); ! infoStream.println(""); infoStream.println("FILENAMES"); infoStream.println("specFilename = " + config.getSpecFileName()); --- 115,128 ---- infoStream.println(); infoStream.println("Configuration parameters:\n" + config); ! infoStream.println(); ! ! // RobustBoost: binary case ! if (m_booster instanceof RobustBoost) { ! RobustBoost rb = (RobustBoost)m_booster; ! infoStream.println("RobustBoost parameters:"); ! infoStream.println(rb.getParameters()); ! infoStream.println(); ! } ! infoStream.println("FILENAMES"); infoStream.println("specFilename = " + config.getSpecFileName()); *************** *** 134,137 **** --- 147,153 ---- new FileWriter(testBoostingFilename))); + trainBoostingBuffer = new ByteArrayOutputStream(); + testBoostingBuffer = new ByteArrayOutputStream(); + afterInitTime= new Date(); infoStream.println("Init Start time = " + startTime); *************** *** 142,152 **** infoStream.println("iter \tbound \ttrain \ttest \ttime"); } - // RobustBoost: multiclass case - else if (booster instanceof MulticlassWrapMH) { - Booster b = ((MulticlassWrapMH)booster).m_booster; - if (b instanceof RobustBoost) { - infoStream.println("iter \tbound \ttrain \ttest \ttime"); - } - } else { infoStream.println("iter \tbound \ttrain \ttest"); --- 158,161 ---- *************** *** 186,189 **** --- 195,199 ---- NumberFormat f= new DecimalFormat("0.0000"); + if (iter > 0) infoStream.print("\n"); // RobustBoost: binary case if (m_booster instanceof RobustBoost) { *************** *** 192,204 **** + f.format(trainError) + "\t" + f.format(testError) + "\t" + f.format(currentTime)); } - // RobustBoost: multiclass case - else if (m_booster instanceof MulticlassWrapMH) { - Booster b = ((MulticlassWrapMH)m_booster).m_booster; - if (b instanceof RobustBoost) { - double currentTime = ((RobustBoost)b).getCurrentTime(); - infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" - + f.format(trainError) + "\t" + f.format(testError) + "\t" + f.format(currentTime)); - } - } // otherwise else { --- 202,205 ---- *************** *** 208,212 **** infoStream.flush(); logBoosting(iter, combined, base); - infoStream.println(""); } --- 209,212 ---- *************** *** 274,278 **** // output the weights for (j= 0; j < tWeights[i].length; j++){ ! boostingStream.print(f.format(tWeights[i][j])); if (j != tmp.length -1) boostingStream.print(SEPARATOR); --- 274,279 ---- // output the weights for (j= 0; j < tWeights[i].length; j++){ ! // output it in log scale ! boostingStream.print(f.format(Math.log(tWeights[i][j]))); if (j != tmp.length -1) boostingStream.print(SEPARATOR); *************** *** 319,329 **** /** output the scores distribution of the training set */ private void logBoosting(int iter, Predictor combined, Predictor base) { ! if (boostingPrintRate == 0 && m_booster instanceof BrownBoost) { ! BrownBoost b = (BrownBoost) m_booster; ! if (!b.isFinished()) { ! return; ! } ! } ! if ((boostingPrintRate==0 && !(m_booster instanceof BrownBoost)) || (boostingPrintRate > 0 && boostingPrintRate != iter)) return; --- 320,324 ---- /** output the scores distribution of the training set */ private void logBoosting(int iter, Predictor combined, Predictor base) { ! if ((boostingPrintRate==0) || (boostingPrintRate > 0 && boostingPrintRate != iter)) return; *************** *** 331,337 **** if (boostingPrintRate == -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" --- 326,331 ---- if (boostingPrintRate == -1) { // print score when highest order digit in iter changes. ! double m=Math.floor(Math.log(iter) / Math.log(10.0)); ! int t = (int) Math.pow(10.0, m); if (iter == 0) t= 1; // fix bug in "pow" *************** *** 339,358 **** return; } logBoostingTrainTest(trainBoostingStream, trainSet, iter, combined, base); logBoostingTrainTest(testBoostingStream, testSet, iter, combined, base); trainBoostingStream.flush(); testBoostingStream.flush(); ! infoStream.print(" \t# output boosting data #"); } /** close the monitor output files */ public void close() throws IOException { endTime= new Date(); ! infoStream.println("End time=" + endTime); infoStream.close(); if (trainBoostingStream != null) trainBoostingStream.close(); if (testBoostingStream != null) testBoostingStream.close(); log("finished closing output files"); } --- 333,383 ---- return; } + + // save to buffer + if (boostingPrintRate == -3) { + trainBoostingBuffer.reset(); + testBoostingBuffer.reset(); + PrintWriter wTrain = new PrintWriter(trainBoostingBuffer); + PrintWriter wTest = new PrintWriter(testBoostingBuffer); + logBoostingTrainTest(wTrain, trainSet, iter, combined, base); + logBoostingTrainTest(wTest, testSet, iter, combined, base); + wTrain.close(); + wTest.close(); + return; + } + logBoostingTrainTest(trainBoostingStream, trainSet, iter, combined, base); logBoostingTrainTest(testBoostingStream, testSet, iter, combined, base); trainBoostingStream.flush(); testBoostingStream.flush(); ! infoStream.print(" \t# output boosting data #"); } /** close the monitor output files */ public void close() throws IOException { + + // print buffer to files + if (boostingPrintRate == -3) { + trainBoostingStream.print(trainBoostingBuffer.toString()); + testBoostingStream.print(testBoostingBuffer.toString()); + infoStream.print(" \t# output boosting data #"); + } + endTime= new Date(); ! infoStream.println("\nEnd time=" + endTime); ! ! // RobustBoost: binary case ! if (m_booster instanceof RobustBoost) { ! RobustBoost rb = (RobustBoost)m_booster; ! infoStream.println("\nrb_t = " + rb.getCurrentTime()); ! } ! infoStream.close(); + if (trainBoostingStream != null) trainBoostingStream.close(); if (testBoostingStream != null) testBoostingStream.close(); + log("finished closing output files"); } |
From: Sunsern C. <sch...@us...> - 2009-06-08 23:40:53
|
Update of /cvsroot/jboost/jboost/lib In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11232/lib Removed Files: Tag: jboost-2_0 concurrent.jar swing-layout-1.0.jar Log Message: jboost 2.0 --- swing-layout-1.0.jar DELETED --- --- concurrent.jar DELETED --- |
From: Sunsern C. <sch...@us...> - 2009-03-16 19:43:36
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15785/src/jboost/visualization Modified Files: HistogramFrame.java Log Message: * Remove GroupLayout * Print PDF now prints iteration numbers Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HistogramFrame.java 12 Mar 2009 23:42:04 -0000 1.7 --- HistogramFrame.java 16 Mar 2009 19:43:29 -0000 1.8 *************** *** 24,28 **** import javax.swing.BorderFactory; import javax.swing.BoxLayout; - import javax.swing.GroupLayout; import javax.swing.JComboBox; import javax.swing.JComponent; --- 24,27 ---- *************** *** 211,216 **** try { - GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane()); - getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { --- 210,213 ---- *************** *** 229,237 **** } ! thisLayout.setVerticalGroup(thisLayout.createSequentialGroup() ! .addComponent(jSplitPane2, 0, 412, Short.MAX_VALUE)); ! thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup() ! .addComponent(jSplitPane2, 0, 886, Short.MAX_VALUE)); ! pack(); this.setSize(1000, 400); --- 226,230 ---- } ! this.add(jSplitPane2); pack(); this.setSize(1000, 400); *************** *** 975,979 **** if (pdf != null) { ! JComponent toDraw = this.jSplitPane1; File[] tmpFiles = new File[maxNumIter]; --- 968,972 ---- if (pdf != null) { ! JComponent toDraw = this.jSplitPane2; File[] tmpFiles = new File[maxNumIter]; *************** *** 983,986 **** --- 976,981 ---- post("Printing " + iterNoList[i] + "..."); + jList1.setSelectedIndex(i); + jList1.scrollRectToVisible(jList1.getCellBounds(i, i)); loadIteration(i); *************** *** 1005,1008 **** --- 1000,1004 ---- // restore plots + jList1.setSelectedIndex(iter); loadIteration(iter); |
From: Sunsern C. <sch...@us...> - 2009-03-12 23:43:13
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16854/src/jboost/controller Modified Files: Configuration.java Controller.java Log Message: * Remove an early stopping criteria from RobustBoost * New HistogramFrame.java and DataSet.java that works with new VisualizeScores.py. Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Controller.java 19 Feb 2009 14:22:56 -0000 1.16 --- Controller.java 12 Mar 2009 23:42:04 -0000 1.17 *************** *** 451,457 **** "[Iter= " + iter + ", Time= " + f.format(((RobustBoost)m_booster).getCurrentTime()) + ! ", Active Examples= " + ((RobustBoost)m_booster).getNumActiveExamples() + ! ", ds= " + f.format(((RobustBoost)m_booster).getLastDs()) + ! ", dt= " + f.format(((RobustBoost)m_booster).getLastDt()) + "]"); } // multiclass case of RobustBoost --- 451,455 ---- "[Iter= " + iter + ", Time= " + f.format(((RobustBoost)m_booster).getCurrentTime()) + ! ", Active Examples= " + ((RobustBoost)m_booster).getNumActiveExamples() + "]"); } // multiclass case of RobustBoost *************** *** 463,469 **** "[Iter= " + iter + ", Time= " + f.format(((RobustBoost)b).getCurrentTime()) + ! ", Active Examples= " + ((RobustBoost)b).getNumActiveExamples() + ! ", ds= " + f.format(((RobustBoost)b).getLastDs()) + ! ", dt= " + f.format(((RobustBoost)b).getLastDt()) + "]"); } } --- 461,465 ---- "[Iter= " + iter + ", Time= " + f.format(((RobustBoost)b).getCurrentTime()) + ! ", Active Examples= " + ((RobustBoost)b).getNumActiveExamples() + "]"); } } Index: Configuration.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Configuration.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Configuration.java 5 Feb 2009 06:32:10 -0000 1.13 --- Configuration.java 12 Mar 2009 23:42:04 -0000 1.14 *************** *** 280,284 **** } catch (FileNotFoundException e) { String s="WARNING: configuration file " + filename + " not found. Continuing..."; ! System.err.println(s); return; } --- 280,284 ---- } catch (FileNotFoundException e) { String s="WARNING: configuration file " + filename + " not found. Continuing..."; ! System.out.println(s); return; } |
From: Sunsern C. <sch...@us...> - 2009-03-12 23:42:50
|
Update of /cvsroot/jboost/jboost/scripts In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17190/scripts Modified Files: VisualizeScores.README VisualizeScores.DEMO.README VisualizeScores.py Log Message: * New VisualizeScores.py Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** VisualizeScores.py 17 Jan 2009 02:00:31 -0000 1.8 --- VisualizeScores.py 12 Mar 2009 23:42:40 -0000 1.9 *************** *** 1,16 **** import sys, os, os.path, re, math, glob - import jarray - from java.util import Vector def usage(): ! print("Usage: VisualizeScores <info-files-path>") ! print("info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ...") ! print("Example: perform the following commands from the jboost root directory") ! print("<setup classpath to point to jython>") ! print("source scripts/setClassPath.sh") ! print("cd demo") ! print("cat spambase.test spambase.train > spambase.data") ! print("../scripts/nfold.py --folds=3 --data=spambase.data --spec=spambase.spec --rounds=43 --tree=ADD_ALL --generate --booster=LogLossBoost") ! print("jython ../scripts/VisualizeScores.py cvdata-09-09-17-00-55/ADD_ALL/trial*") print("") print("IMPORTANT NOTE: jboost should of been run on data and spec files passed through AddRandomIndex.py") --- 1,10 ---- + #!/usr/bin/python + import sys, os, os.path, re, math, glob def usage(): ! print("Usage: VisualizeScores.py <info-files-path>") ! print(" <info-file-path> is a directory containing files with names") ! print(" like trial0.test.boosting.info, trial2.train.boosting.info ...") print("") print("IMPORTANT NOTE: jboost should of been run on data and spec files passed through AddRandomIndex.py") *************** *** 26,163 **** sys.exit(2) - header_p = re.compile('iteration=(\d+): elements=(\d+):') - scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') - - testfiles = glob.glob(globpath + "*.test.boosting.info") trainfiles = glob.glob(globpath + "*.train.boosting.info") - - #testfiles = glob.glob("/Users/yoavfreund/Downloads/dc_boost_active_output/iter?/*.test.boosting.info") - - #testfiles = glob.glob("/Users/yoavfreund/projects/jboost/demo/cvdata-09-09-17-00-55/ADD_ALL/trial*.test.boosting.info") - - print(testfiles) - exampleData = {} - - #find the iteration indices - - infile = open(testfiles[0], 'r') - iterList = [] - iterDict = {} - iterationIndex = 0 - for line in infile: - [(iter, elements)] = header_p.findall(line) - elements = int(elements) - - if iterDict.has_key(iter): - sys.exit("data file " + testfiles[0] + " has two lists corresponding to iteration " + iter) - iterList.append(iter) - iterDict[iter] = iterationIndex - iterationIndex = iterationIndex + 1 - - for count in range(elements): - line = infile.readline() - - from jboost.visualization import DataSet, DataElement, HistogramFrame - - d = DataSet(iterList) - d.setOutputFilename(globpath + "/selectedExamples.txt") - - # read the data into the Dataset data structures. - for filename in testfiles: - print(filename) - infile = open(filename, 'r') - iterList = []; - for line in infile: - [(iter, elements)] = header_p.findall(line) - iterationIndex = iterDict[iter] - elements = int(elements) - - for count in range(elements): - line = infile.readline() - #print line - a = scoreline_p.findall(line) - index = int(a[1]) - score = float(a[3]) - label = int(a[ - 1]) - if not exampleData.has_key(index): - exampleData[index] = {"label":label, "scores":{} } - exampleData[index]["scores"][int(iter)] = {"test":score, "train":[]} - e = DataElement(score, index, label) - d.addDataElement(e, iterationIndex) - - d.preProcessDataset() - lowestScore = d.getMin() - highestScore = d.getMax() - print("lowestScore=%f, highestScore=%f\n" % (lowestScore, highestScore)) - - print(len(exampleData)) - - for filename in trainfiles: - print(filename) - infile = open(filename, 'r') - for line in infile: - [(iter, elements)] = header_p.findall(line) - iterationIndex = iterDict[iter] - elements = int(elements) - - for count in range(elements): - line = infile.readline() - #print line - a = scoreline_p.findall(line) - index = int(a[1]) - score = float(a[3]) - label = int(a[ - 1]) - if exampleData.has_key(index): - exampleData[index]["scores"][int(iter)]["train"].append(score) - #else: - #print "missing index=%d\n" % index - - - # changed first index below from 0 to exampleData.keys()[0] : by boyko - iterList = exampleData[exampleData.keys()[0]]["scores"].keys() - iterList.sort() - - fluctBins = 20 - percentage = 0.05 - barHeight = 6 - binWidth = (highestScore - lowestScore) / fluctBins - fluct = {} - for iter in iterList: - fluct[iter] = [ {"trainScores":[]} for i in range(fluctBins)] - - for iterNo in range(len(iterList)): - iter = iterList[iterNo] - print("iteration %d\n" % iter) - for index in exampleData.keys(): - testScore = exampleData[index]["scores"][iter]["test"] - bin = int((testScore - lowestScore) / binWidth) - bin = min(bin, fluctBins - 1) - for trainScore in exampleData[index]["scores"][iter]["train"]: - fluct[iter][bin]["trainScores"].append(trainScore) - - y = 0 - for bin in range(fluctBins): - fluct[iter][bin]["trainScores"].sort() - n = len(fluct[iter][bin]["trainScores"]) - if n > 10: - bottom = fluct[iter][bin]["trainScores"][int(n * percentage)] - top = fluct[iter][bin]["trainScores"][int(n * (1 - percentage))] - yMax = y - yMin = y - barHeight - y = y - 1.1 * barHeight - fluct[iter][bin]["bottom"] = bottom - fluct[iter][bin]["top"] = top - fluct[iter][bin]["yMin"] = yMin - fluct[iter][bin]["yMax"] = yMax - - print("[%f,%f] -> [%f,%f] X [%f,%f]\n" % (lowestScore + bin * binWidth, lowestScore + (bin + 1) * binWidth, bottom, top, yMin, yMax)) - d.addFluctItems(iterNo, lowestScore + bin * binWidth, lowestScore + (bin + 1) * binWidth, bottom, top, yMin, yMax) - fluct[iter][bin]["trainScores"] = [] - - - v = HistogramFrame(d) - v.show() if __name__ == "__main__": main() --- 20,40 ---- sys.exit(2) testfiles = glob.glob(globpath + "*.test.boosting.info") trainfiles = glob.glob(globpath + "*.train.boosting.info") + #print testfiles + #print trainfiles + + cmd = "java jboost.visualization.HistogramFrame " + str(len(testfiles)) + " " + for f in testfiles: + cmd = cmd + f + " " + cmd = cmd + str(len(trainfiles)) + " " + for f in trainfiles: + cmd = cmd + f + " " + + os.system(cmd) + + + if __name__ == "__main__": main() Index: VisualizeScores.DEMO.README =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.DEMO.README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VisualizeScores.DEMO.README 25 Jan 2009 08:52:38 -0000 1.2 --- VisualizeScores.DEMO.README 12 Mar 2009 23:42:40 -0000 1.3 *************** *** 3,7 **** Assumptions ========== ! 0. you have java, jython, and python installed. 1. you have downloaded the jboost dist from sourceforge.net and built jboost from source or you downloaded the pre-release. (ie. you have jboost 1.4.1 or greater) --- 3,7 ---- Assumptions ========== ! 0. you have java and python installed. 1. you have downloaded the jboost dist from sourceforge.net and built jboost from source or you downloaded the pre-release. (ie. you have jboost 1.4.1 or greater) *************** *** 15,19 **** 1. add some libs to your (existing) java CLASSPATH: ! > export CLASSPATH=$CLASSPATH:$JBOOST_DIR/lib/jcommon-1.0.8.jar:$JBOOST_DIR/lib/jfreechart-1.0.10.jar:$JBOOST_DIR/lib/swing-layout-1.0.jar 2. cd to the demo directory --- 15,19 ---- 1. add some libs to your (existing) java CLASSPATH: ! > export CLASSPATH=$CLASSPATH:$JBOOST_DIR/lib/jcommon-1.0.8.jar:$JBOOST_DIR/lib/jfreechart-1.0.10.jar 2. cd to the demo directory *************** *** 66,72 **** 5. the results are placed in the directory ./spambase_idx.data.folds_2/cvdata-mm-dd-hh-mm-ss/<TREE-TYPE> ! 6. Now run the visualizer in the scripts. Assuming jython is not on your path, be explicit: ! > ~/jython2.2.1/jython ../scripts/VisualizeScores.py spambase_idx.data.folds_2/cvdata-mm-dd-hh-mm-ss/ADD_ALL/trial (note, this example output shows the cvdata-mm-dd-hh-mm-ss for my test run) --- 66,72 ---- 5. the results are placed in the directory ./spambase_idx.data.folds_2/cvdata-mm-dd-hh-mm-ss/<TREE-TYPE> ! 6. Now run the visualizer in the scripts. ! > ../scripts/VisualizeScores.py spambase_idx.data.folds_2/cvdata-mm-dd-hh-mm-ss/ADD_ALL/trial (note, this example output shows the cvdata-mm-dd-hh-mm-ss for my test run) Index: VisualizeScores.README =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VisualizeScores.README 25 Jan 2009 08:52:38 -0000 1.2 --- VisualizeScores.README 12 Mar 2009 23:42:40 -0000 1.3 *************** *** 5,9 **** Requirements ============ ! * Jython * build of jboost 1.4.1 (NOT JBOOST VERSION 1.4 found on sourceforge) * test | train.boosting.info files which are indexed (see AddRandomIndex.py) --- 5,9 ---- Requirements ============ ! * Python * build of jboost 1.4.1 (NOT JBOOST VERSION 1.4 found on sourceforge) * test | train.boosting.info files which are indexed (see AddRandomIndex.py) *************** *** 15,23 **** Usage ===== ! You must add the files from $JBOOST_DIR/lib that are not on your CLASSPATH to your CLASSPATH. If you followed the install instructions from the JBoost website, this would mean adding $JBOOST_DIR/lib/jcommon-1.0.8.jar, $JBOOST_DIR/lib/jfreechart-1.0.10.jar, and $JBOOST_DIR/lib/swing-layout-1.0.jar to the existing classpath (see example below). ! Once classpath is set, from command line invoke the script from Jython: ! [user@host jython2.2.1]$ ./jython $JBOOST_DIR/scripts/VisualizeScores.py <path to *.boosting.info files> Where <path to *.boosting.info files> is the full path to the .boosting.info files stem you would like to process. For example: /Users/jsmith/boostingdata/cvdata/ADD_ALL/trial will glob trial0.train.boosting.info, trial0.test.boosting.info, trial1.train.boosting.info, etc. --- 15,23 ---- Usage ===== ! You must add the files from $JBOOST_DIR/lib that are not on your CLASSPATH to your CLASSPATH. If you followed the install instructions from the JBoost website, this would mean adding $JBOOST_DIR/lib/jcommon-1.0.8.jar, $JBOOST_DIR/lib/jfreechart-1.0.10.jar to the existing classpath (see example below). ! Once classpath is set, from command line invoke the script: ! $JBOOST_DIR/scripts/VisualizeScores.py <path to *.boosting.info files> Where <path to *.boosting.info files> is the full path to the .boosting.info files stem you would like to process. For example: /Users/jsmith/boostingdata/cvdata/ADD_ALL/trial will glob trial0.train.boosting.info, trial0.test.boosting.info, trial1.train.boosting.info, etc. *************** *** 25,37 **** Example ======= - (this example is run from within Jython dist and assumes ): ! [user@host jython2.2.1]$ export JBOOST_DIR=/Users/jsmith/workspace/jboost/ (export for a bash shell. ignore if already done) ! [user@host jython2.2.1]$ export CLASSPATH=$CLASSPATH:$JBOOST_DIR/lib/jcommon-1.0.8.jar:$JBOOST_DIR/lib/jfreechart-1.0.10.jar:$JBOOST_DIR/lib/swing-layout-1.0.jar ! (NOTE: ASSUMES you have already added jboost.jar and concurrent.jar to your classpath) ! [user@host jython2.2.1]$ ./jython $JBOOST_DIR/scripts/VisualizeScores.py /Users/jsmith/boostingdata/<path to specific cvdata>/ADD_ALL/trial After loading, parsing, and analyzing the boosting.info files, the GUI will launch. Boosting iteration shown in upper right. A histogram showing example count by boosting score for each label is predominate and in the center of the window. Sliders below the histogram allow you select lower and upper score ranges. The region within this range on the ROC curve is shown in the upper left of the window. Pressing the button in the lower left (save selected examples) will write to a file the example index and boosting score for each example within the selected range. This file is saved to the directory indicated in step 1 above. --- 25,36 ---- Example ======= ! [user@host ~]$ export JBOOST_DIR=/Users/jsmith/workspace/jboost/ (export for a bash shell. ignore if already done) ! [user@host ~]$ export CLASSPATH=$CLASSPATH:$JBOOST_DIR/lib/jcommon-1.0.8.jar:$JBOOST_DIR/lib/jfreechart-1.0.10.jar ! (NOTE: ASSUME you have already added jboost.jar and concurrent.jar to your classpath) ! [user@host ~]$ $JBOOST_DIR/scripts/VisualizeScores.py /Users/jsmith/boostingdata/<path to specific cvdata>/ADD_ALL/trial After loading, parsing, and analyzing the boosting.info files, the GUI will launch. Boosting iteration shown in upper right. A histogram showing example count by boosting score for each label is predominate and in the center of the window. Sliders below the histogram allow you select lower and upper score ranges. The region within this range on the ROC curve is shown in the upper left of the window. Pressing the button in the lower left (save selected examples) will write to a file the example index and boosting score for each example within the selected range. This file is saved to the directory indicated in step 1 above. |
From: Sunsern C. <sch...@us...> - 2009-03-12 23:42:13
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16854/src/jboost/visualization Modified Files: DataSet.java HistogramFrame.java Log Message: * Remove an early stopping criteria from RobustBoost * New HistogramFrame.java and DataSet.java that works with new VisualizeScores.py. Index: DataSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/DataSet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DataSet.java 15 Sep 2008 22:24:44 -0000 1.6 --- DataSet.java 12 Mar 2009 23:42:04 -0000 1.7 *************** *** 110,116 **** */ public void addScoresList(ArrayList<DataElement> scores,int index) { ! Collections.sort(scores); Object[] a = (Object[]) scores.toArray(); ! System.out.printf("index=%d, a.length=%d%n",index,a.length); int neg_count=0; --- 110,118 ---- */ public void addScoresList(ArrayList<DataElement> scores,int index) { ! ! Collections.sort(scores); Object[] a = (Object[]) scores.toArray(); ! ! //System.out.printf("index=%d, a.length=%d%n",index,a.length); int neg_count=0; *************** *** 126,131 **** --- 128,135 ---- else if(e.label == pos_label) pos_count++; } + total_neg=neg_count; total_pos=pos_count; + //System.out.printf("total_neg=%d, total_pos=%d%n",total_neg,total_pos); *************** *** 139,146 **** for(int i=a.length-1; i >= 0; i--) { DataElement e = ((DataElement) a[i]); if(e.label == neg_label) neg_count++; else if(e.label == pos_label) pos_count++; e.truePositives=pos_count; ! e.falsePositives=neg_count; //System.out.println(e); } --- 143,153 ---- for(int i=a.length-1; i >= 0; i--) { DataElement e = ((DataElement) a[i]); + if(e.label == neg_label) neg_count++; else if(e.label == pos_label) pos_count++; + e.truePositives=pos_count; ! e.falsePositives=neg_count; ! //System.out.println(e); } *************** *** 165,177 **** for(int i=0; i<bins; i++) { DataElement e = iterData.get(binarySearch(iterData, s)); //System.out.printf("label=%d, i= %d, s=%f, prev=%f, e=",label,i,s,prev); //System.out.println(e); if(label==pos_label) { ! h[i]=prev-e.truePositives; ! prev=e.truePositives; } else { ! h[i]=prev-e.falsePositives; ! prev=e.falsePositives; } s=s+step; //System.out.println(prev); --- 172,191 ---- for(int i=0; i<bins; i++) { DataElement e = iterData.get(binarySearch(iterData, s)); + //System.out.printf("label=%d, i= %d, s=%f, prev=%f, e=",label,i,s,prev); //System.out.println(e); + + // exclude its own label + double tp = (e.label == pos_label)? e.truePositives-1: e.truePositives; + double fp = (e.label == neg_label)? e.falsePositives-1: e.falsePositives; + if(label==pos_label) { ! h[i]=prev-tp; ! prev=tp; } else { ! h[i]=prev-fp; ! prev=fp; } + s=s+step; //System.out.println(prev); *************** *** 196,200 **** int i=binarySearch(iterData, lowerScore); DataElement e = iterData.get(i); ! if(e.value<lowerScore && i<iterData.size()) { i++; e = iterData.get(i); --- 210,214 ---- int i=binarySearch(iterData, lowerScore); DataElement e = iterData.get(i); ! if(e.value<lowerScore && i+1<iterData.size()) { i++; e = iterData.get(i); *************** *** 219,230 **** if(s<list.get(0).value) return 0; if(s>list.get(l-1).value) return list.size()-1; - double l2=Math.floor(Math.log((double) l)/Math.log(2.0)); int index= 0; int step= (int) Math.pow(2, l2); DataElement e=list.get(index); ! while(e.value != s && step>0) { if(index+step<l) { ! if(list.get(index+step).value<=s) {index=index+step;} } e=list.get(index); --- 233,243 ---- if(s<list.get(0).value) return 0; if(s>list.get(l-1).value) return list.size()-1; double l2=Math.floor(Math.log((double) l)/Math.log(2.0)); int index= 0; int step= (int) Math.pow(2, l2); DataElement e=list.get(index); ! while(Math.abs(e.value-s) > 1e-7 && step>0) { if(index+step<l) { ! if(list.get(index+step).value <= s) {index=index+step;} } e=list.get(index); *************** *** 248,252 **** public double[] getFPTP(double v) { - ArrayList<DataElement> iterData = data.get(iteration); DataElement e = iterData.get(binarySearch(iterData,v)); --- 261,264 ---- *************** *** 255,258 **** --- 267,284 ---- } + public double getScoreAtTPThreshold(double threshold) { + Object[] a = (Object[]) data.get(iteration).toArray(); + + for(int i=a.length-1; i >= 0; i--) { + DataElement e = ((DataElement) a[i]); + if (e.truePositives / total_pos > threshold) { + return e.value; + } + } + + return Double.NEGATIVE_INFINITY; + } + + /** * @return the iteration Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HistogramFrame.java 15 Sep 2008 22:24:44 -0000 1.6 --- HistogramFrame.java 12 Mar 2009 23:42:04 -0000 1.7 *************** *** 1,19 **** package jboost.visualization; import java.awt.Color; ! import java.awt.GradientPaint; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ! import java.awt.event.ComponentAdapter; ! import javax.swing.BorderFactory; import javax.swing.BoxLayout; ! import javax.swing.DefaultComboBoxModel; [...1576 lines suppressed...] + for (int i=0;i<prediction.length-1;i++) { + ret = ret + (prediction[i]+label_offset) + ","; + } + ret = ret + (prediction[prediction.length-1]+label_offset) + "]"; + return ret; + } + } + + public boolean contains(int k) { + for (int i=0;i<prediction.length;i++) { + if (prediction[i] == k) return true; + } + return false; + } + } + + + + } |
From: Sunsern C. <sch...@us...> - 2009-03-12 23:42:13
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16854/src/jboost/booster Modified Files: RobustBoost.java Log Message: * Remove an early stopping criteria from RobustBoost * New HistogramFrame.java and DataSet.java that works with new VisualizeScores.py. Index: RobustBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/RobustBoost.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RobustBoost.java 19 Feb 2009 14:22:20 -0000 1.5 --- RobustBoost.java 12 Mar 2009 23:42:04 -0000 1.6 *************** *** 33,58 **** protected int m_numExamples; ! /** RobustBoost: current time in [0,1] */ protected double m_t; ! /** RobustBoost: epsilon, fraction of allowed errors */ protected double m_epsilon; ! /** RobustBoost: conf.rated flag */ protected boolean m_conf_rated; ! /** RobustBoost: sigma_f for each class */ protected double[] m_sigma_f; ! /** RobustBoost: theta (goal margin) for each class */ protected double[] m_theta; ! /** RobustBoost: rho for each class */ protected double[] m_rho; ! /** RobustBoost: mistake cost for each class */ protected double[] m_cost; ! /** RobustBoost: most recently used ds */ protected double m_last_ds; ! /** RobustBoost: most recently used dt */ protected double m_last_dt; protected double m_old_t; /** temporary location for storing the examples as they are read in */ protected List<TmpData> m_tmpList; --- 33,64 ---- protected int m_numExamples; ! /** current RobustBoost time [0,1] */ protected double m_t; ! /** epsilon, fraction of allowed errors */ protected double m_epsilon; ! /** conf.rated flag */ protected boolean m_conf_rated; ! /** sigma_f for each class */ protected double[] m_sigma_f; ! /** theta (goal margin) for each class */ protected double[] m_theta; ! /** rho for each class */ protected double[] m_rho; ! /** mistake cost for each class */ protected double[] m_cost; ! /** most recently used ds */ protected double m_last_ds; ! /** most recently used dt */ protected double m_last_dt; + /** RobustBoost time at last iteration */ protected double m_old_t; + /** minimum epsilon that works */ + protected static final double MIN_EPSILON = 1E-6; + /** maximum epsilon that works */ + protected static final double MAX_EPSILON = 0.999; + /** temporary location for storing the examples as they are read in */ protected List<TmpData> m_tmpList; *************** *** 79,84 **** m_tmpList= new ArrayList<TmpData>(); m_numExamples= 0; ! ! m_epsilon = epsilon; m_theta = theta; m_sigma_f = sigma_f; --- 85,92 ---- m_tmpList= new ArrayList<TmpData>(); m_numExamples= 0; ! ! m_epsilon = Math.max(epsilon, MIN_EPSILON); ! m_epsilon = Math.min(m_epsilon, MAX_EPSILON); ! m_theta = theta; m_sigma_f = sigma_f; *************** *** 104,108 **** public void init(Configuration config) { ! m_epsilon= config.getDouble("rb_epsilon", m_epsilon); double theta= config.getDouble("rb_theta", m_theta[0]); double sigma_f= config.getDouble("rb_sigma_f", m_sigma_f[0]); --- 112,118 ---- public void init(Configuration config) { ! m_epsilon= Math.max(config.getDouble("rb_epsilon", m_epsilon), MIN_EPSILON); ! m_epsilon= Math.min(m_epsilon, MAX_EPSILON); ! double theta= config.getDouble("rb_theta", m_theta[0]); double sigma_f= config.getDouble("rb_sigma_f", m_sigma_f[0]); *************** *** 300,311 **** } - public double getLastDs() { - return m_last_ds; - } - - public double getLastDt() { - return m_last_dt; - } - /** * Returns a string with all the weights, margins, etc --- 310,313 ---- *************** *** 397,401 **** public Prediction[] getPredictions(Bag[] bags, int[][] exampleIndex, Prediction[] basePredictions) { ! final double EPS = 1E-5; Prediction[] predictions = new RobustBinaryPrediction[bags.length]; --- 399,403 ---- public Prediction[] getPredictions(Bag[] bags, int[][] exampleIndex, Prediction[] basePredictions) { ! final double EPS = 1E-7; Prediction[] predictions = new RobustBinaryPrediction[bags.length]; *************** *** 407,412 **** double bp = basePredictions[i].getClassScores()[1]; ! // if bp (confidence of weak learner) is too small, don't make any prediction ! if (Math.abs(bp) < EPS) { predictions[i] = new RobustBinaryPrediction(0.0); } --- 409,414 ---- double bp = basePredictions[i].getClassScores()[1]; ! // if bp (confidence of weak learner) is too small or bag is weightless, don't make any prediction ! if (Math.abs(bp) < EPS || bags[i].isWeightless()) { predictions[i] = new RobustBinaryPrediction(0.0); } *************** *** 439,443 **** public void update(Prediction[] predictions, int[][] exampleIndex) { ! final double EPS = 1E-5; // save old m_weights --- 441,445 ---- public void update(Prediction[] predictions, int[][] exampleIndex) { ! final double EPS = 1E-7; // save old m_weights *************** *** 458,462 **** double[] value = rbp.getClassScores(); ! // check if this is a zero prediction if (Math.abs(value[1]) < EPS) { continue; --- 460,464 ---- double[] value = rbp.getClassScores(); ! // if this is a zero prediction, we skip if (Math.abs(value[1]) < EPS) { continue; *************** *** 467,489 **** for (int j= 0; j < exampleIndex[i].length; j++) mask[exampleIndex[i][j]] = true; - // create a set of starting points for NS - double init_ds, init_dt; - double[][] initial_points = new double[3][]; - - // #1. go as far in the future as possible - init_dt = 1 - m_t - 0.01; - init_ds = Math.sqrt(init_dt); - initial_points[0] = new double[] {init_ds, init_dt}; - - // #2. alpha in adaboost - init_ds = rbp.init_ds; - init_dt = init_ds*init_ds; - initial_points[1] = new double[] {init_ds, init_dt}; - - // #3. most recently used - init_ds = m_last_ds; - init_dt = m_last_dt; - initial_points[2] = new double[] {init_ds, init_dt}; - // how many iterations in NewtonSolver before we give up int max_iter = 30; --- 469,472 ---- *************** *** 491,525 **** boolean foundSolution = false; double ds = Double.NaN, dt = Double.NaN; ! for (int k=0;k<initial_points.length;k++) { ! NewtonSolver ns = new NewtonSolver(this, mask, value, initial_points[k], max_iter); ! ds = ns.getDs(); ! dt = ns.getDt(); ! if (ns.isSucceeded()) { ! foundSolution = true; ! break; ! } } ! // if failed, do more search with starting point on a grid ! if (!foundSolution) { ! done: ! for (double temp_ds=0;temp_ds < 10;temp_ds+=0.1) { ! for (double temp_dt=0;temp_dt < 1;temp_dt+=0.1) { ! double[] init_p = new double[] {temp_ds, temp_dt}; ! NewtonSolver ns = new NewtonSolver(this,mask,value,init_p,30); ! if (ns.isSucceeded()) { ! ds = ns.getDs(); ! dt = ns.getDt(); ! break done; } } ! } ! } // if there is a valid solution ! if (ds != Double.NaN && dt != Double.NaN && dt > 0) { --- 474,536 ---- boolean foundSolution = false; double ds = Double.NaN, dt = Double.NaN; + + // create a solver + NewtonSolver ns = new NewtonSolver(this, mask, value, max_iter); ! if (ns.canFinishNow()) { ! foundSolution = true; ! ds = 0; ! dt = Math.abs(1 - m_t); } + else { + // create a set of starting points for NS + double init_ds, init_dt; + double[][] initial_points = new double[3][]; ! // #1. go as far in the future as possible ! init_dt = 1 - m_t; ! init_ds = Math.sqrt(init_dt); ! initial_points[0] = new double[] {init_ds, init_dt}; ! // #2. alpha in adaboost ! init_ds = rbp.init_ds; ! init_dt = init_ds*init_ds; ! initial_points[1] = new double[] {init_ds, init_dt}; ! ! // #3. most recently used ! init_ds = m_last_ds; ! init_dt = m_last_dt; ! initial_points[2] = new double[] {init_ds, init_dt}; ! ! for (int k=0;k<initial_points.length;k++) { ! ns.solve(initial_points[k][0], initial_points[k][1]); ! if (ns.isSucceeded()) { ! ds = ns.getDs(); ! dt = ns.getDt(); ! foundSolution = true; ! break; ! } ! } ! ! // if failed, do more search with starting point on a grid ! if (!foundSolution) { ! done: ! for (double temp_ds=0;temp_ds < 10;temp_ds+=0.1) { ! for (double temp_dt=0.1;temp_dt < 1-m_t;temp_dt+=0.1) { ! ns.solve(temp_ds, temp_dt); ! if (ns.isSucceeded()) { ! ds = ns.getDs(); ! dt = ns.getDt(); ! foundSolution = true; ! break done; ! } } } ! } } // if there is a valid solution ! if (foundSolution && ! ds != Double.NaN && dt != Double.NaN && dt > 0) { *************** *** 550,553 **** --- 561,566 ---- else { + System.out.println("Warning: Newton's method has failed. This might or might not be a problem."); + m_last_ds = 0; m_last_dt = 0; *************** *** 557,563 **** } ! } // update m_weights and m_potentials m_totalWeight = 0; --- 570,578 ---- } ! ! //System.out.println("T = " + m_t); } + // update m_weights and m_potentials m_totalWeight = 0; *************** *** 577,581 **** */ public boolean isFinished() { ! return (1 - m_t < 0.001 || (m_t > 0 && (m_t - m_old_t) < 1E-7)); } --- 592,596 ---- */ public boolean isFinished() { ! return (1 - m_t < 0.001); } *************** *** 686,690 **** public int getNumActiveExamples() { ! double EPS = 1E-4; int num = 0; for (int i=0;i<m_numExamples;i++) { --- 701,705 ---- public int getNumActiveExamples() { ! double EPS = 1E-7; int num = 0; for (int i=0;i<m_numExamples;i++) { *************** *** 1025,1029 **** double RHS_EPS = 1E-5; - double TIME_EPS = 1E-5; double DET_EPS = 1E-7; --- 1040,1043 ---- *************** *** 1033,1037 **** protected double[] value; protected double t; - protected double[] initial_point; protected int max_iter; protected double ds,dt; --- 1047,1050 ---- *************** *** 1040,1044 **** protected boolean succeeded; ! public NewtonSolver(RobustBoost rb, boolean[] mask, double[] value, double[] init_point, int max_iter) { this.rb = rb; --- 1053,1057 ---- protected boolean succeeded; ! public NewtonSolver(RobustBoost rb, boolean[] mask, double[] value, int max_iter) { this.rb = rb; *************** *** 1047,1058 **** this.t = rb.m_t; - this.initial_point = init_point; this.max_iter = max_iter; succeeded = false; log = new StringBuffer(); - - solve(); - } --- 1060,1071 ---- this.t = rb.m_t; this.max_iter = max_iter; succeeded = false; + + this.ds = Double.NaN; + this.dt = Double.NaN; + log = new StringBuffer(); } *************** *** 1067,1071 **** * @return */ ! private double[] calculateJ() { double[] output = new double[] {0,0,0,0}; --- 1080,1084 ---- * @return */ ! public double[] calculateJ(double ds, double dt) { double[] output = new double[] {0,0,0,0}; *************** *** 1118,1122 **** * @return */ ! private double[] calculateF() { double[] output = new double[] {0,0}; --- 1131,1135 ---- * @return */ ! public double[] calculateF(double ds, double dt) { double[] output = new double[] {0,0}; *************** *** 1145,1153 **** return output; } ! private void solve() { ! ! ds = initial_point[0]; ! dt = initial_point[1]; double[] F; --- 1158,1168 ---- return output; } + + public void solve(double init_ds, double init_dt) { ! succeeded = false; ! ! ds = init_ds; ! dt = init_dt; double[] F; *************** *** 1160,1165 **** // calculate F and J ! F = calculateF(); ! J = calculateJ(); // solve for dds, ddt --- 1175,1180 ---- // calculate F and J ! F = calculateF(ds,dt); ! J = calculateJ(ds,dt); // solve for dds, ddt *************** *** 1255,1258 **** --- 1270,1279 ---- } + public boolean canFinishNow() { + double[] F = calculateF(0, 1 - t); + if (-F[1]/m_numExamples < Math.max(0.2*m_epsilon,0.00001) ) return true; + else return false; + } + } |
From: Sunsern C. <sch...@us...> - 2009-02-19 14:23:36
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32242/src/jboost/monitor Modified Files: Monitor.java Log Message: * print out time information for RobustBoost Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Monitor.java 11 Sep 2008 21:25:45 -0000 1.12 --- Monitor.java 19 Feb 2009 14:23:29 -0000 1.13 *************** *** 11,14 **** --- 11,16 ---- import jboost.booster.Booster; import jboost.booster.BrownBoost; + import jboost.booster.MulticlassWrapMH; + import jboost.booster.RobustBoost; import jboost.controller.Configuration; import jboost.controller.Configuration; *************** *** 135,139 **** infoStream.println("Init Start time = " + startTime); infoStream.println("Learn Start time = " + afterInitTime); ! infoStream.println("iter \tbound \ttrain \ttest"); infoStream.flush(); } catch (IOException e) { --- 137,156 ---- infoStream.println("Init Start time = " + startTime); infoStream.println("Learn Start time = " + afterInitTime); ! ! // RobustBoost: binary case ! if (booster instanceof RobustBoost) { ! infoStream.println("iter \tbound \ttrain \ttest \ttime"); ! } ! // RobustBoost: multiclass case ! else if (booster instanceof MulticlassWrapMH) { ! Booster b = ((MulticlassWrapMH)booster).m_booster; ! if (b instanceof RobustBoost) { ! infoStream.println("iter \tbound \ttrain \ttest \ttime"); ! } ! } ! else { ! infoStream.println("iter \tbound \ttrain \ttest"); ! } ! infoStream.flush(); } catch (IOException e) { *************** *** 168,173 **** 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)); infoStream.flush(); logBoosting(iter, combined, base); --- 185,209 ---- double theoryBound= m_booster.getTheoryBound(); NumberFormat f= new DecimalFormat("0.0000"); ! ! // RobustBoost: binary case ! if (m_booster instanceof RobustBoost) { ! double currentTime = ((RobustBoost)m_booster).getCurrentTime(); ! infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" ! + f.format(trainError) + "\t" + f.format(testError) + "\t" + f.format(currentTime)); ! } ! // RobustBoost: multiclass case ! else if (m_booster instanceof MulticlassWrapMH) { ! Booster b = ((MulticlassWrapMH)m_booster).m_booster; ! if (b instanceof RobustBoost) { ! double currentTime = ((RobustBoost)b).getCurrentTime(); ! infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" ! + f.format(trainError) + "\t" + f.format(testError) + "\t" + f.format(currentTime)); ! } ! } ! // otherwise ! else { ! infoStream.print(iter + "\t" + f.format(theoryBound) + "\t" ! + f.format(trainError) + "\t" + f.format(testError)); ! } infoStream.flush(); logBoosting(iter, combined, base); |
From: Sunsern C. <sch...@us...> - 2009-02-19 14:23:10
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32176/src/jboost/controller Modified Files: Controller.java Log Message: * multiclass support for RobustBoost Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Controller.java 9 Feb 2009 10:40:19 -0000 1.15 --- Controller.java 19 Feb 2009 14:22:56 -0000 1.16 *************** *** 23,26 **** --- 23,27 ---- import jboost.booster.Booster; import jboost.booster.Prediction; + import jboost.booster.MulticlassWrapMH; import jboost.booster.RobustBoost; import jboost.examples.BadLabelException; *************** *** 444,448 **** iterNo++; } ! if(m_booster instanceof RobustBoost){ NumberFormat f= new DecimalFormat("0.00000"); --- 445,449 ---- iterNo++; } ! // binary case of RobustBoost if(m_booster instanceof RobustBoost){ NumberFormat f= new DecimalFormat("0.00000"); *************** *** 454,457 **** --- 455,471 ---- ", dt= " + f.format(((RobustBoost)m_booster).getLastDt()) + "]"); } + // multiclass case of RobustBoost + else if (m_booster instanceof MulticlassWrapMH) { + Booster b = ((MulticlassWrapMH)m_booster).m_booster; + if (b instanceof RobustBoost) { + NumberFormat f= new DecimalFormat("0.00000"); + System.out.println("" + + "[Iter= " + iter + + ", Time= " + f.format(((RobustBoost)b).getCurrentTime()) + + ", Active Examples= " + ((RobustBoost)b).getNumActiveExamples() + + ", ds= " + f.format(((RobustBoost)b).getLastDs()) + + ", dt= " + f.format(((RobustBoost)b).getLastDt()) + "]"); + } + } else System.out.println("Finished learning iteration " + iter); |
From: Sunsern C. <sch...@us...> - 2009-02-19 14:22:25
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32124/src/jboost/booster Modified Files: RobustBoost.java Log Message: * Add another stopping condition. If time is updating too slow, we stop. Index: RobustBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/RobustBoost.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RobustBoost.java 11 Feb 2009 03:15:39 -0000 1.4 --- RobustBoost.java 19 Feb 2009 14:22:20 -0000 1.5 *************** *** 53,56 **** --- 53,58 ---- protected double m_last_dt; + protected double m_old_t; + /** temporary location for storing the examples as they are read in */ protected List<TmpData> m_tmpList; *************** *** 90,93 **** --- 92,96 ---- m_t = 0.0; + m_old_t = 0.0; m_last_ds = 0; *************** *** 442,445 **** --- 445,450 ---- m_oldWeights[i]= m_weights[i]; + m_old_t = m_t; + // for each prediction for (int i= 0; i < predictions.length; i++) { *************** *** 572,576 **** */ public boolean isFinished() { ! return (1 - m_t < 0.001); } --- 577,581 ---- */ public boolean isFinished() { ! return (1 - m_t < 0.001 || (m_t > 0 && (m_t - m_old_t) < 1E-7)); } |
From: Sunsern C. <sch...@us...> - 2009-02-19 14:21:39
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32043/src/jboost/booster Modified Files: MulticlassWrapMH.java Log Message: * Add support for RobustBoost Index: MulticlassWrapMH.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/MulticlassWrapMH.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MulticlassWrapMH.java 25 Mar 2008 01:00:28 -0000 1.6 --- MulticlassWrapMH.java 19 Feb 2009 14:21:27 -0000 1.7 *************** *** 22,29 **** */ ! class MulticlassWrapMH extends AbstractBooster { /** The underlying m_booster */ ! private AbstractBooster m_booster; /** The number of labels */ --- 22,29 ---- */ ! public class MulticlassWrapMH extends AbstractBooster { /** The underlying m_booster */ ! public AbstractBooster m_booster; /** The number of labels */ *************** *** 372,380 **** * underlying booster, one for each class. */ ! class MultiPrediction extends Prediction { /** * The predictions made. Has same length as the number of classes. */ ! private Prediction[] preds; /** --- 372,380 ---- * underlying booster, one for each class. */ ! public class MultiPrediction extends Prediction { /** * The predictions made. Has same length as the number of classes. */ ! public Prediction[] preds; /** |
From: Sunsern C. <sch...@us...> - 2009-02-19 14:20:36
|
Update of /cvsroot/jboost/jboost/src/jboost/atree In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31946/src/jboost/atree Modified Files: InstrumentedAlternatingTree.java Log Message: * improve how prediction nodes get normalized. * multiclass support for RobustBoost Index: InstrumentedAlternatingTree.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/InstrumentedAlternatingTree.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** InstrumentedAlternatingTree.java 9 Feb 2009 10:47:50 -0000 1.8 --- InstrumentedAlternatingTree.java 19 Feb 2009 14:20:25 -0000 1.9 *************** *** 14,21 **** --- 14,23 ---- import jboost.booster.Booster; import jboost.booster.BrownBoost; + import jboost.booster.MulticlassWrapMH; import jboost.booster.Prediction; import jboost.booster.NormalizedPrediction; import jboost.booster.RobustBinaryPrediction; import jboost.booster.RobustBoost; + import jboost.booster.MulticlassWrapMH.MultiPrediction; import jboost.controller.Configuration; import jboost.controller.ConfigurationException; *************** *** 389,419 **** // 1.a) Add the new prediction nodes to the alternating tree list pInt[i]= m_predictors.size(); - - // RobustBoost needs to scale all of the previous - // hyphothesis by exp(-dt) - if (predictions[i] instanceof RobustBinaryPrediction) { - // for every RobustBinaryPrediction added before this one - // we scale all of them by exp(-dt) - - double dt = ((RobustBinaryPrediction)predictions[i]).getDt(); - - if (dt > 0) { - double exp_negative_dt = Math.exp(-dt) ; - - // for each prediction before this one - for (int nodeidx=0;nodeidx < m_predictors.size();nodeidx++) { - PredictorNode cpn = (PredictorNode)m_predictors.get(nodeidx); - if (cpn.prediction instanceof RobustBinaryPrediction) { - - //System.out.println(">> scaling predictions"); - //System.out.println("Before: " + ((RobustBinaryPrediction)cpn.prediction).getClassScores()[1]); - ((RobustBinaryPrediction)cpn.prediction).scale(exp_negative_dt); - //System.out.println("After: " + ((RobustBinaryPrediction)cpn.prediction).getClassScores()[1]); - - } - } - } - } - addPredictorNodeToList(pNode[i]); // 1.b) Generate the exampleMasks for the split. --- 391,394 ---- *************** *** 464,467 **** --- 439,510 ---- lastBasePredictor= new AtreePredictor(splitter, parent, predictions, m_booster); node= findSplitter(parent, splitter); + + //--------- RobustBoost ----------// + + // binary case + if (m_booster instanceof RobustBoost) { + + for (int i=0; i < predictions.length; i++) { + + // RobustBoost needs to scale all of the previous + // hyphothesis by exp(-dt) + if (predictions[i] instanceof RobustBinaryPrediction) { + // for every RobustBinaryPrediction added before this one + // we scale all of them by exp(-dt) + double dt = ((RobustBinaryPrediction)predictions[i]).getDt(); + double exp_negative_dt = Math.exp(-dt) ; + + // for each prediction before this one + for (int nodeidx=0;nodeidx < m_predictors.size();nodeidx++) { + PredictorNode cpn = (PredictorNode)m_predictors.get(nodeidx); + cpn.prediction.scale(exp_negative_dt); + } + + } + else { + throw new RuntimeException("RobustBinaryPrediction is expected. This should never happen!"); + } + } + } + // multiclass case + else if (m_booster instanceof MulticlassWrapMH) { + Booster b = ((MulticlassWrapMH)m_booster).m_booster; + if (b instanceof RobustBoost) { + for (int i=0; i < predictions.length; i++) { + + if (predictions[i] instanceof MultiPrediction) { + + Prediction[] preds = ((MultiPrediction)predictions[i]).preds; + + for (int j=0;j<preds.length;j++) { + + if (preds[j] instanceof RobustBinaryPrediction) { + + // for every RobustBinaryPrediction added before this one + // we scale all of them by exp(-dt) + double dt = ((RobustBinaryPrediction)preds[j]).getDt(); + double exp_negative_dt = Math.exp(-dt) ; + + // for each prediction before this one + for (int nodeidx=0;nodeidx < m_predictors.size();nodeidx++) { + PredictorNode cpn = (PredictorNode)m_predictors.get(nodeidx); + cpn.prediction.scale(exp_negative_dt); + } + + } + else { + throw new RuntimeException("RobustBinaryPrediction is expected. This should never happen!"); + } + } + } + else { + throw new RuntimeException("RobustBinaryPrediction is expected. This should never happen!"); + } + } + } + } + + //--------------------------------// + if (node != null && (predictions.length > 0 && !(predictions[0] instanceof NormalizedPrediction)) ) { for (int i=0; i < node.predictorNodes.length; i++) { *************** *** 473,477 **** } } ! /* System.out.println("Adding Candidate: " + candidate); --- 516,521 ---- } } ! ! /* System.out.println("Adding Candidate: " + candidate); *************** *** 655,668 **** public boolean boosterIsFinished() { ! if(m_booster instanceof BrownBoost){ BrownBoost b = (BrownBoost) m_booster; return b.isFinished(); } ! if(m_booster instanceof RobustBoost){ RobustBoost b = (RobustBoost) m_booster; return b.isFinished(); } ! double EPS = 1e-50; double w = m_booster.getTotalWeight(); --- 699,719 ---- public boolean boosterIsFinished() { ! if (m_booster instanceof BrownBoost){ BrownBoost b = (BrownBoost) m_booster; return b.isFinished(); } ! if (m_booster instanceof RobustBoost){ RobustBoost b = (RobustBoost) m_booster; return b.isFinished(); } ! ! if (m_booster instanceof MulticlassWrapMH) { ! if (((MulticlassWrapMH)m_booster).m_booster instanceof RobustBoost) { ! RobustBoost b = (RobustBoost)(((MulticlassWrapMH)m_booster).m_booster); ! return b.isFinished(); ! } ! } ! double EPS = 1e-50; double w = m_booster.getTotalWeight(); |
From: Sunsern C. <sch...@us...> - 2009-02-11 03:15:53
|
Update of /cvsroot/jboost/jboost/src/jboost/booster In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31999/src/jboost/booster Modified Files: RobustBoost.java Log Message: -remove BinarySearch -fix class specific weighting Index: RobustBoost.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/booster/RobustBoost.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RobustBoost.java 9 Feb 2009 10:45:30 -0000 1.3 --- RobustBoost.java 11 Feb 2009 03:15:39 -0000 1.4 *************** *** 84,96 **** m_cost = cost; ! m_rho = new double[] {calculateRho(m_sigma_f[0],m_epsilon,m_theta[0]), ! calculateRho(m_sigma_f[1],m_epsilon,m_theta[1])}; m_t = 0.0; - - m_conf_rated = conf_rated; m_last_ds = 0; m_last_dt = 0; } --- 84,97 ---- m_cost = cost; ! m_conf_rated = conf_rated; ! ! m_rho = new double[] {calculateRho(m_sigma_f[0],m_epsilon,m_theta[0],m_cost[0]), ! calculateRho(m_sigma_f[1],m_epsilon,m_theta[1],m_cost[1])}; m_t = 0.0; m_last_ds = 0; m_last_dt = 0; + } *************** *** 110,114 **** m_theta[1]= config.getDouble("rb_theta_1", m_theta[1]); - m_sigma_f[0] = sigma_f; m_sigma_f[1] = sigma_f; --- 111,114 ---- *************** *** 120,128 **** m_cost[1]= config.getDouble("rb_cost_1", m_cost[1]); - m_rho = new double[] {calculateRho(m_sigma_f[0],m_epsilon,m_theta[0]), - calculateRho(m_sigma_f[1],m_epsilon,m_theta[1])}; - m_conf_rated = config.getBool("rb_conf_rated", m_conf_rated); } --- 120,128 ---- m_cost[1]= config.getDouble("rb_cost_1", m_cost[1]); m_conf_rated = config.getBool("rb_conf_rated", m_conf_rated); + m_rho = new double[] {calculateRho(m_sigma_f[0],m_epsilon,m_theta[0],m_cost[0]), + calculateRho(m_sigma_f[1],m_epsilon,m_theta[1],m_cost[1])}; + } *************** *** 497,515 **** } ! // check if NewtonSolver fails if (!foundSolution) { - - //System.out.println(">> NewtonSolver failed!"); - //System.out.println(">> Trying BinarySearch..."); ! // try binary search ! BinarySearch bs = new BinarySearch(this, mask, value); ! ! if (bs.isSucceeded()) { ! //System.out.println(">> BinarySearch found a solution!"); ! ds = bs.getDs(); ! dt = bs.getDt(); ! } ! } --- 497,516 ---- } ! // if failed, do more search with starting point on a grid if (!foundSolution) { ! done: ! for (double temp_ds=0;temp_ds < 10;temp_ds+=0.1) { ! for (double temp_dt=0;temp_dt < 1;temp_dt+=0.1) { ! double[] init_p = new double[] {temp_ds, temp_dt}; ! NewtonSolver ns = new NewtonSolver(this,mask,value,init_p,30); ! if (ns.isSucceeded()) { ! ds = ns.getDs(); ! dt = ns.getDt(); ! break done; ! } ! } ! } ! } *************** *** 540,548 **** } } // no solutions found else { - //throw new RuntimeException("Error: Cannot find (ds,dt). Please use another value of epsilon, sigma_f or theta!"); - m_last_ds = 0; m_last_dt = 0; --- 541,548 ---- } } + // no solutions found else { m_last_ds = 0; m_last_dt = 0; *************** *** 613,617 **** public static double calculatePotential(boolean conf_rated, double rho, double theta, double sigma_f, double cost, double m, double t) { ! if (conf_rated) { return cost * Math.min(1.0, 1.0 - erf((m - calculateMu(rho,theta,t))/calculateSigma(sigma_f,t))); --- 613,617 ---- public static double calculatePotential(boolean conf_rated, double rho, double theta, double sigma_f, double cost, double m, double t) { ! if (conf_rated) { return cost * Math.min(1.0, 1.0 - erf((m - calculateMu(rho,theta,t))/calculateSigma(sigma_f,t))); *************** *** 648,652 **** */ public static double calculateWeight(boolean conf_rated, double rho, double theta, double sigma_f, double cost, double m, double t) { ! double mu_t = calculateMu(rho, theta, t); double sigma_t_sq = calculateSigmaSquare(sigma_f,t); --- 648,652 ---- */ public static double calculateWeight(boolean conf_rated, double rho, double theta, double sigma_f, double cost, double m, double t) { ! double mu_t = calculateMu(rho, theta, t); double sigma_t_sq = calculateSigmaSquare(sigma_f,t); *************** *** 681,685 **** public int getNumActiveExamples() { ! double EPS = 1E-6; int num = 0; for (int i=0;i<m_numExamples;i++) { --- 681,685 ---- public int getNumActiveExamples() { ! double EPS = 1E-4; int num = 0; for (int i=0;i<m_numExamples;i++) { *************** *** 695,702 **** * @return rho */ ! private double calculateRho(double sigma_f, double epsilon, double theta) { if (!m_conf_rated) epsilon = epsilon * 2; double f1 = Math.sqrt(Math.exp(2.0)*((sigma_f * sigma_f) + 1.0) - 1.0); double f2 = erfinv(1.0 - epsilon); --- 695,704 ---- * @return rho */ ! private double calculateRho(double sigma_f, double epsilon, double theta, double cost) { if (!m_conf_rated) epsilon = epsilon * 2; + epsilon /= cost; + double f1 = Math.sqrt(Math.exp(2.0)*((sigma_f * sigma_f) + 1.0) - 1.0); double f2 = erfinv(1.0 - epsilon); *************** *** 704,707 **** --- 706,710 ---- double denom = 2.0 * (Math.E - 1.0); return numer / denom; + } *************** *** 1161,1166 **** // Found a solution if (Math.abs(F[0]) < RHS_EPS && Math.abs(F[1]) < RHS_EPS && dt > 0) { ! ! if (t + dt > 1) dt = 1 - t; log.append("Found a solution in " + i + " iterations!\n"); log.append("> ds = " + ds + "\n"); --- 1164,1168 ---- // Found a solution if (Math.abs(F[0]) < RHS_EPS && Math.abs(F[1]) < RHS_EPS && dt > 0) { ! //if (t + dt > 1) dt = 1 - t; log.append("Found a solution in " + i + " iterations!\n"); log.append("> ds = " + ds + "\n"); *************** *** 1185,1190 **** log.append("F[1] = " + F[1] + "\n"); ! if (Math.abs(F[1]) < RHS_EPS && dt > 0) { ! if (t + dt > 1) dt = 1 - t; log.append("Found a solution in " + i + " iterations!\n"); log.append("> ds = " + ds + "\n"); --- 1187,1193 ---- log.append("F[1] = " + F[1] + "\n"); ! // if this solution is ok ! if (Math.abs(F[0]) < RHS_EPS && Math.abs(F[1]) < RHS_EPS && dt > 0) { ! //if (t + dt > 1) dt = 1 - t; log.append("Found a solution in " + i + " iterations!\n"); log.append("> ds = " + ds + "\n"); *************** *** 1248,1406 **** } - - /** - * Binary search for solving ds,dt - * - * @author Sunsern Cheamanunkul - * - */ - public class BinarySearch { - - double SOL_EPS = 1E-4; - double EPS = 1E-6; - - protected StringBuffer log; - - protected boolean[] mask; - protected double[] value; - protected double t; - protected double ds,dt; - protected RobustBoost rb; - - protected boolean succeeded; - - public BinarySearch(RobustBoost rb, boolean[] mask, double[] value) { - - this.rb = rb; - this.t = rb.m_t; - this.value = value; - this.mask = mask; - - succeeded = false; - log = new StringBuffer(); - - //solve(); - - } - - - /** - * output is [a b] where - * a = f1(ds,dt) - * b = f2(ds,dt) - * - * @return - */ - private double[] calculateF(double ds, double dt) { - - double[] output = new double[] {0,0}; - double new_t, new_margin, new_weight; - double rho, theta, sigma_f, step, cost; - - new_t = t + dt; - - for (int i=0;i<rb.m_numExamples;i++) { - - rho = rb.m_rho[rb.m_labels[i]]; - theta = rb.m_theta[rb.m_labels[i]]; - sigma_f = rb.m_sigma_f[rb.m_labels[i]]; - cost = rb.m_cost[rb.m_labels[i]]; - step = (mask[i] ? value[rb.m_labels[i]] : 0); - - new_margin = rb.m_margins[i]*Math.exp(-dt) + step*ds; - new_weight = RobustBoost.calculateWeight(rb.m_conf_rated, rho, theta, sigma_f, cost, new_margin, new_t); - - output[0] += step*new_weight; - output[1] += RobustBoost.calculatePotential(rb.m_conf_rated, rho, theta, sigma_f, cost, rb.m_margins[i], t) - - RobustBoost.calculatePotential(rb.m_conf_rated, rho, theta, sigma_f, cost, new_margin, new_t); - - } - - return output; - } - - private void solve() { - - // start at small value - ds = EPS; - - double[] F,F1,F2; - double dt_l,dt_r; - - stop: - while (ds < 10) { - - // set boundary of dt - dt_l = EPS; - dt_r = 1-t; - - F = calculateF(ds,dt_l); - - if (Math.abs(F[1]) > 0.01) break; - - while (Math.abs(dt_l - dt_r) > 0.00001) { - - double dt_m = (dt_l+dt_r)/2; - double dt1 = (dt_l+dt_m)/2; - double dt2 = (dt_r+dt_m)/2; - - F = calculateF(ds,dt_m); - - if (Math.abs(F[1]) < SOL_EPS) { - //if (Math.abs(F[1]) < SOL_EPS && Math.abs(F[0]) < SOL_EPS) { - dt = dt_m; - if (t + dt > 1) dt = 1 - t; - log.append("Found a solution!\n"); - log.append("> ds = " + ds + "\n"); - log.append("> dt = " + dt + "\n"); - log.append("> F[0]=" + F[0] + "\n"); - log.append("> F[1]=" + F[1] + "\n"); - - succeeded = true; - break stop; - } - - F1 = calculateF(ds,dt1); - F2 = calculateF(ds,dt2); - - if (Math.abs(F1[0]) > Math.abs(F2[0])) { - dt_l = dt_m; - } - else { - dt_r = dt_m; - } - - } - - ds += 0.001; - } - - if (!succeeded) { - log.append("BinarySearch failed!\n"); - ds = Double.NaN; - dt = Double.NaN; - } - else { - log.append("BinarySearch completed successfully!\n"); - } - } - - public boolean isSucceeded() { - return succeeded; - } - - public double getDs() { - return ds; - } - - public double getDt() { - return dt; - } - - public String getLog() { - return log.toString(); - } - - } } --- 1251,1254 ---- |
From: william b. <wil...@us...> - 2009-02-09 23:10:22
|
Update of /cvsroot/jboost/jboost In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5303 Modified Files: build.xml Log Message: version number update and added readme support to build Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** build.xml 9 Sep 2008 20:43:24 -0000 1.10 --- build.xml 9 Feb 2009 22:32:09 -0000 1.11 *************** *** 15,19 **** <property name="dir.scripts" value="scripts"/> <property name="dir.javadoc" value="javadoc"/> ! <property name="jboost.version" value="1.4"/> <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.4.1"/> <property name="test.class.name" value="jboost.AllTests"/> *************** *** 165,168 **** --- 165,169 ---- <include name="*.py" /> <include name="*.pl" /> + <include name="*.README" /> </fileset> </copy> |
From: Sunsern C. <sch...@us...> - 2009-02-09 10:47:55
|
Update of /cvsroot/jboost/jboost/src/jboost/atree In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31420/src/jboost/atree Modified Files: InstrumentedAlternatingTree.java Log Message: added more RobustBoost support Index: InstrumentedAlternatingTree.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/atree/InstrumentedAlternatingTree.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** InstrumentedAlternatingTree.java 5 Feb 2009 05:56:57 -0000 1.7 --- InstrumentedAlternatingTree.java 9 Feb 2009 10:47:50 -0000 1.8 *************** *** 17,20 **** --- 17,21 ---- import jboost.booster.NormalizedPrediction; import jboost.booster.RobustBinaryPrediction; + import jboost.booster.RobustBoost; import jboost.controller.Configuration; import jboost.controller.ConfigurationException; *************** *** 457,461 **** Prediction[] predictions= m_booster.getPredictions(bags, partition); - // TODO: normalize precio m_booster.update(predictions, partition); if (parent==null) { --- 458,461 ---- *************** *** 660,663 **** --- 660,668 ---- } + if(m_booster instanceof RobustBoost){ + RobustBoost b = (RobustBoost) m_booster; + return b.isFinished(); + } + double EPS = 1e-50; double w = m_booster.getTotalWeight(); |