Package statechum.analysis.learning.PrecisionRecall

Examples of statechum.analysis.learning.PrecisionRecall.ConfusionMatrix


    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


         {
          RPNIBlueFringe learner = new RPNIBlueFringe(learnerConfig,choice);
            final LearnerGraph actualAutomaton = learner.learn(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(frame),true);
            long tmFinished = new Date().getTime();
            System.out.println("Learning complete, "+((tmFinished-tmStarted)/1000)+" sec");tmStarted = tmFinished;
            ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference, actualAutomaton);
            System.out.println("BCR for frame : "+frame+" = "+matrix.BCR()+", precision: "+matrix.getPrecision()+", recall: "+matrix.getRecall()+", specificity: "+matrix.getSpecificity()+", matrix: "+matrix+", log of choices: "+learner.logOfChoiceNumber);
            //Visualiser.updateFrame(actualAutomaton, graphReference);
            /*
            boolean foundSame = false;
            for(LearnerGraph g:graphs)
              if (WMethod.checkM(g, actualAutomaton) != null)
              {
                foundSame = true;break;
              }
            if (!foundSame) */graphs.add(actualAutomaton);
           
        GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
        ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> counter = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(graphReference, actualAutomaton, null);
        gd.computeGD(graphReference, actualAutomaton, ExperimentRunner.getCpuNumber(),counter,learnerConfig);
       
        int referenceEdges = graphReference.pathroutines.countEdges(), actualEdges = actualAutomaton.pathroutines.countEdges();
        System.out.println(counter.getRemoved()+","+counter.getAdded()+", difference is "+(((double)referenceEdges-counter.getRemoved())/referenceEdges+((double)actualEdges-counter.getAdded())/actualEdges)/2);
       
        uas_S.add(frame,matrix.BCR());
        //uas_S.drawInteractive(gr);
       }
       
        int count=0;
        for(LearnerGraph g:graphs)
View Full Code Here

 
            @Override
            public void run() {
              for(int choice:SelectionChoices)
              {
                ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                    new RPNIBlueFringe(learnerConfig,choice).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() {
                TracesForSeed tracesForThisSeed = collectionOfTraces.get(seed);
               
                for(int choice:SelectionChoices)
                {
                  ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                      new RPNIBlueFringe(learnerConfig,choice).learn(tracesForThisSeed.tracesForUAVandFrame.get(UAVAll).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() {
                    for(int choice:SelectionChoices)
                    {
                      ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,
                          new RPNIBlueFringe(learnerConfig,choice).learn(collectionOfTraces.get(seed).tracesForUAVandFrame.get(UAV).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() {
            for(int choice:SelectionChoices)
            {
              Configuration tmpConf = learnerConfig.copy();tmpConf.setGeneralisationThreshold(arg);
              ConfusionMatrix matrix = DiffExperiments.classify(wMethod, graphReference,new RPNIBlueFringe(tmpConf,choice).learn(collectionOfTraces.get(UAVAllSeeds).tracesForUAVandFrame.get(UAVAllSeeds).get(maxFrameNumber),false));
              uas_threshold.add(arg, matrix.BCR());
            }
          }
         
        };
        if (threadNumber > 1)
View Full Code Here

        {// the exception is thrown because the learner failed to learn anything completely. Ignore it because the default score is zero assigned via zeroScore.
        }
      }

      {// For Markov, we do not need to learn anything at all - our Markov matrix contains enough information to classify paths and hence compare it to the reference graph.
        ConfusionMatrix mat = DiffExperiments.classifyAgainstMarkov(testSet, referenceGraph, m);
        dataSample.markovLearner = new ScoresForGraph();         
        dataSample.markovLearner.differenceBCR = new DifferenceToReferenceLanguageBCR(mat);
      }
     
      dataSample.fractionOfStatesIdentifiedBySingletons=Math.round(100*MarkovClassifier.calculateFractionOfStatesIdentifiedBySingletons(referenceGraph));
 
View Full Code Here

          }
        }
       

        {// For Markov, we do not need to learn anything at all - our Markov matrix contains enough information to classify paths and hence compare it to the reference graph.
          ConfusionMatrix mat = DiffExperiments.classifyAgainstMarkov(testSet, referenceGraph, m);
          dataSample.markovLearner = new ScoresForGraph();     
          System.out.println("Markov");
          dataSample.markovLearner.differenceBCR = new DifferenceToReferenceLanguageBCR(mat);
          System.out.println(dataSample.markovLearner.differenceBCR.getValue());
        }
View Full Code Here

     * @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 DifferenceToReferenceLanguage 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 DifferenceToReferenceLanguage(mat);
    }
View Full Code Here

     * @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

     * @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 DifferenceToReferenceFMeasure 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 DifferenceToReferenceFMeasure(mat);
    }
View Full Code Here

     * @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

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.