From: <lor...@us...> - 2009-12-22 10:47:44
|
Revision: 1949 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1949&view=rev Author: lorenz_b Date: 2009-12-22 10:47:34 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Some improvements in evaluation GUI. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -93,6 +93,7 @@ public EvaluationComputingScript(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException{ loadOntology(fileURL); computeSuggestions(); + computeGenFMeasureWithoutDefaultNegation(); computeWithApproximation(); saveResults(); } @@ -195,7 +196,7 @@ lp.getConfigurator().setType("superClass"); System.out.println("Learning superClass expressions"); } - for(int k = 0; k <= 4; k++){ + for(int k = 0; k <= 3; k++){ if(k == 0){ lp.getConfigurator().setAccuracyMethod("standard"); System.out.println("Using accuracy method: standard"); @@ -312,8 +313,118 @@ } cm.freeComponent(reasoner); } + cm.freeComponent(reasoner); + cm.freeComponent(lp); + cm.freeComponent(celoe); } + private void computeGenFMeasureWithoutDefaultNegation() throws ComponentInitException, MalformedURLException, + LearningProblemUnsupportedException { + ComponentManager cm = ComponentManager.getInstance(); + TreeSet<EvaluatedDescriptionClass> suggestions; + for (int i = 0; i <= 1; i++) { + if (i == 0) { + reasoner = null; + reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + System.out.println("using OWLAPI-Reasoner"); + } else { + reasoner = null; + reasoner = cm.reasoner(FastInstanceChecker.class, ks); + ((FastInstanceChecker) reasoner).getConfigurator().setDefaultNegation(false); + System.out.println("using FastInstanceChecker"); + } + + reasoner.init(); + baseURI = reasoner.getBaseURI(); + prefixes = reasoner.getPrefixes(); + + // loop through all classes + Set<NamedClass> classes = new TreeSet<NamedClass>(reasoner.getNamedClasses()); + classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); + // reduce number of classes for testing purposes + // shrinkSet(classes, 20); + for (NamedClass nc : classes) { + // check whether the class has sufficient instances + int instanceCount = reasoner.getIndividuals(nc).size(); + if (instanceCount < minInstanceCount) { + System.out.println("class " + nc.toManchesterSyntaxString(baseURI, prefixes) + " has only " + + instanceCount + " instances (minimum: " + minInstanceCount + ") - skipping"); + } else { + System.out.println("\nlearning axioms for class " + nc.toManchesterSyntaxString(baseURI, prefixes) + + " with " + instanceCount + " instances"); + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); + lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + for (int j = 0; j <= 1; j++) { + if (j == 0) { + lp.getConfigurator().setType("equivalence"); + System.out.println("Learning equivalentClass expressions"); + } else { + lp.getConfigurator().setType("superClass"); + System.out.println("Learning superClass expressions"); + } + lp.getConfigurator().setAccuracyMethod("generalised_fmeasure"); + System.out.println("Using accuracy method: Generalised F-Measure"); + lp.getConfigurator().setUseApproximations(useApproximations); + lp.init(); + CELOE celoe = cm.learningAlgorithm(CELOE.class, lp, reasoner); + CELOEConfigurator cf = celoe.getConfigurator(); + cf.setUseNegation(false); + cf.setValueFrequencyThreshold(3); + cf.setMaxExecutionTimeInSeconds(algorithmRuntimeInSeconds); + cf.setNoisePercentage(noisePercent); + cf.setMaxNrOfResults(10); + celoe.init(); + + celoe.start(); + + // test whether a solution above the threshold was found + EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); + double bestAcc = best.getAccuracy(); + + if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { + System.out + .println("The algorithm did not find a suggestion with an accuracy above the threshold of " + + (100 * minAccuracy) + + "% or the best description is not appropriate. (The best one was \"" + + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) + + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); + suggestions = new TreeSet<EvaluatedDescriptionClass>(); + } else { + + suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe + .getCurrentlyBestEvaluatedDescriptions(); + } + List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( + suggestions.descendingSet()); + + if (i == 0) { + if (j == 0) { + owlEquivalenceGenFMeasureMap.put(nc, suggestionsList); + } else { + owlSuperGenFMeasureMap.put(nc, suggestionsList); + } + + } else { + if (j == 0) { + fastEquivalenceGenFMeasureMap.put(nc, suggestionsList); + } else { + fastSuperGenFMeasureMap.put(nc, suggestionsList); + } + + } + + } + cm.freeComponent(celoe); + cm.freeComponent(lp); + } + } + cm.freeComponent(reasoner); + } + cm.freeComponent(reasoner); + cm.freeComponent(lp); + cm.freeComponent(celoe); + } + private void computeWithApproximation() throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); TreeSet<EvaluatedDescriptionClass> suggestions; @@ -390,7 +501,7 @@ } } - + cm.freeAllComponents(); } /** Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -3,8 +3,10 @@ import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; +import java.awt.Component; import java.awt.GridLayout; import java.awt.Insets; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -23,11 +25,13 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JWindow; @@ -90,7 +94,7 @@ private int currentClassIndex = 0; private boolean showingEquivalentSuggestions = false; - private boolean showingMultiTables = true; + private boolean showingMultiTables = false; private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceStandardMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); @@ -133,8 +137,10 @@ createUI(); createCoverageWindow(); classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + graphPanel2.setConcept(classesTable.getSelectedClass(currentClassIndex)); showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); - cardLayout.last(cardPanel); + cardLayout.first(cardPanel); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); @@ -148,6 +154,7 @@ classesTable = new MarkableClassesTable(); classesTable.addClasses(new TreeSet<NamedClass>(owlEquivalenceStandardMap.keySet())); JScrollPane classesScroll = new JScrollPane(classesTable); + classesTable.addMouseMotionListener(this); add(classesScroll, BorderLayout.WEST); JScrollPane suggestionsScroll = new JScrollPane(createMainPanel()); @@ -165,6 +172,8 @@ buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); + addMouseMotionListener(this); + } private JPanel createMainPanel(){ @@ -172,6 +181,7 @@ messageTablesPanel.setLayout(new BorderLayout()); messageLabel = new JLabel(); + messageLabel.addMouseMotionListener(this); messageTablesPanel.add(messageLabel, BorderLayout.NORTH); cardPanel = new JPanel(); @@ -242,8 +252,8 @@ panel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JCheckBox box = new JCheckBox(); panel.add(table, BorderLayout.CENTER); - panel.add(box, BorderLayout.EAST); - +// panel.add(box, BorderLayout.EAST); + panel.add(new RatingPanel(), BorderLayout.EAST); return panel; } @@ -304,7 +314,7 @@ graphPanel2 = new GraphicalCoveragePanel(""); coverageWindow.add(graphPanel2); coverageWindow.pack(); - coverageWindow.setLocationRelativeTo(classesTable); +// coverageWindow.setLocationRelativeTo(classesTable); } @SuppressWarnings("unchecked") @@ -366,17 +376,30 @@ coverageWindow.setVisible(visible); } + private void setCoverageLocationRelativeTo(Component component){ + Component parent = component.getParent(); + Point componentLocation = component.getLocationOnScreen(); + Point p; + if(componentLocation.getX() < parent.getSize().width/2){ + p = new Point((int)(componentLocation.getX() + parent.getSize().width/2 + coverageWindow.getSize().getWidth()/2),componentLocation.y); + } else { + p = new Point((int)(componentLocation.getX() - parent.getSize().width/2 - coverageWindow.getSize().getWidth()/2),componentLocation.y); + } + + coverageWindow.setLocation(p); + } + @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("next")){ NamedClass nc = classesTable.getSelectedClass(currentClassIndex); if(showingMultiTables && showingEquivalentSuggestions){ + showSuperSuggestions(nc); showSingleTable(); } else if(!showingMultiTables && showingEquivalentSuggestions){ - showSuperSuggestions(nc); showMultiTables(); - } else if(showingMultiTables && !showingEquivalentSuggestions){ - showSingleTable(); + } else if(!showingMultiTables && !showingEquivalentSuggestions){ + showMultiTables(); if(currentClassIndex + 1 >= owlEquivalenceStandardMap.keySet().size()){ nextFinishButton.setText("Finish"); nextFinishButton.setActionCommand("finish"); @@ -385,8 +408,10 @@ currentClassIndex++; classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); - showMultiTables(); + showSingleTable(); } } else if(e.getActionCommand().equals("finish")){ @@ -465,6 +490,7 @@ EvaluatedDescriptionClass ec = result.getValueAtRow(row); graphPanel2.clear(); graphPanel2.setNewClassDescription(ec); + setCoverageLocationRelativeTo(result); showCoveragePanel(true); } else { @@ -476,7 +502,59 @@ } + + class RatingPanel extends JPanel{ + + /** + * + */ + private static final long serialVersionUID = -111227945780885551L; + private JRadioButton rb1 = new JRadioButton("1"); + private JRadioButton rb2 = new JRadioButton("2");; + private JRadioButton rb3 = new JRadioButton("3");; + private JRadioButton rb4 = new JRadioButton("4");; + private JRadioButton rb5 = new JRadioButton("5");; + private ButtonGroup bg; + public RatingPanel(){ + setLayout(new GridLayout(5,1)); + bg = new ButtonGroup(); + add(rb5); + add(rb4); + add(rb3); + add(rb2); + add(rb1); + bg.add(rb1); + bg.add(rb2); + bg.add(rb3); + bg.add(rb4); + bg.add(rb5); + rb1.setSelected(true); + } + + public int getSelectedValue(){ + if(rb1.isSelected()){ + return 1; + } else if(rb2.isSelected()){ + return 2; + } else if(rb3.isSelected()){ + return 3; + } else if(rb4.isSelected()){ + return 4; + } else { + return 5; + } + } + + public void clearSelection(){ + rb1.setSelected(true); + } + + } + + } + + Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -35,6 +35,7 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.ui.rendering.ManchesterSyntaxRenderer; @@ -68,6 +69,8 @@ private EvaluatedDescription eval; + private NamedClass concept; + private String conceptNew; private final Vector<IndividualPoint> posCovIndVector; private final Vector<IndividualPoint> posNotCovIndVector; @@ -92,6 +95,9 @@ private final Color darkGreen; private final Color darkRed; // private int notCoveredInd; + + private String coverageString = ""; + private String coversAdditionalString = ""; /** @@ -110,7 +116,7 @@ public GraphicalCoveragePanel( String concept) { - this.setPreferredSize(new Dimension(540, 260)); + this.setPreferredSize(new Dimension(640, 260)); // this.repaint(); darkGreen = new Color(0, 100, 0); @@ -142,9 +148,12 @@ AlphaComposite ac = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f); g2D.setColor(Color.BLACK); - if(OREManager.getInstance().getCurrentClass2Learn() != null){ - g2D.drawString(ManchesterSyntaxRenderer.renderSimple(OREManager.getInstance().getCurrentClass2Learn()) + if(concept == null && OREManager.getInstance().getCurrentClass2Learn() != null){ + g2D.drawString(ManchesterSyntaxRenderer.renderSimple(OREManager.getInstance().getCurrentClass2Learn()) , 320, 10); + } else if(concept!= null){ + g2D.drawString(concept.getName(), 320, 10); + } // g2D.setColor(Color.ORANGE); // g2D.fillOval(310, 20, 9, 9); @@ -189,6 +198,13 @@ p = p + 20; g2D.drawString("(potential problem)", 320, p); + p = p +20; + g2D.drawString(coverageString , 320, p); + p = p +20; + g2D.drawString(coversAdditionalString , 320, p); + + + g2D.setColor(Color.YELLOW); g2D.fill(oldConcept); g2D.fillOval(310, 0, 9, 9); @@ -469,17 +485,30 @@ } // computeGraphics(); computeIndividualPoints(); - + int coveredInstanceCount = ((EvaluatedDescriptionClass) eval).getCoveredInstances().size(); + int instanceCount = coveredInstanceCount + ((EvaluatedDescriptionClass) eval).getNotCoveredInstances().size(); + int coverage = (int)(((EvaluatedDescriptionClass) eval).getCoverage() * 100); + int additionalCount = ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size(); + coverageString = "Covers " + coveredInstanceCount + " of " + instanceCount + + "(" + coverage + "%) of all instances"; + coversAdditionalString = "Covers " + additionalCount + " additional instances"; getParent().repaint(); } + public void setConcept(NamedClass nc){ + concept = nc; + getParent().repaint(); + } + public void clear(){ newConcept = new Ellipse2D.Double(0, 0, 0, 0); posCovIndVector.clear(); posNotCovIndVector.clear(); additionalIndividuals.clear(); points.clear(); + coverageString = ""; + coversAdditionalString = ""; getParent().repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |