Package statechum.analysis.learning.PrecisionRecall

Examples of statechum.analysis.learning.PrecisionRecall.ConfusionMatrix


     * @param cpuNumber the number of processors to use. Usually set to 1 because we run as many experiments as there are CPUs and so individual experiments should not consume more computational power than we have available for them.
     */
    public static DifferenceToReferenceLanguageBCR estimationOfDifference(LearnerGraph referenceGraph, LearnerGraph actualAutomaton, Collection<List<Label>> testSet)
    {
           LearnerGraph learntGraph = new LearnerGraph(actualAutomaton.config);AbstractPathRoutines.removeRejectStates(actualAutomaton,learntGraph);
           ConfusionMatrix mat = DiffExperiments.classify(testSet, referenceGraph, learntGraph);
      return new DifferenceToReferenceLanguageBCR(mat);
    }
View Full Code Here


  private Pair<Double,Long> compareLang(LearnerGraph from, LearnerGraph to,
      Collection<List<Label>> sequences)
  {
   
    final long startTime = System.nanoTime();
    ConfusionMatrix matrix = classify(sequences, from,to);
    final long duration = System.nanoTime() - startTime;
    double result = matrix.fMeasure();
    assert !Double.isNaN(result);
    return new Pair<Double,Long>(result,duration);
  }
View Full Code Here

      else if(!inTarget && inMutated)
        fp++;
      else if(!inTarget && !inMutated)
        tn++;
    }
    return new ConfusionMatrix(tp,tn,fp,fn);
  }
View Full Code Here

    set.clear();
    set.addAll(expected);
    set.removeAll(detected);
    fn = set.size();
   
    ConfusionMatrix conf = new ConfusionMatrix(tp, tn, fp, fn);
    return conf.fMeasure();
  }
View Full Code Here

        {// For all frames and all seeds
          Runnable interactiveRunner = new Runnable() {
 
            @Override
            public void run() {
              ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                  new RPNIBlueFringe(learnerConfig,useOptimizedMerge,null,null).learn(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(frame),true));
              uas_outcome.add(new Pair<Integer,String>(frame,"S"),matrix.BCR());
              uas_S.add(frame,matrix.BCR());
            }
           
          };
          if (threadNumber > 1) outcomes.add(executorService.submit(interactiveRunner));else interactiveRunner.run();
        }
       
        for(final String seed:collectionOfTraces.keySet())
          if (!seed.equals(UAVAllSeeds))
          {// Just for all frames of the a single seed
            Runnable interactiveRunner = new Runnable() {

              @Override
              public void run() {
                ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                    new RPNIBlueFringe(learnerConfig,useOptimizedMerge,null,null).learn(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(seed).get(frame),true));
                uas_outcome.add(new Pair<Integer,String>(frame,"A"),matrix.BCR());
                uas_A.add(frame,matrix.BCR());
              }
             
            };
            if (threadNumber > 1) outcomes.add(executorService.submit(interactiveRunner));else interactiveRunner.run();
          }
        for(final String UAV:collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.keySet())
          if (!UAV.equals(UAVAllSeeds) && !UAV.equals(UAVAll))
            for(final String seed:collectionOfTraces.keySet())
              if (!seed.equals(UAVAllSeeds))
              {
                Runnable interactiveRunner = new Runnable() {

                  @Override
                  public void run() {
                    ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                        new RPNIBlueFringe(learnerConfig,useOptimizedMerge,null,null).learn(collectionOfTraces.get(UAV).tracesForUAVandFrame.get(seed).get(frame),true));
                    uas_outcome.add(new Pair<Integer,String>(frame,"U"),matrix.BCR());
                    uas_U.add(frame,matrix.BCR());
                  }
                 
                };
                if (threadNumber > 1) outcomes.add(executorService.submit(interactiveRunner));else interactiveRunner.run();
              }
       
        if (threadNumber <= 1)
        {
          uas_outcome.drawInteractive(gr);
          uas_A.drawInteractive(gr);
          uas_S.drawInteractive(gr);
          uas_U.drawInteractive(gr);
          progress.next();
        }
      }
     
      for(int i=0;i<5;++i)
      {
        final int arg=i;
        Runnable interactiveRunner = new Runnable() {

          @Override
          public void run() {
            Configuration tmpConf = learnerConfig.copy();tmpConf.setGeneralisationThreshold(arg);
            ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,new RPNIBlueFringe(tmpConf,useOptimizedMerge,null,null).learn(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(maxFrameNumber),false));
            uas_threshold.add(arg, matrix.BCR());
          }
         
        };
        if (threadNumber > 1)
          outcomes.add(executorService.submit(interactiveRunner));
