From: <ku...@us...> - 2010-02-16 17:44:35
|
Revision: 2048 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2048&view=rev Author: kurzum Date: 2010-02-16 17:44:27 +0000 (Tue, 16 Feb 2010) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/tiger/TestIterativeLearning.java trunk/src/dl-learner/org/dllearner/utilities/experiments/Table.java trunk/src/dl-learner/org/dllearner/utilities/experiments/TableRowColumn.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/experiments/FinalizedMonitor.java Modified: trunk/src/dl-learner/org/dllearner/scripts/tiger/TestIterativeLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/tiger/TestIterativeLearning.java 2010-02-16 14:15:17 UTC (rev 2047) +++ trunk/src/dl-learner/org/dllearner/scripts/tiger/TestIterativeLearning.java 2010-02-16 17:44:27 UTC (rev 2048) @@ -19,6 +19,7 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.refinement2.ROLComponent2; import org.dllearner.algorithms.refinement2.ROLearner2; +import org.dllearner.core.ComponentManager; import org.dllearner.core.ComponentPool; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; @@ -91,7 +92,7 @@ static List<MonKeyImp> mks = new ArrayList<MonKeyImp>(Arrays.asList(new MonKeyImp[] { logPrecision, logRecall, logFMeasure, logLearningTime, logIterationTime })); - static int iterations = 4; + static int iterations = 5; static int folds = 10; static int printSentences = 3; @@ -106,7 +107,7 @@ Logger.getLogger(SparqlQuery.class).setLevel(Level.INFO); Files.mkdir(resultFolder); - + try { sparqlEndpoint = new SparqlEndpoint(new URL(sparqlEndpointURL), new ArrayList<String>(Arrays .asList(new String[] { graph })), new ArrayList<String>()); @@ -114,7 +115,8 @@ } catch (Exception e) { e.printStackTrace(); } - + + // folds = 2; // iterations = 2; long n = System.currentTimeMillis(); @@ -143,6 +145,12 @@ List<Examples> folds = new ExMakerCrossFolds(allExamples) .splitLeaveOneOut(TestIterativeLearning.folds); + + /*CLEANUP*/ + positives = null; + negatives = null; + allExamples = null; + // ExMakerCrossFolds.printFolds(folds); List<IteratedConfig> configs = getConfigs(); Table masterTable = new Table(); @@ -219,11 +227,11 @@ reducedExamples.splits = 2; // reducedExamples.adaptMaxRuntime=false; // reducedExamples.maxExecutionTime = 20; - reducedExamples.factor = 3.0d; + reducedExamples.factor = 6.0d; IteratedConfig fixRuntime = new IteratedConfig("fixRuntime_20s", iterations); fixRuntime.adaptMaxRuntime = false; - fixRuntime.maxExecutionTime = 20; + fixRuntime.maxExecutionTime = 40; IteratedConfig useLemma = new IteratedConfig("useLemma_false", iterations); useLemma.useDataHasValue = false; @@ -241,8 +249,8 @@ tmp.addPosTrain(allExamples.getPosTrain()); tmp.addNegTrain(allExamples.getNegTrain()); - ExMakerFixedSize fs = new ExMakerFixedSize(tmp); - Examples learn = fs.select(config.initialsplits, config.initialsplits); + Examples learn = new ExMakerFixedSize(tmp).select(config.initialsplits, config.initialsplits); + tmp = null; logger.debug("Total set \n" + allExamples); logger.debug("Initial training set \n" + learn); @@ -260,17 +268,6 @@ Monitor iterationTime = JamonMonitorLogger.getTimeMonitor(TestIterativeLearning.class, "iterationTime").start(); Monitor literationTime = config.start(logIterationTime, i); - // try { - // Thread.sleep(2000); - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // literationTime.stop(); - // System.out.println(literationTime); - // if (true) { - // System.exit(0); - // } /* LEARNING */ Monitor lLearningTime = config.start(logLearningTime, i); @@ -288,6 +285,11 @@ newTestRetrieved = Helper.intersection(allExamples.getTestExamples(), retrieved); newTrainRetrieved = Helper.intersection(allExamples.getTrainExamples(), retrieved); + SortedSet<String> posAsNegInformative = Helper.difference(allExamples.getPositiveExamples(), + retrieved); + + retrieved = null; + // logger.debug("Retrieved "+retrieved.size()+" sentences"); /* MASHING */ @@ -318,8 +320,7 @@ newlyFound.addPosTrain(discoveredPosInStore); newlyFound.addNegTrain(misclassifiedNegInStore); - SortedSet<String> posAsNegInformative = Helper.difference(allExamples.getPositiveExamples(), - retrieved); + logger.debug("Discovered: " + discoveredPosInStore.size() + " positive sentences in store (printing " + printSentences + "):"); @@ -331,8 +332,7 @@ + " positive sentences in store (printing " + printSentences + "):"); _getLabels(posAsNegInformative, printSentences); - fs = new ExMakerFixedSize(newlyFound); - newlyFound = fs.select(config.splits, config.splits); + newlyFound = new ExMakerFixedSize(newlyFound).select(config.splits, config.splits); learn.addPosTrain(newlyFound.getPosTrain()); learn.addNegTrain(newlyFound.getNegTrain()); @@ -463,6 +463,8 @@ result = la.getCurrentlyBestEvaluatedDescription(); logger.trace(PrefixMap.toKBSyntaxString(result.getDescription())); logger.trace(PrefixMap.toManchesterSyntaxString(result.getDescription())); + + ComponentManager.getInstance().freeAllComponents(); } catch (Exception e) { e.printStackTrace(); Added: trunk/src/dl-learner/org/dllearner/utilities/experiments/FinalizedMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/FinalizedMonitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/FinalizedMonitor.java 2010-02-16 17:44:27 UTC (rev 2048) @@ -0,0 +1,77 @@ +package org.dllearner.utilities.experiments; + +import java.io.Serializable; + +import com.jamonapi.MonKey; +import com.jamonapi.Monitor; + +public class FinalizedMonitor implements Serializable{ + private static final long serialVersionUID = 6617125369204663530L; + + final String header; + final String units; + + final double avg; + final double hits; + final double stdDev; + final double lastValue; + final double max; + final double min; + + + public FinalizedMonitor(Monitor m){ + header = (String)m.getMonKey().getValue(MonKey.LABEL_HEADER); + units = (String)m.getMonKey().getValue(MonKey.UNITS_HEADER); + avg = m.getAvg(); + hits = m.getHits(); + stdDev = m.getStdDev(); + lastValue = m.getLastValue(); + max = m.getMax(); + min = m.getMin(); + + + } + + + public String getHeader() { + return header; + } + + + public String getUnits() { + return units; + } + + + public double getAvg() { + return avg; + } + + + public double getHits() { + return hits; + } + + + public double getStdDev() { + return stdDev; + } + + + public double getLastValue() { + return lastValue; + } + + + public double getMax() { + return max; + } + + + public double getMin() { + return min; + } + + + +} Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/Table.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/Table.java 2010-02-16 14:15:17 UTC (rev 2047) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/Table.java 2010-02-16 17:44:27 UTC (rev 2048) @@ -1,6 +1,7 @@ package org.dllearner.utilities.experiments; import java.io.File; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -14,7 +15,9 @@ import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; -public class Table { +public class Table implements Serializable{ + private static final long serialVersionUID = -7191672899557577952L; + private static final Logger logger = Logger.getLogger(Table.class); boolean replaceCommaByPoints = true; @@ -58,13 +61,16 @@ t.addTableRowColumn(trc); } -// System.out.println(t.getLatexAsColumn(true)); + System.out.println(t.getLatexAsColumn(true)); + t.serialize("test.ser"); + Table n = deserialize("test.ser"); + System.out.println(n.getLatexAsColumn(true)); // System.out.println(t.getLatexAsRows()); // System.out.println(t.getGnuPlotAsColumn(true)); // System.out.println(t.getGnuPlotAsRows()); // System.out.println(MonProxyFactory.); - System.out.println( MonitorFactory.getReport()); - JamonMonitorLogger.writeHTMLReport("log/tiger.html"); +// System.out.println( MonitorFactory.getReport()); +// JamonMonitorLogger.writeHTMLReport("log/tiger.html"); } public void addTableRowColumn(List<TableRowColumn> trcs) { @@ -223,7 +229,16 @@ Files.createFile(new File(folder+fileprefix+"_LATEX_ROWS"), getLatexAsRows()); Files.createFile(new File(folder+fileprefix+"_LATEX_COLUMNS"), getLatexAsColumn()); Files.createFile(new File(folder+fileprefix+"_LATEX_COLUMNS_I"), getLatexAsColumn(true)); + + serialize(folder+fileprefix+".ser"); + } + public void serialize(String filename){ + Files.writeObjectToFile(this, new File(filename)); + } + public static Table deserialize(String filename){ + return (Table)Files.readObjectfromFile(new File(filename)); + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/TableRowColumn.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/TableRowColumn.java 2010-02-16 14:15:17 UTC (rev 2047) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/TableRowColumn.java 2010-02-16 17:44:27 UTC (rev 2048) @@ -1,12 +1,14 @@ package org.dllearner.utilities.experiments; +import java.io.Serializable; import java.text.DecimalFormat; import org.dllearner.utilities.JamonMonitorLogger; import com.jamonapi.Monitor; -public class TableRowColumn { +public class TableRowColumn implements Serializable{ + private static final long serialVersionUID = 1252924374566004540L; enum Formats { LATEX, GNUPLOT @@ -18,7 +20,8 @@ private final String label ; private final String experimentName; - Monitor[] monitors; +// final Monitor[] monitors; + final FinalizedMonitor[] monitors; boolean useStdDev = false; DecimalFormat dfGnuPlotDefault = new DecimalFormat("######0.00####"); @@ -31,7 +34,10 @@ // this.monitors = monitors; // } public TableRowColumn(Monitor[] monitors, String experimentName, String label) { - this.monitors = monitors; + this.monitors = new FinalizedMonitor[monitors.length]; + for (int i = 0; i < monitors.length; i++) { + this.monitors[i] = new FinalizedMonitor(monitors[i]); + } this.label = label; this.experimentName = experimentName; } @@ -110,8 +116,8 @@ return dfGnuPlotDefault.format(monitors[i].getAvg()) + ""; } - private String latexFormat(Monitor m, double value){ - if(m.getUnits().equals(JamonMonitorLogger.PERCENTAGE)){ + private String latexFormat(FinalizedMonitor monitors, double value){ + if(monitors.getUnits().equals(JamonMonitorLogger.PERCENTAGE)){ return dfPercentage.format(value); }else{ return dfLatexDefault.format(value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |