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: Yoav F. <yf...@us...> - 2008-09-11 21:25:50
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/src/jboost/visualization Modified Files: DataSet.java HistogramFrame.java Log Message: Visualizing fluctuations. Index: DataSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/DataSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataSet.java 9 Sep 2008 20:43:24 -0000 1.3 --- DataSet.java 11 Sep 2008 21:25:45 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- import org.jfree.data.xy.XYDataset; + import org.jfree.data.xy.XYIntervalSeries; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; *************** *** 28,31 **** --- 29,35 ---- */ private ArrayList<ArrayList<DataElement>> data; + private XYIntervalSeries[] fluctBinSeries; + private XYIntervalSeries[] fluctRangeSeries; + private double minScore,maxScore; private int total_pos,total_neg; *************** *** 35,40 **** --- 39,48 ---- this.iterList = iterList; data = new ArrayList<ArrayList<DataElement>>(); + fluctBinSeries = new XYIntervalSeries[iterList.length]; + fluctRangeSeries = new XYIntervalSeries[iterList.length]; for(int i=0; i<iterList.length; i++) { data.add(new ArrayList<DataElement>()); + fluctBinSeries[i] = new XYIntervalSeries("Bins"); + fluctRangeSeries[i] = new XYIntervalSeries("Ranges"); } } *************** *** 62,65 **** --- 70,86 ---- } + public void addFluctItems(int iterNo, double binMin, double binMax, double rangeMin, double rangeMax, double yMin,double yMax) { + fluctBinSeries[iterNo].add(binMin, binMin, binMax, yMin, yMin, (yMax+yMin)/2.0); + fluctRangeSeries[iterNo].add(rangeMin, rangeMin, rangeMax, yMin, yMin, yMax); + } + + public XYIntervalSeries getFluctBins() { + return fluctBinSeries[iteration]; + } + + public XYIntervalSeries getFluctRanges() { + return fluctRangeSeries[iteration]; + } + public void preProcessDataset() { int size = data.size(); Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HistogramFrame.java 9 Sep 2008 20:43:24 -0000 1.3 --- HistogramFrame.java 11 Sep 2008 21:25:45 -0000 1.4 *************** *** 84,88 **** private double[] negClassScores,posClassScores; ! private XYIntervalSeriesCollection[] histogramDataset; private int noOfBins=100; private JFreeChart histogramChart; --- 84,88 ---- private double[] negClassScores,posClassScores; ! private XYIntervalSeriesCollection histogramDataset; private int noOfBins=100; private JFreeChart histogramChart; *************** *** 194,200 **** jPanel1.setLayout(jPanel1Layout); { ! histogramDataset = new XYIntervalSeriesCollection[2]; ! histogramDataset[0] = new XYIntervalSeriesCollection(); ! histogramDataset[1] = new XYIntervalSeriesCollection(); updateHistogramDataset(); histogramChart = createHistogramChart(histogramDataset); --- 194,198 ---- jPanel1.setLayout(jPanel1Layout); { ! histogramDataset = new XYIntervalSeriesCollection(); updateHistogramDataset(); histogramChart = createHistogramChart(histogramDataset); *************** *** 290,300 **** private void updateHistogramDataset() { ! if(histogramDataset[0].getSeriesCount()>0) { ! histogramDataset[0].removeAllSeries(); ! histogramDataset[1].removeAllSeries(); } XYIntervalSeries posSeries = new XYIntervalSeries("positive"); XYIntervalSeries negSeries = new XYIntervalSeries("negative"); double[] posHist = rawData.computeHistogram(1, noOfBins); double[] negHist = rawData.computeHistogram(-1,noOfBins); --- 288,298 ---- private void updateHistogramDataset() { ! if(histogramDataset.getSeriesCount()>0) { ! histogramDataset.removeAllSeries(); } XYIntervalSeries posSeries = new XYIntervalSeries("positive"); XYIntervalSeries negSeries = new XYIntervalSeries("negative"); + double[] posHist = rawData.computeHistogram(1, noOfBins); double[] negHist = rawData.computeHistogram(-1,noOfBins); *************** *** 310,329 **** x=x+step; } ! histogramDataset[0].addSeries(posSeries); ! histogramDataset[1].addSeries(negSeries); } ! private static JFreeChart createHistogramChart(IntervalXYDataset[] dataset) { ! XYBarRenderer posRenderer = new XYBarRenderer(); ! posRenderer.setSeriesPaint(0,Color.blue); ! XYBarRenderer negRenderer = new XYBarRenderer(); ! negRenderer.setSeriesPaint(0,Color.red); ! XYPlot plot = new XYPlot(dataset[0], new NumberAxis("score"), new NumberAxis("count"), ! posRenderer); ! plot.setDataset(1, dataset[1]); ! plot.setRenderer(1, negRenderer); //plot.setBackgroundPaint(Color.lightGray); --- 308,332 ---- x=x+step; } ! ! ! histogramDataset.addSeries(posSeries); ! histogramDataset.addSeries(negSeries); ! histogramDataset.addSeries(rawData.getFluctBins()); ! histogramDataset.addSeries(rawData.getFluctRanges()); ! } ! private static JFreeChart createHistogramChart(IntervalXYDataset dataset) { ! XYBarRenderer renderer = new XYBarRenderer(); ! renderer.setSeriesPaint(0,Color.blue); ! renderer.setSeriesPaint(1,Color.red); ! renderer.setSeriesPaint(2,Color.green); ! renderer.setSeriesPaint(3, Color.orange); ! renderer.setUseYInterval(true); ! XYPlot plot = new XYPlot(dataset, new NumberAxis("score"), new NumberAxis("count"), ! renderer); //plot.setBackgroundPaint(Color.lightGray); |
From: Yoav F. <yf...@us...> - 2008-09-11 21:25:50
|
Update of /cvsroot/jboost/jboost/src/jboost/examples In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/src/jboost/examples Modified Files: ExampleSet.java Example.java Log Message: Visualizing fluctuations. Index: Example.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/Example.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Example.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- Example.java 11 Sep 2008 21:25:45 -0000 1.2 *************** *** 83,86 **** --- 83,90 ---- } + public ExampleDescription getDescription() { + return m_exampleDescription; + } + public String toString() { return "instance=" + m_instance.toString(m_exampleDescription) Index: ExampleSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExampleSet.java 18 Sep 2007 03:25:59 -0000 1.2 --- ExampleSet.java 11 Sep 2008 21:25:45 -0000 1.3 *************** *** 19,22 **** --- 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. /** *************** *** 58,62 **** --- 60,75 ---- } 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); + } } + /** add an example */ public void addExample(int index, Example example) { *************** *** 76,79 **** --- 89,97 ---- } + /** get the description of the fields in an example */ + public ExampleDescription getExampleDescription() { + return exampleDescription; + } + /** get no of examples */ public int getExampleNo() { *************** *** 270,273 **** --- 288,305 ---- return s; } + + /** check if there is an attribute whose name is "INDEX" **/ + public boolean hasIndex() { + return indexLocation>-1; + } + + /** generate the list of example Indexes **/ + public double[] getIndexes() { + double[] indexes = new double[exampleSet.length]; + for(int i=0; i<indexes.length; i++) { + indexes[i]=((RealAttribute) exampleSet[i].getAttribute(indexLocation)).getValue(); + } + return indexes; + } } |
From: Yoav F. <yf...@us...> - 2008-09-11 21:25:49
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/scripts Modified Files: VisualizeScores.py Log Message: Visualizing fluctuations. Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** VisualizeScores.py 11 Sep 2008 04:14:40 -0000 1.5 --- VisualizeScores.py 11 Sep 2008 21:25:45 -0000 1.6 *************** *** 82,87 **** highestScore = d.getMax() print "lowestScore=%f, highestScore=%f\n" % (lowestScore,highestScore) - v=HistogramFrame(d) - v.show() print len(exampleData) --- 82,85 ---- *************** *** 111,157 **** iterList.sort() ! fluctBins=10 fluct = {} for iter in iterList: ! fluct[iter] = [{"sum":0.0, "sumSquare":0.0, "count":0} for i in range(fluctBins)] ! for index in exampleData.keys(): ! for iter in iterList: testScore=exampleData[index]["scores"][iter]["test"] ! maxDiff=0 ! for trainScore in exampleData[index]["scores"][iter]["train"]: ! maxDiff = max(maxDiff,abs(trainScore-testScore)) ! exampleData[index]["scores"][iter]["maxDiff"]=maxDiff ! bin = int((testScore-lowestScore)/(highestScore-lowestScore)*fluctBins) bin = min(bin,fluctBins-1) ! fluct[iter][bin]["count"] += 1 ! fluct[iter][bin]["sum"] += maxDiff ! fluct[iter][bin]["sumSquare"] += maxDiff*maxDiff ! ! from math import sqrt ! step = (highestScore-lowestScore)/fluctBins ! for iter in iterList: ! print "iteration %d\n" % iter for bin in range(fluctBins): ! count = fluct[iter][bin]["count"] ! if count>0: ! mean = fluct[iter][bin]["sum"] / count ! meanSquare = fluct[iter][bin]["sumSquare"] / count ! std = sqrt(meanSquare-mean*mean) ! else: ! mean=0 ! std=0 ! fluct[iter][bin]["mean"]=mean ! fluct[iter][bin]["std"]=std ! fl=fluct[iter][bin] ! r=lowestScore + bin*step ! print "\t[%f,%f] count=%d, mean=%f, std=%f\n" % (r,r+step,count,mean,std) - #for index in range(5): - # print "%d: label=%d\n" % (index,exampleData[index]["label"]) - # for iterNo in iterList: - # print ("%d: " % iterNo) - # print exampleData[index]["scores"][iterNo] - --- 109,150 ---- 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() |
From: Yoav F. <yf...@us...> - 2008-09-11 21:25:49
|
Update of /cvsroot/jboost/jboost/src/jboost/monitor In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/src/jboost/monitor Modified Files: Monitor.java Log Message: Visualizing fluctuations. Index: Monitor.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/monitor/Monitor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Monitor.java 15 Aug 2008 21:38:13 -0000 1.11 --- Monitor.java 11 Sep 2008 21:25:45 -0000 1.12 *************** *** 17,21 **** /** * A class whose responsibility is to generate the log files that will later be ! * analyzed with perl scripts that were written for the C++ version of Atrees * * @author Yoav Freund --- 17,21 ---- /** * A class whose responsibility is to generate the log files that will later be ! * analyzed using scripts * * @author Yoav Freund *************** *** 30,39 **** private static final char SEPARATOR = ','; - /** a high-level log of the program's progress. */ private String infoFilename; private PrintWriter infoStream; - /** training and testing streams and variables */ private int boostingPrintRate; --- 30,37 ---- *************** *** 43,47 **** private String testBoostingFilename; - /** a stream for logging resampling activity private PrintWriter samplingStream; --- 41,44 ---- *************** *** 193,196 **** --- 190,197 ---- ArrayList tScores = tSet.calcScores(iter, combined, base); ArrayList tLabelIndices = tSet.getBinaryLabels(); + + double[] tIndex=null; + if(tSet.hasIndex()) tIndex=tSet.getIndexes(); + double[][] tWeights = null; double[][] tPotentials = null; *************** *** 208,212 **** --- 209,219 ---- boostingStream.print("" + i + FIELD_SEPARATOR); + // If available, output the example index + if(tIndex != null) { + boostingStream.printf("%.0f"+FIELD_SEPARATOR,tIndex[i]); + } + // output the margins + // I think this field is not very useful and should be eliminated (YoavFreund 9/9/08) tmp = ((double[]) tMargin.get(i)); for (j= 0; j < tmp.length; j++){ *************** *** 274,278 **** } - /** output the scores distribution of the training set */ private void logBoosting(int iter, Predictor combined, Predictor base) { --- 281,284 ---- *************** *** 290,295 **** // 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) --- 296,300 ---- // 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) *************** *** 305,311 **** } - - - /** close the monitor output files */ public void close() throws IOException { --- 310,313 ---- |
From: Yoav F. <yf...@us...> - 2008-09-11 21:25:48
|
Update of /cvsroot/jboost/jboost/.settings In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/.settings Added Files: org.eclipse.ltk.core.refactoring.prefs Log Message: Visualizing fluctuations. --- NEW FILE: org.eclipse.ltk.core.refactoring.prefs --- #Wed Sep 10 21:46:50 PDT 2008 eclipse.preferences.version=1 org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false |
From: Yoav F. <yf...@us...> - 2008-09-11 21:25:44
|
Update of /cvsroot/jboost/jboost/.settings In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2619/.settings Log Message: Directory /cvsroot/jboost/jboost/.settings added to the repository |
From: Yoav F. <yf...@us...> - 2008-09-11 19:58:06
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv30612/scripts Added Files: AddRandomIndex.py Log Message: A script for adding a random index to a data file. --- NEW FILE: AddRandomIndex.py --- """ add an INDEX field to a jboost data file. INDEX is a randomly permuted number ranging between 1 and the number of examples in the data file. The script also takes care of altering the spec file. This pre-processing step makes it possible to track examples through an n-fold cross validation experiment. """ filename = "/Users/yoavfreund/projects/jboost/demo/spambase" datafile = open(filename+".data",'r') lines=[] morelines = datafile.readlines(100000) while len(morelines)>0: lines.extend(morelines) morelines = datafile.readlines(100000) datafile.close() length = len(lines) from random import shuffle shuffle(lines) newdatafile = open(filename+"I.data",'w') for i in range(length): newdatafile.write(("%d," % i)+lines[i]) newdatafile.close() |
From: Yoav F. <yf...@us...> - 2008-09-11 04:14:45
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv24863/scripts Modified Files: VisualizeScores.py Log Message: First version of visualizeScores.py that computes fluctuations in scores between folds. Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** VisualizeScores.py 10 Sep 2008 00:19:25 -0000 1.4 --- VisualizeScores.py 11 Sep 2008 04:14:40 -0000 1.5 *************** *** 4,33 **** args = sys.argv[1:] ! if len(args) != 1: ! sys.exit(""" ! Usage: VisualizeScore <info-files-path> ! info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ... ! Example: perform the following commands from the jboost root directory ! <setup classpath to point to jython> ! source scripts/setClassPath.sh ! cd demo ! cat spambase.test spambase.train > spambase.data ! ../scripts/nfold.py --folds=3 --data=spambase.data --spec=spambase.spec --rounds=43 --tree=ADD_ALL --generate --booster=LogLossBoost ! jython ../scripts/VisualizeScores.py cvdata-09-09-17-00-55/ADD_ALL/ ! """) ! info_path = args[0] header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') testfiles = glob.glob(info_path+"trial*.test.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 ! indexes={} ! scores={} ! labels={} #find the iteration indices --- 4,35 ---- args = sys.argv[1:] ! #if len(args) != 1: ! # sys.exit(""" ! # Usage: VisualizeScore <info-files-path> ! # info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ... ! # Example: perform the following commands from the jboost root directory ! # <setup classpath to point to jython> ! # source scripts/setClassPath.sh ! # cd demo ! # cat spambase.test spambase.train > spambase.data ! # ../scripts/nfold.py --folds=3 --data=spambase.data --spec=spambase.spec --rounds=43 --tree=ADD_ALL --generate --booster=LogLossBoost ! # jython ../scripts/VisualizeScores.py cvdata-09-09-17-00-55/ADD_ALL/ ! # """) ! #info_path = args[0] header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') + info_path = "/Users/yoavfreund/projects/jboost/demo/cvdata-09-10-13-54-55/ADD_ALL/" + testfiles = glob.glob(info_path+"trial*.test.boosting.info") + trainfiles = glob.glob(info_path+"trial*.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 *************** *** 56,68 **** # read the data into the Dataset data structures. for filename in testfiles: - print filename infile = open(filename,'r') iterList=[]; for line in infile: - print line [(iter,elements)] = header_p.findall(line) iterationIndex=iterDict[iter] elements = int(elements) - print "iter=%s iterationIndex=%d elements=%d\n" % (iter,iterationIndex, elements) for count in range(elements): --- 58,67 ---- *************** *** 70,86 **** #print line a = scoreline_p.findall(line) ! index=int(a[0]) ! score=float(a[2]) label=int(a[-1]) e=DataElement(score,index,label) d.addDataElement(e,iterationIndex) - print "going to preprocess\n" d.preProcessDataset() ! print "finisehd preprocessing\n" ! print "min= %f, max=%f\n" % (d.getMin(),d.getMax()) ! v=HistogramFrame(d) - v.show() --- 69,157 ---- #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) ! v=HistogramFrame(d) ! v.show() ! 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 ! ! ! iterList = exampleData[0]["scores"].keys() ! iterList.sort() ! ! fluctBins=10 ! fluct = {} ! for iter in iterList: ! fluct[iter] = [{"sum":0.0, "sumSquare":0.0, "count":0} for i in range(fluctBins)] ! ! for index in exampleData.keys(): ! for iter in iterList: ! testScore=exampleData[index]["scores"][iter]["test"] ! maxDiff=0 ! for trainScore in exampleData[index]["scores"][iter]["train"]: ! maxDiff = max(maxDiff,abs(trainScore-testScore)) ! exampleData[index]["scores"][iter]["maxDiff"]=maxDiff ! bin = int((testScore-lowestScore)/(highestScore-lowestScore)*fluctBins) ! bin = min(bin,fluctBins-1) ! fluct[iter][bin]["count"] += 1 ! fluct[iter][bin]["sum"] += maxDiff ! fluct[iter][bin]["sumSquare"] += maxDiff*maxDiff ! ! from math import sqrt ! ! step = (highestScore-lowestScore)/fluctBins ! for iter in iterList: ! print "iteration %d\n" % iter ! for bin in range(fluctBins): ! count = fluct[iter][bin]["count"] ! if count>0: ! mean = fluct[iter][bin]["sum"] / count ! meanSquare = fluct[iter][bin]["sumSquare"] / count ! std = sqrt(meanSquare-mean*mean) ! else: ! mean=0 ! std=0 ! fluct[iter][bin]["mean"]=mean ! fluct[iter][bin]["std"]=std ! fl=fluct[iter][bin] ! r=lowestScore + bin*step ! print "\t[%f,%f] count=%d, mean=%f, std=%f\n" % (r,r+step,count,mean,std) ! ! #for index in range(5): ! # print "%d: label=%d\n" % (index,exampleData[index]["label"]) ! # for iterNo in iterList: ! # print ("%d: " % iterNo) ! # print exampleData[index]["scores"][iterNo] ! |
From: Yoav F. <yf...@us...> - 2008-09-10 00:19:29
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv14947/scripts Modified Files: VisualizeScores.py Log Message: VisualizeScore takes the path to the info files as a parameter Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VisualizeScores.py 9 Sep 2008 20:43:25 -0000 1.3 --- VisualizeScores.py 10 Sep 2008 00:19:25 -0000 1.4 *************** *** 3,24 **** from java.util import Vector ! info_path = '/Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/' ! ! #args = sys.argv[1:] ! #if len(args) != 1: ! # sys.exit(""" ! # Usage: VisualizeScore <info-files-path> ! # info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ... ! # Example: VisualizeScore /Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/' ! # """) ! #filename = args[0] header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') ! #testfiles = glob.glob(info_path+"trial*.test.boosting.info") ! testfiles = glob.glob("/Users/yoavfreund/Downloads/dc_boost_active_output/iter?/*.test.boosting.info") indexes={} scores={} --- 3,30 ---- from java.util import Vector ! args = sys.argv[1:] ! if len(args) != 1: ! sys.exit(""" ! Usage: VisualizeScore <info-files-path> ! info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ... ! Example: perform the following commands from the jboost root directory ! <setup classpath to point to jython> ! source scripts/setClassPath.sh ! cd demo ! cat spambase.test spambase.train > spambase.data ! ../scripts/nfold.py --folds=3 --data=spambase.data --spec=spambase.spec --rounds=43 --tree=ADD_ALL --generate --booster=LogLossBoost ! jython ../scripts/VisualizeScores.py cvdata-09-09-17-00-55/ADD_ALL/ ! """) ! info_path = args[0] header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') ! testfiles = glob.glob(info_path+"trial*.test.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 indexes={} scores={} |
From: Yoav F. <yf...@us...> - 2008-09-09 20:43:29
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21955/src/jboost/visualization Modified Files: DataSet.java HistogramFrame.java Added Files: DataElement.java Log Message: VisualizeScores.py is working. Index: DataSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/DataSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataSet.java 3 Sep 2008 18:09:54 -0000 1.2 --- DataSet.java 9 Sep 2008 20:43:24 -0000 1.3 *************** *** 1,6 **** package jboost.visualization; import java.util.Random; ! import java.util.TreeSet; import org.jfree.data.xy.XYDataset; --- 1,11 ---- package jboost.visualization; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.Collections; + import java.util.List; import java.util.Random; ! import java.util.ArrayList; ! import java.util.Vector; import org.jfree.data.xy.XYDataset; *************** *** 14,134 **** public class DataSet { ! private TreeSet<DataElement> data; ! public DataSet(int size) { ! data = new TreeSet<DataElement>(); ! Random generator = new Random(12345678L); ! for (int i = 0; i < 2*size; i++) { ! DataElement element = new DataElement(); ! int label = (i<size)?-1:1; ! element.value = generator.nextGaussian() + label/2.0+5; ! element.index = i; ! element.label = label; ! data.add(element); ! } } ! public DataSet(int[] indexes, double[] values, int[] labels) { ! data = new TreeSet<DataElement>(); ! for (int i = 0; i < indexes.length; i++) { ! DataElement element = new DataElement(); ! element.value = values[i]; ! element.index = indexes[i]; ! element.label = labels[i]; ! data.add(element); ! } } public double getMin() { ! return data.first().value; } public double getMax() { ! return data.last().value; ! } ! ! public double[] getFPTP(double v) { ! DataElement e = data.tailSet(new DataElement(v)).first(); ! double[] answer = {e.FPR,e.TPR}; ! return answer; } ! public double[] getSet(int label) { ! Object[] a = (Object[]) data.toArray(); ! int count=0; ! for (int i=0; i<a.length; i++) { ! DataElement e = ((DataElement) a[i]); ! if(e.label == label) { ! count++; } } ! if(count==0) {return new double[] {0.0};} ! double[] answer = new double[count]; ! count=0; ! for (int i=0; i<a.length; i++) { ! DataElement e = ((DataElement) a[i]); ! if(e.label == label) { ! answer[count] = e.value; ! count++; } } ! return answer; } ! public XYDataset generateRoC(int neg_label, int pos_label) { XYSeries roc = new XYSeries("ROC"); - Object[] a = (Object[]) data.toArray(); - - int neg_count=0; - int pos_count=0; - for(int i=0; i<a.length; i++) { - DataElement e = ((DataElement) a[i]); - if(e.label == neg_label) neg_count++; - else if(e.label == pos_label) pos_count++; - } - double total_neg=neg_count; - double total_pos=pos_count; - neg_count=0; - pos_count=0; 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.TPR=pos_count/total_pos; ! e.FPR=neg_count/total_neg; ! ! // System.out.printf("%f: %f,%f%n",e.value,e.FPR,e.TPR); ! roc.add(e.FPR, e.TPR); } ! XYSeriesCollection dataset = new XYSeriesCollection(); ! dataset.addSeries(roc); ! return dataset; } public static void main(String[] args) { ! DataSet test = new DataSet(50); test.generateRoC(-1,1); double[] a = test.getFPTP(5.0); ! System.out.printf("%f; %f%n",a[0],a[1]); ! System.out.println("yoav was here!"); ! } ! } ! class DataElement implements Comparable{ ! protected double value; ! protected int label; ! protected int index; ! protected double FPR,TPR; ! ! public DataElement(double v) { ! value=v; ! } ! public DataElement() {} ! ! public int compareTo(Object that) { ! return (int) Math.signum(this.value-((DataElement) that).value); ! } ! } --- 19,232 ---- public class DataSet { ! private String[] iterList; ! ! private int iteration=0; ! /** ! * data is a list of ArrayLists, each list element corresponds to a (boosting) iteration, ! * Each List entry consists of a sorted list of DataElements, sorted according to their score. ! */ ! private ArrayList<ArrayList<DataElement>> data; ! private double minScore,maxScore; ! private int total_pos,total_neg; ! private int neg_label=-1,pos_label=+1; ! ! public DataSet(String[] iterList) { ! this.iterList = iterList; ! data = new ArrayList<ArrayList<DataElement>>(); ! for(int i=0; i<iterList.length; i++) { ! data.add(new ArrayList<DataElement>()); ! } } ! public DataSet(int size,int iterations) { ! data = new ArrayList<ArrayList<DataElement>>(); ! iterList = new String[iterations]; ! Random generator = new Random(12345678L); ! ! for (int iter = 0; iter<iterations; iter++) { ! iterList[iter] = "iteration "+iter; ! data.add(new ArrayList<DataElement>()); ! for (int i = 0; i < 2*size; i++) { ! int label = (i<size)?-1:1; ! double value = Math.floor(generator.nextGaussian() + (iter*label)/4.0+5); ! this.addDataElement(new DataElement(value,i,label),iter); ! } ! } ! this.preProcessDataset(); } + + public void addDataElement(DataElement e,int iteration) { + ArrayList<DataElement> d=data.get(iteration); + d.add(e); + } + + public void preProcessDataset() { + int size = data.size(); + //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); + } + } + + /** + * addScoresList processes a list of scores, + * computes the true-positive-rate (TPR) and false-positive-rate (FPR) for each element in the list + * and adds the list to the data + * + * @param scores + * void + */ + 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; + int pos_count=0; + 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]); + if(e.label == neg_label) neg_count++; + 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); + + } else { + minScore = Math.min(minScore,scores.get(0).value); + maxScore = Math.max(maxScore,scores.get(scores.size()-1).value); + } + + neg_count=0; + pos_count=0; + 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); + } + } + public double getMin() { ! return minScore; } public double getMax() { ! return maxScore; } ! public double[] computeHistogram(int label,int bins) { ! ! 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; ! ArrayList<DataElement> iterData = data.get(iteration); ! for(int i=0; i<bins; i++) { ! DataElement e = 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); } ! return h; ! } ! ! private DataElement binarySearch(ArrayList<DataElement> list, double s) { ! int l=list.size(); ! if(s<list.get(0).value) return list.get(0); ! if(s>list.get(l-1).value) return list.get(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); + //System.out.printf("s=%f,e.value=%f,index=%d,step=%d%n",s,e.value,index,step); + step=step/2; } ! return e; } ! 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; ! } ! ! public double[] getFPTP(double v) { ! DataElement e = binarySearch(data.get(iteration),v); ! double[] answer = {e.falsePositives/total_neg,e.truePositives/total_pos}; ! return answer; } + /** + * @return the iteration + */ + public int getIteration() { + return iteration; + } + + /** + * @param iteration the iteration to set + */ + public void setIteration(int iteration) { + this.iteration = iteration; + } + + /** + * @return the iterList + */ + public String[] getIterList() { + return iterList; + } + public static void main(String[] args) { ! 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); ! System.out.printf("%d: %f; %f%n",test.getIteration(),a[0],a[1]); ! test.setIteration(2); ! test.generateRoC(-1,1); ! a = test.getFPTP(5.0); ! System.out.printf("%d: %f; %f%n",test.getIteration(),a[0],a[1]); ! ! double[] hist = test.computeHistogram(1, 30); ! for(int i=0; i<hist.length; i++) System.out.printf("%f, ",hist[i]); ! System.out.println(); ! hist = test.computeHistogram(-1, 30); ! for(int i=0; i<hist.length; i++) System.out.printf("%f, ",hist[i]); ! System.out.println(); ! } } --- NEW FILE: DataElement.java --- /** * */ package jboost.visualization; /** * @author yoavfreund * */ public class DataElement implements Comparable{ protected double value; protected int label; protected int index; protected double falsePositives,truePositives; public DataElement() {} public DataElement(double value) { this.value=value; } public DataElement(double value, int index, int label) { this.value = value; this.index = index; this.label = label; } public String toString() { String s = "[index="+Integer.toString(index) +",value="+Double.toString(value) +",label="+Integer.toString(label) +",TP="+Double.toString(truePositives) +",FP="+Double.toString(falsePositives) +"]"; return s; } public int compareTo(Object that) { return (int) Math.signum(this.value-((DataElement) that).value); } } Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistogramFrame.java 3 Sep 2008 18:09:54 -0000 1.2 --- HistogramFrame.java 9 Sep 2008 20:43:24 -0000 1.3 *************** *** 1,14 **** --- 1,23 ---- package jboost.visualization; import java.awt.Color; + import java.awt.GradientPaint; + import java.awt.event.ComponentAdapter; + import javax.swing.BorderFactory; import javax.swing.BoxLayout; + import javax.swing.DefaultComboBoxModel; import javax.swing.JComponent; + import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSplitPane; + import javax.swing.ListModel; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; + import javax.swing.border.BevelBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; + import javax.swing.event.ListSelectionEvent; + import javax.swing.event.ListSelectionListener; import org.jdesktop.layout.GroupLayout; *************** *** 17,31 **** --- 26,69 ---- import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; + import org.jfree.chart.axis.DateAxis; + import org.jfree.chart.axis.NumberAxis; + import org.jfree.chart.axis.SymbolAxis; + import org.jfree.chart.event.MarkerChangeListener; + import org.jfree.chart.event.PlotChangeEvent; + import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.plot.IntervalMarker; + import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; + import org.jfree.chart.renderer.category.BarRenderer; + import org.jfree.chart.renderer.xy.ClusteredXYBarRenderer; import org.jfree.chart.renderer.xy.XYBarRenderer; + import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; + import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.statistics.HistogramDataset; + import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; + import org.jfree.data.xy.XYIntervalSeries; + import org.jfree.data.xy.XYIntervalSeriesCollection; + import org.jfree.data.xy.XYSeries; + import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.Layer; + + /** + * This code was edited or generated using CloudGarden's Jigloo + * SWT/Swing GUI Builder, which is free for non-commercial + * use. If Jigloo is being used commercially (ie, by a corporation, + * company or business for any purpose whatever) then you + * should purchase a license for each developer using Jigloo. + * Please visit www.cloudgarden.com for details. + * Use of Jigloo implies acceptance of these licensing terms. + * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR + * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED + * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. + */ /** * @author yoavfreund *************** *** 42,50 **** private JPanel jPanel2; private JFreeChart histogramChart; private ChartPanel histogramPanel; private JFreeChart rocChart; private ChartPanel rocPanel; ! private static double upper_limit; private static double lower_limit; --- 80,99 ---- private JPanel jPanel2; + private int negLabel=-1; + private int posLabel=+1; + private double[] negClassScores,posClassScores; + + private XYIntervalSeriesCollection[] histogramDataset; + private int noOfBins=100; private JFreeChart histogramChart; private ChartPanel histogramPanel; + private XYSeriesCollection rocDataset; private JFreeChart rocChart; private ChartPanel rocPanel; ! ! private JList jList1; ! private JSplitPane jSplitPane2; ! private String[] iterNoList; ! private static double upper_limit; private static double lower_limit; *************** *** 61,65 **** */ public static void main(String[] args) { ! final DataSet dataset = new DataSet(SampleSize); SwingUtilities.invokeLater(new Runnable() { public void run() { --- 110,114 ---- */ public static void main(String[] args) { ! final DataSet dataset = new DataSet(SampleSize,10); SwingUtilities.invokeLater(new Runnable() { public void run() { *************** *** 71,77 **** --- 120,130 ---- } + public HistogramFrame(DataSet dataset) { super(); rawData = dataset; + lower_limit=dataset.getMin(); + upper_limit=dataset.getMax(); + this.iterNoList = dataset.getIterList(); initGUI(); } *************** *** 81,92 **** GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane()); getContentPane().setLayout(thisLayout); thisLayout.setVerticalGroup(thisLayout.createSequentialGroup() ! .add(getJSplitPane1(), 0, 407, Short.MAX_VALUE) ! .addPreferredGap(LayoutStyle.RELATED)); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup() ! .add(getJSplitPane1(), 0, 632, Short.MAX_VALUE)); ! setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); pack(); ! this.setSize(632, 434); } catch (Exception e) { e.printStackTrace(); --- 134,178 ---- GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane()); getContentPane().setLayout(thisLayout); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + { + jSplitPane2 = new JSplitPane(); + jSplitPane2.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED)); + jSplitPane2.setDividerLocation(800); + { + ListModel jList1Model = + new DefaultComboBoxModel(iterNoList); + jList1 = new JList(); + jSplitPane2.add(getJSplitPane1(), JSplitPane.LEFT); + jSplitPane2.add(jList1, JSplitPane.RIGHT); + jList1.setModel(jList1Model); + jList1.setPreferredSize(new java.awt.Dimension(85, 408)); + jList1.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + + if(!evt.getValueIsAdjusting()) { + JList list = (JList) evt.getSource(); + int iter = list.getSelectedIndex(); + System.out.printf("jList1.valueChanged, item index=%d, id=%s%n",iter,list.getSelectedValue()); + rawData.setIteration(iter); //update the rawDataSet according to the new iteration. + updateHistogramDataset(); + //System.out.printf("histogramDataset has %d series%n",histogramDataset.getSeriesCount()); + //histogramDataset.seriesChanged(null); + + XYSeries rocSeries = rawData.generateRoC(negLabel,posLabel); + rocDataset.removeSeries(0); + rocDataset.addSeries(rocSeries); + updateUpperMarker(); + updateLowerMarker(); + } + } + }); + } + } thisLayout.setVerticalGroup(thisLayout.createSequentialGroup() ! .add(jSplitPane2, 0, 412, Short.MAX_VALUE)); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup() ! .add(jSplitPane2, 0, 886, Short.MAX_VALUE)); pack(); ! this.setSize(886, 434); } catch (Exception e) { e.printStackTrace(); *************** *** 97,113 **** if(jSplitPane1 == null) { jSplitPane1 = new JSplitPane(); { jPanel1 = new JPanel(); jSplitPane1.add(jPanel1, JSplitPane.RIGHT); ! jPanel1.setPreferredSize(new java.awt.Dimension(263, 393)); BoxLayout jPanel1Layout = new BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS); jPanel1.setLayout(jPanel1Layout); { ! IntervalXYDataset dataset = createHistogramDataset(); ! histogramChart = createHistChart(dataset); histogramPanel = new ChartPanel(histogramChart); jPanel1.add(histogramPanel); histogramPanel.setPopupMenu(null); } } --- 183,212 ---- if(jSplitPane1 == null) { jSplitPane1 = new JSplitPane(); + jSplitPane1.setPreferredSize(new java.awt.Dimension(546, 408)); + jSplitPane1.setDividerLocation(400); + jSplitPane1.setDoubleBuffered(true); { jPanel1 = new JPanel(); jSplitPane1.add(jPanel1, JSplitPane.RIGHT); ! jPanel1.setPreferredSize(new java.awt.Dimension(10, 406)); BoxLayout jPanel1Layout = new BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS); jPanel1.setLayout(jPanel1Layout); { ! histogramDataset = new XYIntervalSeriesCollection[2]; ! histogramDataset[0] = new XYIntervalSeriesCollection(); ! histogramDataset[1] = new XYIntervalSeriesCollection(); ! updateHistogramDataset(); ! histogramChart = createHistogramChart(histogramDataset); ! ! double initialLocation = (upper_limit+lower_limit)/2.0; ! histMarker = new IntervalMarker(initialLocation,initialLocation); ! XYPlot plot = (XYPlot) histogramChart.getPlot(); ! plot.addDomainMarker(histMarker, Layer.BACKGROUND); ! histogramPanel = new ChartPanel(histogramChart); jPanel1.add(histogramPanel); histogramPanel.setPopupMenu(null); + histogramPanel.setPreferredSize(new java.awt.Dimension(10, 374)); } } *************** *** 115,127 **** jPanel2 = new JPanel(); jSplitPane1.add(jPanel2, JSplitPane.LEFT); ! jPanel2.setPreferredSize(new java.awt.Dimension(291, 393)); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); { ! rocChart = createRocChart(rawData.generateRoC(-1, 1)); rocPanel = new ChartPanel(rocChart); jPanel2.add(rocPanel); rocPanel.setPopupMenu(null); } } --- 214,231 ---- jPanel2 = new JPanel(); jSplitPane1.add(jPanel2, JSplitPane.LEFT); ! jPanel2.setPreferredSize(new java.awt.Dimension(10, 393)); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); + jPanel2.setOpaque(false); { ! rocDataset = new XYSeriesCollection(); ! XYSeries rocSeries = rawData.generateRoC(negLabel,posLabel); ! rocDataset.addSeries(rocSeries); ! rocChart = createRocChart(rocDataset); rocPanel = new ChartPanel(rocChart); jPanel2.add(rocPanel); rocPanel.setPopupMenu(null); + rocPanel.setPreferredSize(new java.awt.Dimension(10, 406)); } } *************** *** 130,144 **** jPanel1.add(jSlider1); jSlider1.setLayout(null); jSlider1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { ! ! int pos = (int)jSlider1.getValue(); ! double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; ! histMarker.setEndValue(v); ! if (!jSlider1.getValueIsAdjusting()) { ! double[] FPTP = rawData.getFPTP(v); ! upper_fprMarker.setValue(FPTP[0]); ! upper_tprMarker.setValue(FPTP[1]); ! } } }); --- 234,241 ---- jPanel1.add(jSlider1); jSlider1.setLayout(null); + jSlider1.setPreferredSize(new java.awt.Dimension(10, 16)); jSlider1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { ! updateUpperMarker(); } }); *************** *** 148,161 **** jPanel1.add(jSlider2); jSlider2.setLayout(null); jSlider2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { ! int pos = (int)jSlider2.getValue(); ! double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; ! histMarker.setStartValue(v); ! if (!jSlider2.getValueIsAdjusting()) { ! double[] FPTP = rawData.getFPTP(v); ! lower_fprMarker.setValue(FPTP[0]); ! lower_tprMarker.setValue(FPTP[1]); ! } } }); --- 245,252 ---- jPanel1.add(jSlider2); jSlider2.setLayout(null); + jSlider2.setPreferredSize(new java.awt.Dimension(10, 16)); jSlider2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { ! updateLowerMarker(); } }); *************** *** 166,218 **** } ! /** ! * Creates a sample ! * ! * @return the dataset. ! */ ! private static IntervalXYDataset createHistogramDataset() { ! HistogramDataset dataset = new HistogramDataset(); ! double[] negSet = rawData.getSet(-1); ! double[] posSet = rawData.getSet(1); ! System.out.printf("negSet:%d,posSet:%d%n",negSet.length,posSet.length); ! dataset.addSeries("H1", negSet, 100, rawData.getMin(), rawData.getMax()); ! dataset.addSeries("H2", posSet, 100, rawData.getMin(), rawData.getMax()); ! return dataset; } ! /** ! * Creates a chart. ! * ! * @param dataset a dataset. ! * ! * @return The chart. ! */ ! private static JFreeChart createHistChart(IntervalXYDataset dataset) { ! JFreeChart chart = ChartFactory.createHistogram( ! "Histogram", ! null, ! null, ! dataset, ! PlotOrientation.VERTICAL, ! false, /* No Legend */ ! true, ! false ! ); ! XYPlot plot = (XYPlot) chart.getPlot(); ! Range range = plot.getDataRange(plot.getDomainAxis()); ! System.out.println(range); ! upper_limit = range.getUpperBound(); ! lower_limit = range.getLowerBound(); ! plot.setForegroundAlpha(0.85f); ! XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); ! renderer.setDrawBarOutline(false); ! ! histMarker = new IntervalMarker((lower_limit+upper_limit)/2.0,(lower_limit+upper_limit)/2.0); ! ! plot.addDomainMarker(histMarker, Layer.BACKGROUND); ! return chart; } private static JFreeChart createRocChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart( --- 257,346 ---- } ! private void updateUpperMarker() { ! int pos = (int)jSlider1.getValue(); ! double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; ! histMarker.setEndValue(v); ! if (!jSlider1.getValueIsAdjusting()) { ! double[] FPTP = rawData.getFPTP(v); ! upper_fprMarker.setValue(FPTP[0]); ! upper_tprMarker.setValue(FPTP[1]); ! } ! } ! ! private void updateLowerMarker() { ! int pos = (int)jSlider2.getValue(); ! double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; ! histMarker.setStartValue(v); ! if (!jSlider2.getValueIsAdjusting()) { ! double[] FPTP = rawData.getFPTP(v); ! lower_fprMarker.setValue(FPTP[0]); ! lower_tprMarker.setValue(FPTP[1]); ! } ! } ! ! /** ! * @param listener ! * @see org.jfree.chart.plot.Marker#addChangeListener(org.jfree.chart.event.MarkerChangeListener) ! */ ! public void addChangeListener(MarkerChangeListener listener) { ! histMarker.addChangeListener(listener); ! } ! ! ! private void updateHistogramDataset() { ! ! if(histogramDataset[0].getSeriesCount()>0) { ! histogramDataset[0].removeAllSeries(); ! histogramDataset[1].removeAllSeries(); ! } ! ! XYIntervalSeries posSeries = new XYIntervalSeries("positive"); ! XYIntervalSeries negSeries = new XYIntervalSeries("negative"); ! double[] posHist = rawData.computeHistogram(1, noOfBins); ! double[] negHist = rawData.computeHistogram(-1,noOfBins); ! ! double min=rawData.getMin(); ! double max=rawData.getMax(); ! ! double x=min; ! double step=(max-min)/noOfBins; ! for(int i=0; i<noOfBins; i++){ ! posSeries.add(x, x, x+(step/2), posHist[i], 0, posHist[i]); ! negSeries.add(x+(step/2),x+(step/2),x+step, negHist[i], 0, negHist[i]); ! x=x+step; ! } ! histogramDataset[0].addSeries(posSeries); ! histogramDataset[1].addSeries(negSeries); } ! private static JFreeChart createHistogramChart(IntervalXYDataset[] dataset) { ! ! XYBarRenderer posRenderer = new XYBarRenderer(); ! posRenderer.setSeriesPaint(0,Color.blue); ! XYBarRenderer negRenderer = new XYBarRenderer(); ! negRenderer.setSeriesPaint(0,Color.red); ! XYPlot plot = new XYPlot(dataset[0], ! new NumberAxis("score"), ! new NumberAxis("count"), ! posRenderer); ! plot.setDataset(1, dataset[1]); ! plot.setRenderer(1, negRenderer); ! ! //plot.setBackgroundPaint(Color.lightGray); ! //plot.setDomainGridlinePaint(Color.white); ! //plot.setRangeGridlinePaint(Color.white); ! ! JFreeChart chart = new JFreeChart( ! "Histogram", ! JFreeChart.DEFAULT_TITLE_FONT, ! plot, ! false // legend ! ); ! return chart; } + + private static JFreeChart createRocChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart( |
From: Yoav F. <yf...@us...> - 2008-09-09 20:43:29
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21955 Modified Files: build.xml .pydevproject Log Message: VisualizeScores.py is working. Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** build.xml 3 Sep 2008 18:18:49 -0000 1.9 --- build.xml 9 Sep 2008 20:43:24 -0000 1.10 *************** *** 1,5 **** <?xml version="1.0"?> ! <project name="jboost Buildfile" default="compile" basedir="."> <!-- Properties --> --- 1,5 ---- <?xml version="1.0"?> ! <project name="jboost Buildfile" default="jar" basedir="."> <!-- Properties --> Index: .pydevproject =================================================================== RCS file: /cvsroot/jboost/jboost/.pydevproject,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .pydevproject 3 Sep 2008 18:40:01 -0000 1.1 --- .pydevproject 9 Sep 2008 20:43:25 -0000 1.2 *************** *** 3,6 **** <pydev_project> ! <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property> </pydev_project> --- 3,14 ---- <pydev_project> ! <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">jython 2.1</pydev_property> ! <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> ! <path>/jboost/dist/jboost.jar</path> ! <path>/jboost/lib/concurrent.jar</path> ! <path>/jboost/lib/jcommon-1.0.8.jar</path> ! <path>/jboost/lib/jfreechart-1.0.10.jar</path> ! <path>/jboost/lib/junit.jar</path> ! <path>/jboost/lib/swing-layout-1.0.jar</path> ! </pydev_pathproperty> </pydev_project> |
From: Yoav F. <yf...@us...> - 2008-09-09 20:43:29
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21955/scripts Modified Files: VisualizeScores.py Log Message: VisualizeScores.py is working. Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VisualizeScores.py 3 Sep 2008 18:37:32 -0000 1.2 --- VisualizeScores.py 9 Sep 2008 20:43:25 -0000 1.3 *************** *** 1,55 **** ! import sys,os,os.path,re,math import jarray ! filename = '/Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/trial0.test.boosting.info' #args = sys.argv[1:] #if len(args) != 1: ! # sys.exit('Usage: ParseTree <name>.output.tree') #filename = args[0] - infile = open(filename,'r') - header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') for line in infile: - #print line [(iter,elements)] = header_p.findall(line) - iter=int(iter) elements = int(elements) ! # print "iter=%d elements=%d\n" % (iter,elements) ! indexes=[] ! scores=[] ! labels=[] for count in range(elements): line=infile.readline() - #print line - a = scoreline_p.findall(line) - [index,margin,score,label]=a - #[index,margin,score,x1,x2,label]=a - indexes.append(int(index)) - scores.append(float(score)) - labels.append(int(label)) - #print "index=%d, score=%f, label=%d\n" % (index,score,label) - #if index>10: - # break ! print len(indexes) ! jindexes = jarray.array(indexes,'i') ! jscores = jarray.array(scores,'d') ! jlabels = jarray.array(labels,'i') ! print jscores[3:30] ! print jlabels[3:30] ! if iter==20: ! break ! import jboost.visualization ! d=jboost.visualization.DataSet(jindexes,jscores,jlabels) ! print d.getMin() ! v=jboost.visualization.HistogramFrame(d) ! v.show() ! ! --- 1,80 ---- ! import sys,os,os.path,re,math,glob import jarray + from java.util import Vector ! info_path = '/Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/' #args = sys.argv[1:] #if len(args) != 1: ! # sys.exit(""" ! # Usage: VisualizeScore <info-files-path> ! # info-file-path is a directory containing files with names like trial0.test.boosting.info, trial2.train.boosting.info ... ! # Example: VisualizeScore /Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/' ! # """) #filename = args[0] header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') + #testfiles = glob.glob(info_path+"trial*.test.boosting.info") + + testfiles = glob.glob("/Users/yoavfreund/Downloads/dc_boost_active_output/iter?/*.test.boosting.info") + + indexes={} + scores={} + labels={} + + #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) ! # read the data into the Dataset data structures. ! for filename in testfiles: ! print filename ! infile = open(filename,'r') ! iterList=[]; ! for line in infile: ! print line ! [(iter,elements)] = header_p.findall(line) ! iterationIndex=iterDict[iter] ! elements = int(elements) ! print "iter=%s iterationIndex=%d elements=%d\n" % (iter,iterationIndex, elements) ! for count in range(elements): ! line=infile.readline() ! #print line ! a = scoreline_p.findall(line) ! index=int(a[0]) ! score=float(a[2]) ! label=int(a[-1]) ! e=DataElement(score,index,label) ! d.addDataElement(e,iterationIndex) ! ! print "going to preprocess\n" ! d.preProcessDataset() ! print "finisehd preprocessing\n" ! ! print "min= %f, max=%f\n" % (d.getMin(),d.getMax()) ! ! v=HistogramFrame(d) ! ! v.show() |
From: Yoav F. <yf...@us...> - 2008-09-09 20:42:55
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21567 Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- build javadoc |
From: Yoav F. <yf...@us...> - 2008-09-09 20:41:10
|
Update of /cvsroot/jboost/jboost/dist In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv21159/dist Added Files: jboost.jar Log Message: VisualizeScores.py is working. --- NEW FILE: jboost.jar --- (This appears to be a binary file; contents omitted.) |
From: Yoav F. <yf...@us...> - 2008-09-09 20:39:30
|
Update of /cvsroot/jboost/jboost/dist In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv20281/dist Log Message: Directory /cvsroot/jboost/jboost/dist added to the repository |
From: Yoav F. <yf...@us...> - 2008-09-03 18:40:09
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2314 Modified Files: .project Added Files: .pydevproject Log Message: Updating eclipse project files. Index: .project =================================================================== RCS file: /cvsroot/jboost/jboost/.project,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .project 3 Sep 2008 18:18:49 -0000 1.1 --- .project 3 Sep 2008 18:40:01 -0000 1.2 *************** *** 7,10 **** --- 7,15 ---- <buildSpec> <buildCommand> + <name>org.python.pydev.PyDevBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> *************** *** 14,17 **** --- 19,23 ---- <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.python.pydev.pythonNature</nature> </natures> </projectDescription> --- NEW FILE: .pydevproject --- <?xml version="1.0" encoding="UTF-8"?> <?eclipse-pydev version="1.0"?> <pydev_project> <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property> </pydev_project> |
From: Yoav F. <yf...@us...> - 2008-09-03 18:37:35
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv1447/scripts Modified Files: VisualizeScores.py Added Files: setClassPath.sh Log Message: Update to VisualizeScores Added setClassPath to set the java class path, script should be run from the root of the jboost directory. Index: VisualizeScores.py =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/VisualizeScores.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VisualizeScores.py 3 Sep 2008 17:36:25 -0000 1.1 --- VisualizeScores.py 3 Sep 2008 18:37:32 -0000 1.2 *************** *** 46,53 **** break ! import mljava.visualization ! d=mljava.visualization.DataSet(jindexes,jscores,jlabels) print d.getMin() ! v=mljava.visualization.HistogramFrame(d) v.show() --- 46,53 ---- break ! import jboost.visualization ! d=jboost.visualization.DataSet(jindexes,jscores,jlabels) print d.getMin() ! v=jboost.visualization.HistogramFrame(d) v.show() --- NEW FILE: setClassPath.sh --- export JBOOST_HOME=`pwd` export CLASSPATH="$CLASSPATH:$JBOOST_HOME/dist/jboost.jar:$JBOOST_HOME/lib/jcommon-1.0.8.jar:$JBOOST_HOME/lib/jfreechart-1.0.10.jar" export CLASSPATH="$CLASSPATH:$JBOOST_HOME/bin/junit.jar:lib/jcommon-1.0.8.jar:$JBOOST_HOME/lib/concurrent.jar:$JBOOST_HOME/lib/swing-layout-1.0.jar" |
From: Yoav F. <yf...@us...> - 2008-09-03 18:18:53
|
Update of /cvsroot/jboost/jboost In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv26151 Modified Files: build.xml Added Files: .project .classpath Log Message: Updated eclipse project configuration files and ant build file to point to new libraries. --- NEW FILE: .project --- <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>jboost</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> Index: build.xml =================================================================== RCS file: /cvsroot/jboost/jboost/build.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** build.xml 23 Oct 2007 23:52:26 -0000 1.8 --- build.xml 3 Sep 2008 18:18:49 -0000 1.9 *************** *** 77,81 **** description="Compile all source code."> <javac srcdir="${dir.src}" ! classpath="${dir.lib}/junit.jar:${dir.lib}/concurrent.jar" destdir="${dir.build}" debug="on" --- 77,81 ---- 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" --- NEW FILE: .classpath --- <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jcommon-1.0.8"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jfreechart-1.0.10"/> <classpathentry kind="lib" path="lib/swing-layout-1.0.jar"/> <classpathentry kind="output" path="bin"/> </classpath> |
From: Yoav F. <yf...@us...> - 2008-09-03 18:10:00
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv22380/src/jboost/visualization Modified Files: DataSet.java HistogramFrame.java Log Message: Corrected package name Index: DataSet.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/DataSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataSet.java 3 Sep 2008 17:32:27 -0000 1.1 --- DataSet.java 3 Sep 2008 18:09:54 -0000 1.2 *************** *** 1,3 **** ! package mljava.visualization; import java.util.Random; --- 1,3 ---- ! package jboost.visualization; import java.util.Random; Index: HistogramFrame.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/visualization/HistogramFrame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistogramFrame.java 3 Sep 2008 17:32:27 -0000 1.1 --- HistogramFrame.java 3 Sep 2008 18:09:54 -0000 1.2 *************** *** 1,14 **** ! package mljava.visualization; import java.awt.Color; import javax.swing.BoxLayout; import javax.swing.JComponent; - import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSplitPane; ! import javax.swing.JTextArea; ! import javax.swing.WindowConstants; import org.jdesktop.layout.GroupLayout; import org.jdesktop.layout.LayoutStyle; --- 1,15 ---- ! package jboost.visualization; import java.awt.Color; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSplitPane; ! import javax.swing.SwingUtilities; import javax.swing.WindowConstants; + import javax.swing.event.ChangeEvent; + import javax.swing.event.ChangeListener; + import org.jdesktop.layout.GroupLayout; import org.jdesktop.layout.LayoutStyle; *************** *** 22,26 **** import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.Range; - import org.jfree.data.general.Dataset; import org.jfree.data.statistics.HistogramDataset; import org.jfree.data.xy.IntervalXYDataset; --- 23,26 ---- *************** *** 28,37 **** import org.jfree.ui.Layer; - import javax.swing.SwingUtilities; - import javax.swing.event.ChangeEvent; - import javax.swing.event.ChangeListener; - - - /** * @author yoavfreund --- 28,31 ---- |
From: Yoav F. <yf...@us...> - 2008-09-03 17:36:28
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv8336/scripts Added Files: VisualizeScores.py Log Message: Jython script for visualizing score distributions --- NEW FILE: VisualizeScores.py --- import sys,os,os.path,re,math import jarray filename = '/Users/yoavfreund/Desktop/Galit_Lahav/Raw_tifs/28/jboost/t28.0/ADD_ALL/trial0.test.boosting.info' #args = sys.argv[1:] #if len(args) != 1: # sys.exit('Usage: ParseTree <name>.output.tree') #filename = args[0] infile = open(filename,'r') header_p = re.compile('iteration=(\d+): elements=(\d+):') scoreline_p = re.compile('([-+\d.]+):\s+') #([+-1]+):') for line in infile: #print line [(iter,elements)] = header_p.findall(line) iter=int(iter) elements = int(elements) # print "iter=%d elements=%d\n" % (iter,elements) indexes=[] scores=[] labels=[] for count in range(elements): line=infile.readline() #print line a = scoreline_p.findall(line) [index,margin,score,label]=a #[index,margin,score,x1,x2,label]=a indexes.append(int(index)) scores.append(float(score)) labels.append(int(label)) #print "index=%d, score=%f, label=%d\n" % (index,score,label) #if index>10: # break print len(indexes) jindexes = jarray.array(indexes,'i') jscores = jarray.array(scores,'d') jlabels = jarray.array(labels,'i') print jscores[3:30] print jlabels[3:30] if iter==20: break import mljava.visualization d=mljava.visualization.DataSet(jindexes,jscores,jlabels) print d.getMin() v=mljava.visualization.HistogramFrame(d) v.show() |
From: Yoav F. <yf...@us...> - 2008-09-03 17:32:31
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv6664/src/jboost/visualization Added Files: DataSet.java HistogramFrame.java Log Message: Adding Histogram visualization code. --- NEW FILE: DataSet.java --- package mljava.visualization; import java.util.Random; import java.util.TreeSet; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * @author yoavfreund * A data structure that stores a set of scores and labels for examples. Used to store the data for {@HistogramFrame}. */ public class DataSet { private TreeSet<DataElement> data; public DataSet(int size) { data = new TreeSet<DataElement>(); Random generator = new Random(12345678L); for (int i = 0; i < 2*size; i++) { DataElement element = new DataElement(); int label = (i<size)?-1:1; element.value = generator.nextGaussian() + label/2.0+5; element.index = i; element.label = label; data.add(element); } } public DataSet(int[] indexes, double[] values, int[] labels) { data = new TreeSet<DataElement>(); for (int i = 0; i < indexes.length; i++) { DataElement element = new DataElement(); element.value = values[i]; element.index = indexes[i]; element.label = labels[i]; data.add(element); } } public double getMin() { return data.first().value; } public double getMax() { return data.last().value; } public double[] getFPTP(double v) { DataElement e = data.tailSet(new DataElement(v)).first(); double[] answer = {e.FPR,e.TPR}; return answer; } public double[] getSet(int label) { Object[] a = (Object[]) data.toArray(); int count=0; for (int i=0; i<a.length; i++) { DataElement e = ((DataElement) a[i]); if(e.label == label) { count++; } } if(count==0) {return new double[] {0.0};} double[] answer = new double[count]; count=0; for (int i=0; i<a.length; i++) { DataElement e = ((DataElement) a[i]); if(e.label == label) { answer[count] = e.value; count++; } } return answer; } public XYDataset generateRoC(int neg_label, int pos_label) { XYSeries roc = new XYSeries("ROC"); Object[] a = (Object[]) data.toArray(); int neg_count=0; int pos_count=0; for(int i=0; i<a.length; i++) { DataElement e = ((DataElement) a[i]); if(e.label == neg_label) neg_count++; else if(e.label == pos_label) pos_count++; } double total_neg=neg_count; double total_pos=pos_count; neg_count=0; pos_count=0; 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.TPR=pos_count/total_pos; e.FPR=neg_count/total_neg; // System.out.printf("%f: %f,%f%n",e.value,e.FPR,e.TPR); roc.add(e.FPR, e.TPR); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(roc); return dataset; } public static void main(String[] args) { DataSet test = new DataSet(50); test.generateRoC(-1,1); double[] a = test.getFPTP(5.0); System.out.printf("%f; %f%n",a[0],a[1]); System.out.println("yoav was here!"); } } class DataElement implements Comparable{ protected double value; protected int label; protected int index; protected double FPR,TPR; public DataElement(double v) { value=v; } public DataElement() {} public int compareTo(Object that) { return (int) Math.signum(this.value-((DataElement) that).value); } } --- NEW FILE: HistogramFrame.java --- package mljava.visualization; import java.awt.Color; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.WindowConstants; import org.jdesktop.layout.GroupLayout; import org.jdesktop.layout.LayoutStyle; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.IntervalMarker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.Range; import org.jfree.data.general.Dataset; import org.jfree.data.statistics.HistogramDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.Layer; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; /** * @author yoavfreund * A class based on swing and jFreeChart that implements a frame for visualizing an ROC and a histogram * for a two-class distribution. Used to visualize the scores distribution generated by boosting. */ public class HistogramFrame extends javax.swing.JFrame { private static final long serialVersionUID = 1L; private JSplitPane jSplitPane1; private JSlider jSlider1; private JSlider jSlider2; private JPanel jPanel1; private JPanel jPanel2; private JFreeChart histogramChart; private ChartPanel histogramPanel; private JFreeChart rocChart; private ChartPanel rocPanel; private static double upper_limit; private static double lower_limit; private static IntervalMarker histMarker; private static ValueMarker lower_tprMarker, lower_fprMarker; //markers for ROC graph private static ValueMarker upper_tprMarker, upper_fprMarker; //markers for ROC graph private static DataSet rawData; private static final int SampleSize = 10000; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { final DataSet dataset = new DataSet(SampleSize); SwingUtilities.invokeLater(new Runnable() { public void run() { HistogramFrame inst = new HistogramFrame(dataset); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public HistogramFrame(DataSet dataset) { super(); rawData = dataset; initGUI(); } private void initGUI() { try { GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane()); getContentPane().setLayout(thisLayout); thisLayout.setVerticalGroup(thisLayout.createSequentialGroup() .add(getJSplitPane1(), 0, 407, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.RELATED)); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup() .add(getJSplitPane1(), 0, 632, Short.MAX_VALUE)); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); pack(); this.setSize(632, 434); } catch (Exception e) { e.printStackTrace(); } } private JSplitPane getJSplitPane1() { if(jSplitPane1 == null) { jSplitPane1 = new JSplitPane(); { jPanel1 = new JPanel(); jSplitPane1.add(jPanel1, JSplitPane.RIGHT); jPanel1.setPreferredSize(new java.awt.Dimension(263, 393)); BoxLayout jPanel1Layout = new BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS); jPanel1.setLayout(jPanel1Layout); { IntervalXYDataset dataset = createHistogramDataset(); histogramChart = createHistChart(dataset); histogramPanel = new ChartPanel(histogramChart); jPanel1.add(histogramPanel); histogramPanel.setPopupMenu(null); } } { jPanel2 = new JPanel(); jSplitPane1.add(jPanel2, JSplitPane.LEFT); jPanel2.setPreferredSize(new java.awt.Dimension(291, 393)); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); { rocChart = createRocChart(rawData.generateRoC(-1, 1)); rocPanel = new ChartPanel(rocChart); jPanel2.add(rocPanel); rocPanel.setPopupMenu(null); } } { jSlider1 = new JSlider(); jPanel1.add(jSlider1); jSlider1.setLayout(null); jSlider1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { int pos = (int)jSlider1.getValue(); double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; histMarker.setEndValue(v); if (!jSlider1.getValueIsAdjusting()) { double[] FPTP = rawData.getFPTP(v); upper_fprMarker.setValue(FPTP[0]); upper_tprMarker.setValue(FPTP[1]); } } }); } { jSlider2 = new JSlider(); jPanel1.add(jSlider2); jSlider2.setLayout(null); jSlider2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { int pos = (int)jSlider2.getValue(); double v=lower_limit+pos*(upper_limit-lower_limit)/100.0; histMarker.setStartValue(v); if (!jSlider2.getValueIsAdjusting()) { double[] FPTP = rawData.getFPTP(v); lower_fprMarker.setValue(FPTP[0]); lower_tprMarker.setValue(FPTP[1]); } } }); } } return jSplitPane1; } /** * Creates a sample * * @return the dataset. */ private static IntervalXYDataset createHistogramDataset() { HistogramDataset dataset = new HistogramDataset(); double[] negSet = rawData.getSet(-1); double[] posSet = rawData.getSet(1); System.out.printf("negSet:%d,posSet:%d%n",negSet.length,posSet.length); dataset.addSeries("H1", negSet, 100, rawData.getMin(), rawData.getMax()); dataset.addSeries("H2", posSet, 100, rawData.getMin(), rawData.getMax()); return dataset; } /** * Creates a chart. * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createHistChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createHistogram( "Histogram", null, null, dataset, PlotOrientation.VERTICAL, false, /* No Legend */ true, false ); XYPlot plot = (XYPlot) chart.getPlot(); Range range = plot.getDataRange(plot.getDomainAxis()); System.out.println(range); upper_limit = range.getUpperBound(); lower_limit = range.getLowerBound(); plot.setForegroundAlpha(0.85f); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); histMarker = new IntervalMarker((lower_limit+upper_limit)/2.0,(lower_limit+upper_limit)/2.0); plot.addDomainMarker(histMarker, Layer.BACKGROUND); return chart; } private static JFreeChart createRocChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart( "ROC", // chart title "False positive rate", // x axis label "True positive rate", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); lower_tprMarker = new ValueMarker(0.5); lower_tprMarker.setPaint(Color.blue); lower_fprMarker = new ValueMarker(0.5); lower_fprMarker.setPaint(Color.blue); plot.addRangeMarker(lower_tprMarker); plot.addDomainMarker(lower_fprMarker); upper_tprMarker = new ValueMarker(0.5); upper_tprMarker.setPaint(Color.red); upper_fprMarker = new ValueMarker(0.5); upper_fprMarker.setPaint(Color.red); plot.addRangeMarker(upper_tprMarker); plot.addDomainMarker(upper_fprMarker); return chart; } } |
From: Yoav F. <yf...@us...> - 2008-09-03 17:31:29
|
Update of /cvsroot/jboost/jboost/src/jboost/visualization In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv6266/src/jboost/visualization Log Message: Directory /cvsroot/jboost/jboost/src/jboost/visualization added to the repository |
From: Yoav F. <yf...@us...> - 2008-09-03 17:29:02
|
Update of /cvsroot/jboost/jboost/lib In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv5007/lib Added Files: swing-layout-1.0.jar jfreechart-1.0.10.jar jcommon-1.0.8.jar Log Message: Added libraries for visualization code --- NEW FILE: swing-layout-1.0.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jcommon-1.0.8.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jfreechart-1.0.10.jar --- (This appears to be a binary file; contents omitted.) |
From: Aaron A. <aa...@us...> - 2008-08-16 03:17:18
|
Update of /cvsroot/jboost/jboost/src/jboost/controller In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv32164 Modified Files: Controller.java Log Message: Removed 300 iteration bound on BrownBoost... user beware... Index: Controller.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/controller/Controller.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Controller.java 15 Aug 2008 21:38:13 -0000 1.10 --- Controller.java 16 Aug 2008 03:17:13 -0000 1.11 *************** *** 431,435 **** + iter); } ! if(m_booster instanceof BrownBoost && iterNo < 2*DEFAULT_NUMROUNDS){ iterNo++; } --- 431,435 ---- + iter); } ! if(m_booster instanceof BrownBoost){ iterNo++; } |
From: Aaron A. <aa...@us...> - 2008-08-15 21:50:15
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv28672 Modified Files: README atreeplot.R Log Message: Small bug fixes and more documentation Index: README =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 31 Jul 2008 22:15:33 -0000 1.1 --- README 15 Aug 2008 21:50:09 -0000 1.2 *************** *** 1,19 **** ! How to use scripts ----------------- Requirements: * R (version 2.6 or higher) ! * igraph (R package, can be obtained via install.packages or CRAN) ! * jboost (R package, can be obtained via install.packages or CRAN) - The best way to use the scripts is to install the jboost package. - This can be done by using the 'install.packages()' from R or by - downloading the JBoost package from CRAN and installing via 'R CMD - INSTALL jboost'. ! How to make the package: -------------------------- --- 1,24 ---- ! How to install scripts ----------------- Requirements: + * Python (tested with version 2.5.2, though lower version may work) * R (version 2.6 or higher) ! * igraph (R package, can be obtained via install.packages() or CRAN) + How to use the visualization scripts + -------------------------- + + source("atreeplot.R") + plot.atree(treefile="stem.output.tree", specfile="stem.spec") + + source("marginplot.R") + plot.margin(infofile="stem.train.boosting.info", specfile="stem.spec", iteration=c(10,50,100)) ! ! How to make the package -------------------------- Index: atreeplot.R =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/atreeplot.R,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** atreeplot.R 31 Jul 2008 22:16:52 -0000 1.2 --- atreeplot.R 15 Aug 2008 21:50:11 -0000 1.3 *************** *** 37,41 **** ! plot.atree <- function(treefile, specfile, flip.labels=F, depth=-1, width=-1, height=-1) { labels = parse.labels(specfile) num.labels = length(labels); --- 37,41 ---- ! plot.atree <- function(treefile, specfile, flip.labels=F, depth=-1, plot.width=-1, plot.height=-1) { labels = parse.labels(specfile) num.labels = length(labels); *************** *** 79,83 **** label = x[4] predType = x[4]; ! #show(c(type, iteration, index, label)) x <- perl.re(predType, ".*MultiPrediction.*") y <- perl.re(predType, ".*BinaryPrediction.*=(.*)") --- 79,83 ---- label = x[4] predType = x[4]; ! show(c(type, iteration, index, label)) x <- perl.re(predType, ".*MultiPrediction.*") y <- perl.re(predType, ".*BinaryPrediction.*=(.*)") *************** *** 102,105 **** --- 102,106 ---- } else if (y[1]=="TRUE") { label = y[2] + show(sprintf("label is %0.5f", label)) if(flip.labels) { label = as.numeric(label) *************** *** 107,110 **** --- 108,114 ---- label = as.character(label) } + } else { + error(paste("Do not recognize prediction type:", label)) + return } } *************** *** 154,163 **** ans <- substr(index,nchar(index), nchar(index)) if (ans=="0") { - E(g)$color[length(E(g))] <- "red" - E(g)$label[length(E(g))] <- "False" - } else if (ans=="1") { E(g)$color[length(E(g))] <- "green" ! E(g)$label[length(E(g))] <- "True" ! } else { error(paste("The splitter has an invalid return value!\n 1 or 0 expected, recieved", ans)) } --- 158,167 ---- ans <- substr(index,nchar(index), nchar(index)) if (ans=="0") { E(g)$color[length(E(g))] <- "green" ! E(g)$label[length(E(g))] <- " Yes" ! } else if (ans=="1") { ! E(g)$color[length(E(g))] <- "red" ! E(g)$label[length(E(g))] <- "No " ! } else { error(paste("The splitter has an invalid return value!\n 1 or 0 expected, recieved", ans)) } *************** *** 169,176 **** } ! w <- warnings() ! if (length(w)>0) { ! show(w) ! } i <- i + 1 } --- 173,180 ---- } ! #w <- warnings() ! #if (length(w)>0) { ! # show(w) ! #} i <- i + 1 } *************** *** 180,186 **** coords[,2] <- max(coords[,2])-coords[,2] fname <- sprintf("%s.eps", treefile) show(sprintf("Writing file to '%s'", fname)) ! postscript(file=sprintf("%s.eps", treefile), fonts=c("serif", "Palatino"), paper="special", width=70, height=40, horizontal=TRUE) plot(1, type="n", axes=FALSE, xlab=NA, ylab=NA, xlim=c(-1,1), ylim=c(-1,1)) sw <- strwidth(paste("", V(g)$label, "")) --- 184,198 ---- coords[,2] <- max(coords[,2])-coords[,2] + if(plot.width<0) { + plot.width <- 8 + } + if(plot.height<0) { + plot.height <- 9 + } + fname <- sprintf("%s.eps", treefile) show(sprintf("Writing file to '%s'", fname)) ! postscript(file=sprintf("%s.eps", treefile), fonts=c("serif", "Palatino"), ! paper="special", width=plot.width, height=plot.height, horizontal=TRUE) plot(1, type="n", axes=FALSE, xlab=NA, ylab=NA, xlim=c(-1,1), ylim=c(-1,1)) sw <- strwidth(paste("", V(g)$label, "")) |