View Full Code Here

  public void testClassify1()
  {
    LearnerGraph from = buildLearnerGraph("A-a->A-b->B / A-c-#C","testClassify1a",mainConfiguration,converter),
    to= buildLearnerGraph("A-b->A-a->B","testClassify1b",mainConfiguration,converter);
   
    ConfusionMatrix matrix = DiffExperiments.classify(TestFSMAlgo.buildSet(new String[][]{
        new String[]{"a"}
    },mainConfiguration,converter), from, to);
    Assert.assertEquals(1.,matrix.getPrecision(),Configuration.fpAccuracy);
    Assert.assertEquals(1.,matrix.getRecall(),Configuration.fpAccuracy);
    Assert.assertEquals(1.,matrix.fMeasure(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getSpecificity(),Configuration.fpAccuracy);
    Assert.assertEquals(0.5,matrix.BCR(),Configuration.fpAccuracy);
  }
View Full Code Here

  public void testClassify2()
  {
    LearnerGraph from = buildLearnerGraph("A-a->A-b->B / A-c-#C","testClassify1a",mainConfiguration,converter),
    to=buildLearnerGraph("A-b->A-a->B","testClassify1b",mainConfiguration,converter);
   
    ConfusionMatrix matrix = DiffExperiments.classify(TestFSMAlgo.buildSet(new String[][]{
        new String[]{"notransition"}
    },mainConfiguration,converter), from, to);
    Assert.assertEquals(0.,matrix.getPrecision(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getRecall(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.fMeasure(),Configuration.fpAccuracy);
    Assert.assertEquals(1.,matrix.getSpecificity(),Configuration.fpAccuracy);
    Assert.assertEquals(0.5,matrix.BCR(),Configuration.fpAccuracy);
  }
View Full Code Here

  public void testClassify3()
  {
    LearnerGraph from = buildLearnerGraph("A-a->A-b->B / A-c-#C","testClassify1a",mainConfiguration,converter),
    to=buildLearnerGraph("A-b->A-a->B","testClassify1b",mainConfiguration,converter);
   
    ConfusionMatrix matrix = DiffExperiments.classify(TestFSMAlgo.buildSet(new String[][]{
        new String[]{"c"}
    },mainConfiguration,converter), from, to);
    Assert.assertEquals(0.,matrix.getPrecision(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getRecall(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.fMeasure(),Configuration.fpAccuracy);
    Assert.assertEquals(1.,matrix.getSpecificity(),Configuration.fpAccuracy);
    Assert.assertEquals(0.5,matrix.BCR(),Configuration.fpAccuracy);
  }
View Full Code Here

  public void testClassify4()
  {
    LearnerGraph from = buildLearnerGraph("A-a->A-b->B / A-c-#C","testClassify1a",mainConfiguration,converter),
    to=buildLearnerGraph("A-b->A-a->B","testClassify1b",mainConfiguration,converter);
   
    ConfusionMatrix matrix = DiffExperiments.classify(TestFSMAlgo.buildSet(new String[][]{
        new String[]{"a","a"} // FN
    },mainConfiguration,converter), from, to);
    Assert.assertEquals(0.,matrix.getPrecision(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getRecall(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.fMeasure(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getSpecificity(),Configuration.fpAccuracy);
    Assert.assertEquals(0,matrix.BCR(),Configuration.fpAccuracy);
  }
View Full Code Here

  public void testClassify5()
  {
    LearnerGraph from = buildLearnerGraph("A-a->A-b->B / A-c-#C","testClassify1a",mainConfiguration,converter),
    to=buildLearnerGraph("A-b->A-a->B","testClassify1b",mainConfiguration,converter);
   
    ConfusionMatrix matrix = DiffExperiments.classify(TestFSMAlgo.buildSet(new String[][]{
        new String[]{"a","a"} // FN
        ,new String[]{"b"} // TP
    },mainConfiguration,converter), from, to);
    Assert.assertEquals(1.,matrix.getPrecision(),Configuration.fpAccuracy);
    Assert.assertEquals(0.5,matrix.getRecall(),Configuration.fpAccuracy);
    Assert.assertEquals(0.66666666,matrix.fMeasure(),Configuration.fpAccuracy);
    Assert.assertEquals(0.,matrix.getSpecificity(),Configuration.fpAccuracy);
    Assert.assertEquals(0.25,matrix.BCR(),Configuration.fpAccuracy);
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.PrecisionRecall.ConfusionMatrix

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.