Examples of SquareBagPlot


Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

 
  @Test
  public void testDrawBagPlotWithDiagonal1()
  {
    final String X="axisX", Y="axisY";
    final SquareBagPlot g=new SquareBagPlot(X,Y, new File("someName"),2,40,true);
    g.add(5.5,34.);g.add(5.7,32.);g.add(7.8,31.);
    Assert.assertEquals(Arrays.asList(new String[]{"bplot<-compute.bagplot(c(5.5,5.7,7.8),c(34.0,32.0,31.0))","plot(bplot,xlim=c(2.0,40.0), ylim=c(2.0,40.0),xlab=\"axisX\",ylab=\"axisY\")", "abline(0,1)"}),
        g.getDrawingCommand());
  }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

  }
  @Test
  public void testDrawBagPlotWithDiagonal2()
  {
    final String X="axisX", Y="axisY";
    final SquareBagPlot g=new SquareBagPlot(X,Y, new File("someName"),2,40,false);
    g.add(5.5,34.);g.add(5.7,32.);g.add(7.8,31.);
    Assert.assertEquals(Arrays.asList(new String[]{"bplot<-compute.bagplot(c(5.5,5.7,7.8),c(34.0,32.0,31.0))","plot(bplot,xlim=c(2.0,40.0), ylim=c(2.0,40.0),xlab=\"axisX\",ylab=\"axisY\")"}),
        g.getDrawingCommand());
  }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

  }
  @Test
  public void testDrawBagPlotWithDiagonal3()
  {
    final String X="axisX", Y="axisY";
    final SquareBagPlot g=new SquareBagPlot(X,Y, new File("someName"),2,40,true);
    g.setLimit(30000);
    g.add(5.5,34.);g.add(5.7,32.);g.add(7.8,31.);
    Assert.assertEquals(Arrays.asList(new String[]{"bplot<-compute.bagplot(c(5.5,5.7,7.8),c(34.0,32.0,31.0),approx.limit=30000)","plot(bplot,xlim=c(2.0,40.0), ylim=c(2.0,40.0),xlab=\"axisX\",ylab=\"axisY\")", "abline(0,1)"}),
        g.getDrawingCommand());
  }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

                ";onlyPositives="+onlyPositives+";selectingRed="+selectingRed+";classifierToBlockAllMergers="+classifierToBlockAllMergers+";zeroScoringAsRed="+zeroScoringAsRed+";lengthMultiplier="+lengthMultiplier+";";

            final int totalTaskNumber = traceQuantity;
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score"+selection.substring(0, 80)+".pdf"));
            final RBoxPlot<String> gr_QualityForNumberOfTraces = new RBoxPlot<String>("traces","%%",new File("quality_traces"+selection.substring(0, 80)+".pdf"));
            SquareBagPlot gr_NewToOrig = new SquareBagPlot("orig score","score with learnt selection",new File("new_to_orig"+selection.substring(0, 80)+".pdf"),0,1,true);
            final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();
            try
            {
              int numberOfTasks = 0;
              for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
                for(int sample=0;sample<samplesPerFSM;++sample)
                {
                  LearnerRunner learnerRunner = new LearnerRunner(states,sample,totalTaskNumber+numberOfTasks,traceQuantity, config, converter);
                  learnerRunner.setPickUniqueFromInitial(useUnique);
                  learnerRunner.setOnlyUsePositives(onlyPositives);learnerRunner.setLengthMultiplier(lengthMultiplier);
                  learnerRunner.setSelectionID(selection+"_states"+states+"_sample"+sample);
                  runner.submit(learnerRunner);
                  ++numberOfTasks;
                }
              ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for "+selection, numberOfTasks);
              for(int count=0;count < numberOfTasks;++count)
              {
                ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
                if (gr_NewToOrig != null)
                {
                  for(SampleData sample:result.samples)
                    gr_NewToOrig.add(sample.referenceLearner.getValue(),sample.actualLearner.getValue());
                }
               
                for(SampleData sample:result.samples)
                  if (sample.referenceLearner.getValue() > 0)
                    gr_QualityForNumberOfTraces.add(traceQuantity+"",sample.actualLearner.getValue()/sample.referenceLearner.getValue());
                progress.next();
              }
              if (gr_PairQuality != null)
              {
                synchronized(pairQualityCounter)
                {
                  updateGraph(gr_PairQuality,pairQualityCounter);
                  //gr_PairQuality.drawInteractive(gr);
                  //gr_NewToOrig.drawInteractive(gr);
                  //if (gr_QualityForNumberOfTraces.size() > 0)
                  //  gr_QualityForNumberOfTraces.drawInteractive(gr);
                }
              }
              if (gr_PairQuality != null) gr_PairQuality.drawPdf(gr);
            }
            catch(Exception ex)
            {
              IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
              if (executorService != null) { executorService.shutdownNow();executorService = null; }
              throw e;
            }
            if (gr_NewToOrig != null) gr_NewToOrig.drawPdf(gr);
            if (gr_QualityForNumberOfTraces != null) gr_QualityForNumberOfTraces.drawPdf(gr);
          }
        }
      }
    if (executorService != null) { executorService.shutdown();executorService = null; }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

      }
    if (gr_BCRForDifferentLearners != null) gr_BCRForDifferentLearners.drawPdf(gr);if (gr_StructuralForDifferentLearners != null) gr_StructuralForDifferentLearners.drawPdf(gr);

    // Inference from a few traces
    final int traceQuantityToUse = traceQuantity;
    SquareBagPlot gr_StructuralDiff = new SquareBagPlot("Structural score, EDSM,>=2","Structural Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_structuraldiff.pdf"),0,1,true);
    SquareBagPlot gr_BCR = new SquareBagPlot("BCR, EDSM,>=2","BCR, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr.pdf"),0.5,1,true);
    RBagPlot gr_BCR_singletons = new RBagPlot("%% states identified by singletons","BCR Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr_singletons.pdf"));
    RBagPlot gr_BCR_states = new RBagPlot("number of states in reference","BCR Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr_numberofstates.pdf"));
    ScatterPlot gr_ImprovementPerState = new ScatterPlot("State number", "BCR, improvement",new File(branch+"_"+(traceQuantityToUse/2)+"_bcr_statenumber.pdf"));
    for(final boolean onlyPositives:new boolean[]{true})
      for(final double alphabetMultiplier:new double[]{alphabetMultiplierMax})
      {
            final int totalTaskNumber = traceQuantityToUse;
            try
            {
              int numberOfTasks = 0;
              for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
                for(int sample=0;sample<samplesPerFSM;++sample)
                {
                  LearnerRunner learnerRunner = new LearnerRunner(states,sample,totalTaskNumber+numberOfTasks,traceQuantityToUse, config, converter);
                  learnerRunner.setOnlyUsePositives(onlyPositives);
                  learnerRunner.setAlphabetMultiplier(alphabetMultiplier);
                  learnerRunner.setTraceLengthMultiplier(traceLengthMultiplierMax);learnerRunner.setChunkLen(chunkSize);
                  learnerRunner.setSelectionID(branch+"_states"+states+"_sample"+sample);
                  runner.submit(learnerRunner);
                  ++numberOfTasks;
                }
              ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for learning whole graphs", numberOfTasks);
              for(int count=0;count < numberOfTasks;++count)
              {
                ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
                for(SampleData sample:result.samples)
                  gr_StructuralDiff.add(sample.referenceLearner.differenceStructural.getValue(),sample.actualLearner.differenceStructural.getValue());
             
                for(SampleData sample:result.samples)
                {
                  gr_BCR.add(sample.referenceLearner.differenceBCR.getValue(),sample.actualLearner.differenceBCR.getValue());
                  gr_BCR_singletons.add((double)sample.fractionOfStatesIdentifiedBySingletons,sample.actualLearner.differenceBCR.getValue());
                  gr_BCR_states.add((double)sample.stateNumber,sample.actualLearner.differenceBCR.getValue());
                  if (sample.referenceLearner.differenceBCR.getValue() > 0)
                  gr_ImprovementPerState.add((double)sample.stateNumber,sample.actualLearner.differenceBCR.getValue()/sample.referenceLearner.differenceBCR.getValue());
                }
                progress.next();
              }
              gr_StructuralDiff.drawInteractive(gr);gr_BCR.drawInteractive(gr);gr_BCR_singletons.drawInteractive(gr);gr_BCR_states.drawInteractive(gr);gr_ImprovementPerState.drawInteractive(gr);
            }
            catch(Exception ex)
            {
              IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
              if (executorService != null) { executorService.shutdownNow();executorService = null; }
              throw e;
            }
      }
      if (gr_StructuralDiff != null) gr_StructuralDiff.drawPdf(gr);
      if (gr_BCR != null) gr_BCR.drawPdf(gr);
      if (gr_BCR_singletons != null) gr_BCR_singletons.drawPdf(gr);
      if (gr_BCR_states != null) gr_BCR_states.drawPdf(gr);
      if (gr_ImprovementPerState != null) gr_ImprovementPerState.drawPdf(gr);

    final RBoxPlot<String> gr_BCRImprovementForDifferentAlphabetSize = new RBoxPlot<String>("alphabet multiplier","improvement, BCR",new File(branch+"BCR_vs_alphabet.pdf"));
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

                ";selectingRed="+selectingRed+";classifierToBlockAllMergers="+classifierToBlockAllMergers+";zeroScoringAsRed="+zeroScoringAsRed+";traceQuantity="+traceQuantity+";lengthMultiplier="+lengthMultiplier+";trainingDataMultiplier="+trainingDataMultiplier+";";

            final int totalTaskNumber = traceQuantity;
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score"+selection+".pdf"));
            final RBoxPlot<String> gr_QualityForNumberOfTraces = new RBoxPlot<String>("traces","%%",new File("quality_traces"+selection+".pdf"));
            SquareBagPlot gr_NewToOrig = new SquareBagPlot("orig score","score with learnt selection",new File("new_to_orig"+selection+".pdf"),0,1,true);
            final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();
            try
            {
              int numberOfTasks = 0;
              for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
                for(int sample=0;sample<samplesPerFSM;++sample)
                {
                  LearnerRunner learnerRunner = new LearnerRunner(dataCollector,states,sample,totalTaskNumber+numberOfTasks,traceQuantity, config, converter)
                  {
                    @Override
                    public LearnerThatCanClassifyPairs createLearner(LearnerEvaluationConfiguration evalCnf,LearnerGraph argReferenceGraph,@SuppressWarnings("unused") WekaDataCollector argDataCollector,  LearnerGraph argInitialPTA)
                    {
                      LearnerThatUsesWekaResults l = new LearnerThatUsesWekaResults(ifDepth,evalCnf,argReferenceGraph,classifier,argInitialPTA);
                      if (gr_PairQuality != null)
                        l.setPairQualityCounter(pairQualityCounter);
                     
                      l.setUseClassifierForRed(selectingRed);l.setUseClassifierToChooseNextRed(classifierToBlockAllMergers);
                      l.setBlacklistZeroScoringPairs(zeroScoringAsRed);
                      l.setThreshold(threshold);
                      return l;
                    }
                   
                  };
                  learnerRunner.setPickUniqueFromInitial(useUnique);learnerRunner.setEvaluateAlsoUsingReferenceLearner(true);
                  learnerRunner.setOnlyUsePositives(onlyPositives);learnerRunner.setIfdepth(ifDepth);learnerRunner.setLengthMultiplier(lengthMultiplier);
                  learnerRunner.setSelectionID(selection+"_states"+states+"_sample"+sample);
                  runner.submit(learnerRunner);
                  ++numberOfTasks;
                }
              ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for "+selection, numberOfTasks);
              for(int count=0;count < numberOfTasks;++count)
              {
                ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
                if (gr_NewToOrig != null)
                {
                  for(SampleData sample:result.samples)
                    gr_NewToOrig.add(sample.referenceLearner.getValue(),sample.actualLearner.getValue());
                }
               
                for(SampleData sample:result.samples)
                  if (sample.referenceLearner.getValue() > 0)
                    gr_QualityForNumberOfTraces.add(traceQuantity+"",sample.actualLearner.getValue()/sample.referenceLearner.getValue());
                progress.next();
              }
              if (gr_PairQuality != null)
              {
                synchronized(pairQualityCounter)
                {
                  updateGraph(gr_PairQuality,pairQualityCounter);
                  //gr_PairQuality.drawInteractive(gr);
                  //gr_NewToOrig.drawInteractive(gr);
                  //if (gr_QualityForNumberOfTraces.size() > 0)
                  //  gr_QualityForNumberOfTraces.drawInteractive(gr);
                }
              }
              if (gr_PairQuality != null) gr_PairQuality.drawPdf(gr);
            }
            catch(Exception ex)
            {
              IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
              if (executorService != null) { executorService.shutdownNow();executorService = null; }
              throw e;
            }
            if (gr_NewToOrig != null) gr_NewToOrig.drawPdf(gr);
            if (gr_QualityForNumberOfTraces != null) gr_QualityForNumberOfTraces.drawPdf(gr);
          }
        }
      }
    if (executorService != null) { executorService.shutdown();executorService = null; }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

      gr_TimeW_StatesLevel = new RBoxPlot<Pair<Integer,Integer>>("Mutation level,States","Time taken by W",new File("TimeW_statesmutations.pdf")),
      gr_TimeRand_StatesLevel = new RBoxPlot<Pair<Integer,Integer>>("Mutation level,States","Time taken by Random",new File("TimeRand_statesmutations.pdf"));
    RBagPlot gr_Diff_MutationsToOriginal = new RBagPlot("Mutations/Original Edges","patch size",new File("diff_mutations.pdf")),
      gr_Diff_W = new RBagPlot("W f-measure","patch size",new File("diff_w.pdf")),
      gr_Diff_MismatchedPairs = new RBagPlot("Mismatched key pairs","Diff/Mutations",new File("diff_pairs.pdf"));
    SquareBagPlot gr_F_measures = new SquareBagPlot("W f-measure", "Linear f-measure", new File("f_measure_w_linear.pdf"),0,1,true),
      gr_Rand_W = new SquareBagPlot("W f-measure","Rand f-measure",new File("f_measure_rand_W.pdf"),0,1,true);
    int approxLimit = 3000;
    gr_Diff_MutationsToOriginal.setLimit(approxLimit);
    gr_Diff_W.setLimit(approxLimit);
    gr_Rand_W.setLimit(approxLimit);
    gr_Diff_MismatchedPairs.setLimit(approxLimit);
    gr_F_measures.setLimit(approxLimit);
   
    gr_Diff_MutationsToOriginal.setXboundaries(0.,0.5);
    gr_Diff_MutationsToOriginal.setYboundaries(1.,1.15);

    // Useful values of the threshold
    double pairThreshold[] = new double[]{0.2,0.4,0.6,0.8,0.95},lowToHigh[] = new double[]{0.2,0.4,0.6,0.8,0.95};
    RBoxPlot<Double> gr_Diff_threshold = new RBoxPlot<Double>("Threshold values, Low to High ratio = 0.5","ratio of patch size to mutations",new File("diff_threshold.pdf")),
      gr_Diff_lowtohigh = new RBoxPlot<Double>("Low to High values, threshold ratio = 0.7","ratio of patch size to mutations",new File("diff_lowtohigh.pdf"));
    RBoxPlot<Pair<Double,Double>> gr_Diff_thresholdslowhigh = new RBoxPlot<Pair<Double,Double>>("Low to High ratio, Threshold","ratio of patch size to mutations",new File("diff_thresholdlowhigh.pdf"));
    RBoxPlot<Double> gr_Diff_k = new RBoxPlot<Double>("attenuation factor","ratio of patch size to mutations",new File("diff_attenuation.pdf"));
   
    for(int graphComplexity=0;graphComplexity < graphComplexityMax;graphComplexity++)
    {
      int states=initStates+graphComplexity*50;
      int alphabet = states/2;
     
      MachineGenerator mg = new MachineGenerator(states, 40, states/10);
      int mutationsPerStage = (states/2) / 2;
      //System.out.print("\n"+states+": ");
      ProgressIndicator progress = new ProgressIndicator(""+states, mutationStages*experimentsPerMutationCategory);
      for(int mutationStage = 0;mutationStage<mutationStages;mutationStage++)
      {
        for(int experiment=0;experiment<experimentsPerMutationCategory;experiment++)
        {
          ExperimentResult outcome = new ExperimentResult();
          while(!outcome.experimentValid)
          {
            int mutations = mutationsPerStage * (mutationStage+1);
            LearnerGraphND origGraph = mg.nextMachine(alphabet, experiment,config,converter);
            GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator = new GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(origGraph,r);
            mutator.mutate(mutations);
            LearnerGraphND origAfterRenaming = new LearnerGraphND(origGraph.config);
            Map<CmpVertex,CmpVertex> origToNew = copyStatesAndTransitions(origGraph,origAfterRenaming);
            LearnerGraphND mutated = (LearnerGraphND)mutator.getMutated();
            Set<Transition> appliedMutations = new HashSet<Transition>();
            for(Transition tr:mutator.getDiff())
            {
              CmpVertex renamedFrom = origToNew.get(tr.getFrom());if (renamedFrom == null) renamedFrom = tr.getFrom();
              CmpVertex renamedTo = origToNew.get(tr.getTo());if (renamedTo == null) renamedTo = tr.getTo();
              appliedMutations.add(new Transition(renamedFrom,renamedTo,tr.getLabel()));
            }
           
            final double perfectLowToHigh=0.7,perfectThreshold=0.5;
           
            // These experiments are only run for the maximal number of states
            if (graphComplexity == graphComplexityMax-1)
            {
              for(double k:new double[]{0,.2,.4,.6,.8,.95})
              {
                config.setAttenuationK(k);
                config.setGdKeyPairThreshold(0.5);
                config.setGdLowToHighRatio(perfectLowToHigh);
                config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
                linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
               
                gr_Diff_k.add(k, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
               
              }

              for(double threshold:new double[]{0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95})
              {
                config.setGdKeyPairThreshold(threshold);
                config.setGdLowToHighRatio(perfectLowToHigh);
                config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
                linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
               
                gr_Diff_threshold.add(threshold, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
              }

              for(double lowtohigh:new double[]{0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95})
              {
                config.setGdKeyPairThreshold(perfectThreshold);
                config.setGdLowToHighRatio(lowtohigh);
                config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
                linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
               
                gr_Diff_lowtohigh.add(lowtohigh, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
              }
             
             
              for(int i=0;i<pairThreshold.length;++i)
                for(double ratio:lowToHigh)
                {
                  config.setGdKeyPairThreshold(pairThreshold[i]);
                  config.setGdLowToHighRatio(ratio);
                  config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
                  linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
                 
                  gr_Diff_thresholdslowhigh.add(new Pair<Double,Double>(ratio,pairThreshold[i]), outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
                }
            }
            config.setAttenuationK(0.5);
            config.setGdKeyPairThreshold(perfectThreshold);
            config.setGdLowToHighRatio(perfectLowToHigh);
            config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
            linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
           
            if (!skip)
            {
              LearnerGraph fromDet = null, toDet = null;
              try {
                fromDet = mergeAndDeterminize(origAfterRenaming);
                toDet = mergeAndDeterminize(mutated);
              } catch (IncompatibleStatesException e) {
                Helper.throwUnchecked("failed to build a deterministic graph from a nondet one", e);
              }
              languageDiff(fromDet,toDet,states, graphComplexity,outcome);
            }
            outcome.experimentValid = true;
            progress.next();
            gr_Diff_States.add(states, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
            gr_W_States.add(states,outcome.getValue(DOUBLE_V.ACCURACY_W));
            Pair<Integer,Integer> mutations_states = new Pair<Integer,Integer>(mutationStage+1,states);
            Pair<Integer,Integer> states_mutations = new Pair<Integer,Integer>(states,mutationStage+1);
            gr_DiffGD_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
            gr_DiffW_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.ACCURACY_W));
            gr_DiffRand_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.ACCURACY_W));
            gr_MutationsToOriginal_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.MUTATIONS_TO_TRANSITIONS));
            gr_DiffRand_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.ACCURACY_W));
            gr_MismatchedPairs.add(states_mutations,outcome.getValue(DOUBLE_V.MISMATCHED_KEYPAIRS));
            gr_Pairs_States.add(states,outcome.getValue(DOUBLE_V.MISMATCHED_KEYPAIRS));
           
            // Time taken
            long ns = 1000000L;
            gr_TimeDiff_StatesLevel.add(states_mutations, (double)(outcome.getValue(LONG_V.DURATION_GD)/ns));
            gr_TimeW_StatesLevel.add(states_mutations, (double)(outcome.getValue(LONG_V.DURATION_W)/ns));
            gr_TimeRand_StatesLevel.add(states_mutations, (double)(outcome.getValue(LONG_V.DURATION_RAND)/ns));
            gr_TimeDiff_States.add(states,(double)(outcome.getValue(LONG_V.DURATION_GD)/ns));
            gr_TimeW_States.add(states,(double)(outcome.getValue(LONG_V.DURATION_W)/ns));
            gr_TimeRand_States.add(states,(double)(outcome.getValue(LONG_V.DURATION_RAND)/ns));
           
            gr_Diff_MutationsToOriginal.add(outcome.getValue(DOUBLE_V.MUTATIONS_TO_TRANSITIONS),outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
            gr_Diff_W.add(outcome.getValue(DOUBLE_V.ACCURACY_W),outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
            gr_Rand_W.add(outcome.getValue(DOUBLE_V.ACCURACY_W),outcome.getValue(DOUBLE_V.ACCURACY_RAND));
            gr_Diff_MismatchedPairs.add(outcome.getValue(DOUBLE_V.MISMATCHED_KEYPAIRS),outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
            gr_F_measures.add(outcome.getValue(DOUBLE_V.ACCURACY_W), outcome.getValue(DOUBLE_V.ACCURACY_LINEAR));
            gr_FMeasure_Level.add(mutationStage, outcome.getValue(DOUBLE_V.ACCURACY_LINEAR));
          }

        }
        // finished doing this mutation stage, update graphs
        gr_Diff_States.drawInteractive(gr);gr_MutationsToOriginal_StatesLevel.drawInteractive(gr);         
        //gr_Diff_thresholds.drawInteractive(gr);
        //gr_Diff_k.drawInteractive(gr);
        gr_DiffGD_StatesLevel.drawInteractive(gr);gr_DiffW_StatesLevel.drawInteractive(gr);gr_DiffRand_StatesLevel.drawInteractive(gr);
        gr_Diff_MutationsToOriginal.drawInteractive(gr);
        gr_W_States.drawInteractive(gr);
        gr_Diff_W.drawInteractive(gr);
        gr_Rand_W.drawInteractive(gr);
        gr_FMeasure_Level.drawInteractive(gr);
        //gr_TimeDiff_StatesLevel.drawInteractive(gr);gr_TimeW_StatesLevel.drawInteractive(gr);gr_TimeRand_StatesLevel.drawInteractive(gr);
        //gr_MismatchedPairs.drawInteractive(gr);
        gr_Pairs_States.drawInteractive(gr);gr_TimeDiff_States.drawInteractive(gr);gr_TimeRand_States.drawInteractive(gr);gr_TimeW_States.drawInteractive(gr);
        gr_F_measures.drawInteractive(gr);
        //if (mutationStage>0) gr_Diff_MismatchedPairs.drawInteractive(gr);
       
        //ExperimentResult average = getAverage(accuracyStruct,graphComplexity,mutationStage);
        //arrayWithDiffResults.add(diffValues);arrayWithKeyPairsResults.add(keyPairsValues);
        //arrayWithResultNames.add(""+states+"-"+Math.round(100*average.mutationsToTransitions)+"%");
        //System.out.print("["+average+"]");
       
       
        //List<String> names=arrayWithResultNames.size()>1?arrayWithResultNames:null;
      }

    }
    gr_Diff_States.drawPdf(gr);gr_W_States.drawPdf(gr);gr_MutationsToOriginal_StatesLevel.drawPdf(gr);
    gr_Diff_threshold.drawPdf(gr);gr_Diff_lowtohigh.drawPdf(gr);gr_Diff_thresholdslowhigh.drawPdf(gr);gr_Diff_k.drawPdf(gr);
    gr_Diff_MutationsToOriginal.drawPdf(gr);
    gr_DiffGD_StatesLevel.drawPdf(gr);gr_DiffW_StatesLevel.drawPdf(gr);gr_DiffRand_StatesLevel.drawPdf(gr);
    gr_Diff_W.drawPdf(gr);gr_Rand_W.drawPdf(gr);
    gr_MismatchedPairs.drawPdf(gr);gr_Diff_MismatchedPairs.drawPdf(gr);
   
    gr_TimeDiff_StatesLevel.drawPdf(gr);gr_TimeW_StatesLevel.drawPdf(gr);gr_TimeRand_StatesLevel.drawPdf(gr);
    gr_Pairs_States.drawPdf(gr);gr_TimeDiff_States.drawPdf(gr);gr_TimeRand_States.drawPdf(gr);gr_TimeW_States.drawPdf(gr);
    gr_F_measures.drawPdf(gr);
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

                ";selectingRed="+selectingRed+";classifierToBlockAllMergers="+classifierToBlockAllMergers+";zeroScoringAsRed="+zeroScoringAsRed+";traceQuantity="+traceQuantity+";lengthMultiplier="+lengthMultiplier+";trainingDataMultiplier="+trainingDataMultiplier+";";

            final int totalTaskNumber = traceQuantity;
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score"+selection+".pdf"));
            final RBoxPlot<String> gr_QualityForNumberOfTraces = new RBoxPlot<String>("traces","%%",new File("quality_traces"+selection+".pdf"));
            SquareBagPlot gr_NewToOrig = new SquareBagPlot("orig score","score with learnt selection",new File("new_to_orig"+selection+".pdf"),0,1,true);
            final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();
            try
            {
              int numberOfTasks = 0;
              for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
                for(int sample=0;sample<samplesPerFSM;++sample)
                {
                  LearnerRunner learnerRunner = new LearnerRunner(dataCollector,states,sample,totalTaskNumber+numberOfTasks,traceQuantity, config, converter)
                  {
                    @Override
                    public LearnerThatCanClassifyPairs createLearner(LearnerEvaluationConfiguration evalCnf,LearnerGraph argReferenceGraph,@SuppressWarnings("unused") WekaDataCollector argDataCollector,  LearnerGraph argInitialPTA)
                    {
                      LearnerThatUsesWekaResults l = new LearnerThatUsesWekaResults(ifDepth,evalCnf,argReferenceGraph,classifier,argInitialPTA);
                      if (gr_PairQuality != null)
                        l.setPairQualityCounter(pairQualityCounter);
                     
                      l.setUseClassifierForRed(selectingRed);l.setUseClassifierToChooseNextRed(classifierToBlockAllMergers);
                      l.setBlacklistZeroScoringPairs(zeroScoringAsRed);
                      l.setThreshold(threshold);
                      return l;
                    }
                   
                  };
                  learnerRunner.setPickUniqueFromInitial(useUnique);learnerRunner.setEvaluateAlsoUsingReferenceLearner(true);
                  learnerRunner.setOnlyUsePositives(onlyPositives);learnerRunner.setIfdepth(ifDepth);learnerRunner.setLengthMultiplier(lengthMultiplier);
                  learnerRunner.setSelectionID(selection+"_states"+states+"_sample"+sample);
                  runner.submit(learnerRunner);
                  ++numberOfTasks;
                }
              ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for "+selection, numberOfTasks);
              for(int count=0;count < numberOfTasks;++count)
              {
                ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
                if (gr_NewToOrig != null)
                {
                  for(SampleData sample:result.samples)
                    gr_NewToOrig.add(sample.referenceLearner.getValue(),sample.actualLearner.getValue());
                }
               
                for(SampleData sample:result.samples)
                  if (sample.referenceLearner.getValue() > 0)
                    gr_QualityForNumberOfTraces.add(traceQuantity+"",sample.actualLearner.getValue()/sample.referenceLearner.getValue());
                progress.next();
              }
              if (gr_PairQuality != null)
              {
                synchronized(pairQualityCounter)
                {
                  updateGraph(gr_PairQuality,pairQualityCounter);
                  //gr_PairQuality.drawInteractive(gr);
                  //gr_NewToOrig.drawInteractive(gr);
                  //if (gr_QualityForNumberOfTraces.size() > 0)
                  //  gr_QualityForNumberOfTraces.drawInteractive(gr);
                }
              }
              if (gr_PairQuality != null) gr_PairQuality.drawPdf(gr);
            }
            catch(Exception ex)
            {
              IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
              if (executorService != null) { executorService.shutdownNow();executorService = null; }
              throw e;
            }
            if (gr_NewToOrig != null) gr_NewToOrig.drawPdf(gr);
            if (gr_QualityForNumberOfTraces != null) gr_QualityForNumberOfTraces.drawPdf(gr);
          }
        }
      }
    if (executorService != null) { executorService.shutdown();executorService = null; }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

                ";selectingRed="+selectingRed+";classifierToBlockAllMergers="+classifierToBlockAllMergers+";zeroScoringAsRed="+zeroScoringAsRed+";traceQuantity="+traceQuantity+";lengthMultiplier="+lengthMultiplier+";trainingDataMultiplier="+trainingDataMultiplier+";";

            final int totalTaskNumber = traceQuantity;
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score"+selection+".pdf"));
            final RBoxPlot<String> gr_QualityForNumberOfTraces = new RBoxPlot<String>("traces","%%",new File("quality_traces"+selection+".pdf"));
            SquareBagPlot gr_NewToOrig = new SquareBagPlot("orig score","score with learnt selection",new File("new_to_orig"+selection+".pdf"),0,1,true);
            final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();
            try
            {
              int numberOfTasks = 0;
              for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
                for(int sample=0;sample<samplesPerFSM;++sample)
                {
                  LearnerRunner learnerRunner = new LearnerRunner(dataCollector,states,sample,totalTaskNumber+numberOfTasks,traceQuantity, config, converter)
                  {
                    @Override
                    public LearnerThatCanClassifyPairs createLearner(LearnerEvaluationConfiguration evalCnf,LearnerGraph argReferenceGraph,@SuppressWarnings("unused") WekaDataCollector argDataCollector,  LearnerGraph argInitialPTA)
                    {
                      LearnerThatUsesWekaResults l = new LearnerThatUsesWekaResults(ifDepth,evalCnf,argReferenceGraph,classifier,argInitialPTA);
                      if (gr_PairQuality != null)
                        l.setPairQualityCounter(pairQualityCounter);
                     
                      l.setUseClassifierForRed(selectingRed);l.setUseClassifierToChooseNextRed(classifierToBlockAllMergers);
                      l.setBlacklistZeroScoringPairs(zeroScoringAsRed);
                      l.setThreshold(threshold);
                      return l;
                    }
                   
                  };
                  learnerRunner.setPickUniqueFromInitial(useUnique);learnerRunner.setEvaluateAlsoUsingReferenceLearner(true);
                  learnerRunner.setOnlyUsePositives(onlyPositives);learnerRunner.setIfdepth(ifDepth);learnerRunner.setLengthMultiplier(lengthMultiplier);
                  learnerRunner.setSelectionID(selection+"_states"+states+"_sample"+sample);
                  runner.submit(learnerRunner);
                  ++numberOfTasks;
                }
              ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for "+selection, numberOfTasks);
              for(int count=0;count < numberOfTasks;++count)
              {
                ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
                if (gr_NewToOrig != null)
                {
                  for(SampleData sample:result.samples)
                    gr_NewToOrig.add(sample.differenceForReferenceLearner.getValue(),sample.difference.getValue());
                }
               
                for(SampleData sample:result.samples)
                  if (sample.differenceForReferenceLearner.getValue() > 0)
                    gr_QualityForNumberOfTraces.add(traceQuantity+"",sample.difference.getValue()/sample.differenceForReferenceLearner.getValue());
                progress.next();
              }
              if (gr_PairQuality != null)
              {
                synchronized(pairQualityCounter)
                {
                  updateGraph(gr_PairQuality,pairQualityCounter);
                  //gr_PairQuality.drawInteractive(gr);
                  //gr_NewToOrig.drawInteractive(gr);
                  //if (gr_QualityForNumberOfTraces.size() > 0)
                  //  gr_QualityForNumberOfTraces.drawInteractive(gr);
                }
              }
              if (gr_PairQuality != null) gr_PairQuality.drawPdf(gr);
            }
            catch(Exception ex)
            {
              IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
              if (executorService != null) { executorService.shutdownNow();executorService = null; }
              throw e;
            }
            if (gr_NewToOrig != null) gr_NewToOrig.drawPdf(gr);
            if (gr_QualityForNumberOfTraces != null) gr_QualityForNumberOfTraces.drawPdf(gr);
          }
        }
      }
    if (executorService != null) { executorService.shutdown();executorService = null; }
