Package statechum.analysis.learning.observers

Examples of statechum.analysis.learning.observers.QuestionAndRestartCounter


    ErlangOracleVisualiser viz = new ErlangOracleVisualiser();
    ErlangOracleLearner innerLearner = createLearner(viz,tracesFile);
    innerLearner.addObserver(viz);
    innerLearner.setGraphNameSuffix(tracesFile);
    innerLearner.getTentativeAutomaton().getLayoutOptions().showNegatives = false;
    QuestionAndRestartCounter counter = new QuestionAndRestartCounter(innerLearner);
   
    LearnerGraph result = counter.learnMachine();
   
    if (innerLearner.getTentativeAutomaton().config.getErlangDisplayStatistics())
    {
      System.out.println("STATISTICS: "+counter.getQuestionCounter()+" questions, "+counter.getRestarts()+" restarts");
    }
   
    return result;
  }
View Full Code Here


        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      precRec.crossWith(engine);PosNegPrecisionRecall prNeg = precRec.getPosNegPrecisionRecallNum();
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

    ErlangOracleVisualiser viz = new ErlangOracleVisualiser();
    ErlangOracleLearner innerLearner = createLearner(viz,tracesFile);
    innerLearner.addObserver(viz);
    innerLearner.setGraphNameSuffix(tracesFile);
    innerLearner.getTentativeAutomaton().getLayoutOptions().showNegatives = false;
    QuestionAndRestartCounter counter = new QuestionAndRestartCounter(innerLearner);
   
    LearnerGraph result = counter.learnMachine();
   
    if (innerLearner.getTentativeAutomaton().config.getErlangDisplayStatistics())
    {
      System.out.println("STATISTICS: "+counter.getQuestionCounter()+" questions, "+counter.getRestarts()+" restarts");
    }
   
    return result;
  }
View Full Code Here

        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      precRec.crossWith(engine);PosNegPrecisionRecall prNeg = precRec.getPosNegPrecisionRecallNum();
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      precRec.crossWith(engine);PosNegPrecisionRecall prNeg = precRec.getPosNegPrecisionRecallNum();
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePath(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph);
      PosNegPrecisionRecall ptaPR = precRec.crossWith(sMinus);
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      PosNegPrecisionRecall prNeg = precRec.crossWith(engine);
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      precRec.crossWith(engine);PosNegPrecisionRecall prNeg = precRec.getPosNegPrecisionRecallNum();
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

    ErlangOracleVisualiser viz = new ErlangOracleVisualiser();
    ErlangOracleLearner innerLearner = createLearner(viz,tracesFile);
    innerLearner.addObserver(viz);
    innerLearner.setGraphNameSuffix(new File(tracesFile).getName());
    innerLearner.getTentativeAutomaton().getLayoutOptions().showNegatives = false;
    QuestionAndRestartCounter counter = new QuestionAndRestartCounter(innerLearner);
   
    LearnerGraph result = counter.learnMachine();
    if (innerLearner.getTentativeAutomaton().config.getErlangDisplayStatistics())
    {
      System.out.println("STATISTICS: "+counter.getQuestionCounter()+" questions, "+counter.getRestarts()+" restarts");
    }
   
    return result;
  }
View Full Code Here

        {
          questionNumber.addAndGet(1);
          return new Pair<Integer,String>(graph.paths.tracePathPrefixClosed(question),null);
        }
      };
      QuestionAndRestartCounter l = new QuestionAndRestartCounter(learner);
      sPlus = rpg.getExtraSequences(percent/10-1);sMinus = rpg.getAllSequences(percent/10-1);

      LearnerGraph learnt = learn(l,sMinus);
      PTA_computePrecisionRecall precRec = new PTA_computePrecisionRecall(learnt);
      PTASequenceEngine engine = new PTA_FSMStructure(graph,null);
      precRec.crossWith(sMinus);PosNegPrecisionRecall ptaPR = precRec.getPosNegPrecisionRecallNum();
      SequenceSet ptaTestSet = engine.new SequenceSet();ptaTestSet.setIdentity();
      ptaTestSet = ptaTestSet.cross(graph.wmethod.getFullTestSet(1));
      precRec.crossWith(engine);PosNegPrecisionRecall prNeg = precRec.getPosNegPrecisionRecallNum();
     
      assert questionNumber.get() == l.getQuestionCounter();
     
      // Column 0 is the name of the learner.
      // Columns 3 and 4
      result = result+prNeg.getPrecision()+FS+prNeg.getRecall();
     
      result = result + FS + questionNumber+ FS + // 5
        // Columns 6 and 7
        ptaPR.getPrecision()  + FS + ptaPR.getRecall() + FS +
        "size:"+size+FS+ // 8
        "chunks: "+(100/percentPerChunk)+FS+ // 9
        "per chunk:"+nrPerChunk + // 10
        FS+percent+"%"+FS+ // 11
        "+:"+sPlus.getData().size()+FS+// 12
        "-:"+sMinus.getData(PTASequenceEngine.truePred).size(); // 13
      try
      {
        result = result + FS+"L"+// 14
        // 15 and 16
          FS+Linear.getSimilarity(graph,learnt, false, 1)+FS+Linear.getSimilarity(graph, learnt, true, 1);
        // 17
        result = result + FS + Linear.getSimilarityGD(graph,learnt, 1).getCompressionRate();// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
        // 18
        result = result + FS + Linear.getSimilarityGD_details(graph,learnt, 1);// + graph.linear.getSimilarityWithNegatives(learned, 1, GDLearnerGraph.DDRH_default.class);
      }
      catch(IllegalArgumentException ex)
      {
        StringWriter wr = new StringWriter();ex.printStackTrace(new PrintWriter(wr));
        result = result+"\n"+"exception from linear: "+ex+
          " on graph with "+learnt.getStateNumber()+" and "+learnt.getStateNumber()+" transitions" +
          "\n"+wr.getBuffer().toString();
      }
     
      // 19 and 20
      result = result + FS + graph.paths.getExtentOfCompleteness() + FS + learnt.paths.getExtentOfCompleteness() + FS +
        l.getRestarts(); // 21
    }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.observers.QuestionAndRestartCounter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.