View Full Code Here

Examples of statechum.analysis.learning.DrawGraphs.SquareBagPlot

     final Collection<List<Label>> evaluationTestSet = computeEvaluationSet(referenceGraph,-1,-1);
       DrawGraphs gr = new DrawGraphs();
    final RBoxPlot<String>
      uas_F=new RBoxPlot<String>("Time","F-measure",new File("time_"+name+"_f.pdf")),
      uas_Diff=new RBoxPlot<String>("Time","Diff-measure",new File("time_"+name+"_Diff.pdf"));
    SquareBagPlot gr_diff_to_f = new SquareBagPlot("f-measure","diff-based measure",new File("diff-to-f.pdf"),0,1,true);

    Set<Integer> allFrames = collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).keySet();
    Classifier classifiers[] = loadClassifierFromArff(arffName);
    ProgressIndicator progress = new ProgressIndicator("UAS", allFrames.size()*classifiers.length);
    LearnerEvaluationConfiguration initConfiguration = new LearnerEvaluationConfiguration(learnerInitConfiguration.config);
    initConfiguration.setLabelConverter(learnerInitConfiguration.getLabelConverter());// we do not copy if-then automata here because we do not wish to augment from if-then on every iteration because our properties are pairwise and this permits augmentation to be carried out first thing and not any more.
    initConfiguration.config.setUseConstraints(false);// do not use if-then during learning (refer to the explanation above)
   
    LearnerGraph [] ifthenAutomata = Transform.buildIfThenAutomata(learnerInitConfiguration.ifthenSequences, null, referenceGraph, learnerInitConfiguration.config, learnerInitConfiguration.getLabelConverter()).toArray(new LearnerGraph[0]);
    System.out.println(new Date().toString()+" learning commencing.");
    final Integer frame=6;
      //for(final Integer frame:allFrames)
      {
        LearnerGraph initPTA = new LearnerGraph(initConfiguration.config);initPTA.paths.augmentPTA(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(frame));
        Transform.augmentFromIfThenAutomaton(initPTA, null, ifthenAutomata, initConfiguration.config.getHowManyStatesToAddFromIFTHEN());// we only need  to augment our PTA once (refer to the explanation above).
        System.out.println("total states : "+initPTA.getStateNumber()+", "+initPTA.getAcceptStateNumber()+" accept-states");

        final Set<Label> alphabetForIfThen = referenceGraph.pathroutines.computeAlphabet();
        Label uniqueLabel = AbstractLearnerGraph.generateNewLabel("Waypoint_Selected", initConfiguration.config,initConfiguration.getLabelConverter());

        /*
        for(int i=0;i<classifiers.length;++i)
        {
          {
            initPTA.storage.writeGraphML("resources/"+name+"-init_"+frame+"_"+i+".xml");
            LearnerThatCanClassifyPairs learner = new LearnerThatUsesWekaResults(ifDepth,initConfiguration,referenceGraph,classifiers[i],initPTA);
            //learner.setAlphabetUsedForIfThen(alphabetForIfThen);
            learner.setLabelsLeadingToStatesToBeMerged(Collections.<Label>emptyList());learner.setLabelsLeadingFromStatesToBeMerged(Collections.<Label>emptyList());
            //learner.setLabelsLeadingFromStatesToBeMerged(Arrays.asList(new Label[]{AbstractLearnerGraph.generateNewLabel("Waypoint_Selected", initConfiguration.config,initConfiguration.getLabelConverter())}));
               final LearnerGraph actualAutomaton = learner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
               //actualAutomaton.storage.writeGraphML("resources/"+name+"_"+frame+"_"+i+".xml");
             
               double differenceF = PairQualityLearner.estimationOfDifferenceFmeasure(referenceGraph, actualAutomaton, evaluationTestSet);
               double differenceD = PairQualityLearner.estimationOfDifferenceDiffMeasure(referenceGraph, actualAutomaton, initConfiguration.config, ExperimentRunner.getCpuNumber());
              System.out.println(new Date().toString()+" _L: For frame : "+frame+" (classifier "+i+"), long traces f-measure = "+ differenceF+" diffmeasure = "+differenceD);
          uas_F.add(frame+"_L",differenceF,"green");uas_Diff.add(frame+"_L",differenceD,"green");gr_diff_to_f.add(differenceF,differenceD);
          }
                   
          {
            LearnerThatCanClassifyPairs learner = new LearnerThatUsesWekaResults(ifDepth,initConfiguration,referenceGraph,classifiers[i],initPTA);
            learner.setAlphabetUsedForIfThen(alphabetForIfThen);
            learner.setLabelsLeadingToStatesToBeMerged(Collections.<Label>emptyList());
            learner.setLabelsLeadingFromStatesToBeMerged(Arrays.asList(new Label[]{uniqueLabel}));
               LearnerGraph actualAutomaton = learner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
              //actualAutomaton.storage.writeGraphML("resources/"+name+"-mm_"+frame+"_"+i+".xml");

              // Now merge everything that we need to merge
              LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
          List<StatePair> pairsList = LearnerThatCanClassifyPairs.buildVerticesToMerge(actualAutomaton,learner.getLabelsLeadingToStatesToBeMerged(),learner.getLabelsLeadingFromStatesToBeMerged());
          if (!pairsList.isEmpty())
          {
            int score = actualAutomaton.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
            if (score < 0) throw new RuntimeException("last merge in the learning process was not possible");
            actualAutomaton = MergeStates.mergeCollectionOfVertices(actualAutomaton, null, verticesToMerge);
          }

              double differenceF = PairQualityLearner.estimationOfDifferenceFmeasure(referenceGraph, actualAutomaton, evaluationTestSet);
              double differenceD = PairQualityLearner.estimationOfDifferenceDiffMeasure(referenceGraph, actualAutomaton, initConfiguration.config, ExperimentRunner.getCpuNumber());
              System.out.println(new Date().toString()+" _M: For frame : "+frame+" (classifier "+i+"), long traces f-measure = "+ differenceF+" diffmeasure = "+differenceD);
          uas_F.add(frame+"_M",differenceF,"blue");uas_Diff.add(frame+"_M",differenceD,"blue");gr_diff_to_f.add(differenceF,differenceD);
          }
          {
            LearnerGraph ptaAfterMergingBasedOnUniques = PairQualityLearner.mergeStatesForUnique(initPTA,uniqueLabel);
            LearnerThatCanClassifyPairs learner = new LearnerThatUsesWekaResults(ifDepth,initConfiguration,referenceGraph,classifiers[i],ptaAfterMergingBasedOnUniques);
            learner.setAlphabetUsedForIfThen(alphabetForIfThen);
            learner.setLabelsLeadingToStatesToBeMerged(Collections.<Label>emptyList());
            learner.setLabelsLeadingFromStatesToBeMerged(Arrays.asList(new Label[]{uniqueLabel}));
               LearnerGraph actualAutomaton = learner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
              //actualAutomaton.storage.writeGraphML("resources/"+name+"-mm_"+frame+"_"+i+".xml");

              // Now merge everything that we need to merge
              LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
          List<StatePair> pairsList = LearnerThatCanClassifyPairs.buildVerticesToMerge(actualAutomaton,learner.getLabelsLeadingToStatesToBeMerged(),learner.getLabelsLeadingFromStatesToBeMerged());
          if (!pairsList.isEmpty())
          {
            int score = actualAutomaton.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
            if (score < 0) throw new RuntimeException("last merge in the learning process was not possible");
            actualAutomaton = MergeStates.mergeCollectionOfVertices(actualAutomaton, null, verticesToMerge);
          }

              double differenceF = PairQualityLearner.estimationOfDifferenceFmeasure(referenceGraph, actualAutomaton, evaluationTestSet);
              double differenceD = PairQualityLearner.estimationOfDifferenceDiffMeasure(referenceGraph, actualAutomaton, initConfiguration.config, ExperimentRunner.getCpuNumber());
              System.out.println(new Date().toString()+" _UM: For frame : "+frame+" (classifier "+i+"), long traces f-measure = "+ differenceF+" diffmeasure = "+differenceD);
          uas_F.add(frame+"_UM",differenceF,"blue");uas_Diff.add(frame+"_UM",differenceD,"blue");gr_diff_to_f.add(differenceF,differenceD);
          }
          progress.next();
        }
          */

        initPTA.storage.writeGraphML("hugegraph.xml");
      LearnerGraph ptaSmall = PairQualityLearner.mergeStatesForUnique(initPTA,uniqueLabel);
        //Visualiser.updateFrame(initPTA.transform.trimGraph(4, initPTA.getInit()), ptaSmall.transform.trimGraph(4, ptaSmall.getInit()));
        //Visualiser.waitForKey();
       
        {
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score_huge_ref.pdf"));
          final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();

          PairQualityLearner.ReferenceLearner referenceLearner = new PairQualityLearner.ReferenceLearner(initConfiguration, referenceGraph, initPTA);
          referenceLearner.setPairQualityCounter(pairQualityCounter);
            LearnerGraph referenceOutcome = referenceLearner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
            //referenceOutcome.storage.writeGraphML("resources/"+name+"-ref_"+frame+".xml");
           
            DifferenceToReference differenceF = DifferenceToReferenceLanguage.estimationOfDifference(referenceGraph, referenceOutcome, evaluationTestSet);
            DifferenceToReference differenceD = DifferenceToReferenceDiff.estimationOfDifferenceDiffMeasure(referenceGraph, referenceOutcome, initConfiguration.config, ExperimentRunner.getCpuNumber());
            System.out.println(new Date().toString()+" _R: For frame : "+frame+", long traces f-measure = "+ differenceF.getValue()+" diffmeasure = "+differenceD.getValue());
        uas_F.add(frame+"_R",differenceF.getValue(),"red");uas_Diff.add(frame+"_R",differenceD.getValue(),"red");gr_diff_to_f.add(differenceF.getValue(),differenceD.getValue());

        //PairQualityLearner.updateGraph(gr_PairQuality,pairQualityCounter);
        //gr_PairQuality.drawInteractive(gr);gr_PairQuality.drawPdf(gr);
      }

        {
            final RBoxPlot<Long> gr_PairQuality = new RBoxPlot<Long>("Correct v.s. wrong","%%",new File("percentage_score_huge_refM.pdf"));
          final Map<Long,TrueFalseCounter> pairQualityCounter = new TreeMap<Long,TrueFalseCounter>();

          LearnerGraph ptaAfterMergingBasedOnUniques = PairQualityLearner.mergeStatesForUnique(initPTA,uniqueLabel);
          PairQualityLearner.ReferenceLearner referenceLearner = new PairQualityLearner.ReferenceLearner(initConfiguration, referenceGraph, ptaAfterMergingBasedOnUniques);
          referenceLearner.setPairQualityCounter(pairQualityCounter);
            LearnerGraph referenceOutcome = referenceLearner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
            //referenceOutcome.storage.writeGraphML("resources/"+name+"-ref_"+frame+".xml");
           
            DifferenceToReference differenceF = DifferenceToReferenceLanguage.estimationOfDifference(referenceGraph, referenceOutcome, evaluationTestSet);
            DifferenceToReference differenceD = DifferenceToReferenceDiff.estimationOfDifferenceDiffMeasure(referenceGraph, referenceOutcome, initConfiguration.config, ExperimentRunner.getCpuNumber());
            System.out.println(new Date().toString()+" _R: For frame : "+frame+", long traces f-measure = "+ differenceF+" diffmeasure = "+differenceD);
        uas_F.add(frame+"_RM",differenceF.getValue(),"red");uas_Diff.add(frame+"_RM",differenceD.getValue(),"red");gr_diff_to_f.add(differenceF.getValue(),differenceD.getValue());

        //PairQualityLearner.updateGraph(gr_PairQuality,pairQualityCounter);
        //gr_PairQuality.drawInteractive(gr);gr_PairQuality.drawPdf(gr);
      }

     
      uas_F.drawInteractive(gr);uas_Diff.drawInteractive(gr);gr_diff_to_f.drawInteractive(gr);
      }
      uas_F.drawPdf(gr);uas_Diff.drawPdf(gr);gr_diff_to_f.drawPdf(gr);
    DrawGraphs.end();// the process will not terminate without it because R has its own internal thread
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.