Package statechum.analysis.learning.MarkovClassifier

Examples of statechum.analysis.learning.MarkovClassifier.ConsistencyChecker


                            for(List<Label> seq:sMinus)
                              pta.paths.augmentPTA(seq,false,false,null);
                            final MarkovModel m= new MarkovModel(3,true,true);

                            new MarkovClassifier(m, pta).updateMarkov(false);// construct Markov chain if asked for.
                            final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
                         
                            pta.clearColours();
                            EDSM_MarkovLearner learner = new EDSM_MarkovLearner(learnerInitConfiguration,pta,0) {

                              @Override
View Full Code Here


    assert pta.getStateNumber() == pta.getAcceptStateNumber() : "graph with negatives but onlyUsePositives is set";
     
    final Configuration deepCopy = pta.config.copy();deepCopy.setLearnerCloneGraph(true);
    LearnerGraph ptaCopy = new LearnerGraph(deepCopy);LearnerGraph.copyGraphs(pta, ptaCopy);

    final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
    //long inconsistencyForTheReferenceGraph = MarkovClassifier.computeInconsistency(trimmedReference, m, checker,false);

    MarkovClassifier ptaClassifier = new MarkovClassifier(m,pta);
    final List<List<Label>> pathsToMerge=ptaClassifier.identifyPathsToMerge(checker);
    // These vertices are merged first and then the learning start from the root as normal.
View Full Code Here

       
        final Configuration deepCopy = pta.config.copy();deepCopy.setLearnerCloneGraph(true);
        LearnerGraph ptaCopy = new LearnerGraph(deepCopy);LearnerGraph.copyGraphs(pta, ptaCopy);

        LearnerGraph trimmedReference = MarkovPassivePairSelection.trimUncoveredTransitions(pta,referenceGraph);
        final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
        long inconsistencyForTheReferenceGraph = MarkovClassifier.computeInconsistency(trimmedReference, m, checker,false);

        LearnerGraph ptaToUseForInference = pta;
        Collection<Set<CmpVertex>> verticesToMergeBasedOnInitialPTA=null;
               
View Full Code Here

    // transitions in the vicinity of the added ones. For instance, where a path has been folded in with some transitions sticking out, those new ones
    // may be inconsistent with predictions, based on the transitions in the red part of the graph.

    // mapping map to store all paths leave each state in different length
    double tentativeScore=0;
    @SuppressWarnings("rawtypes")
    ConsistencyChecker checker = new MarkovClassifier.InconsistencyNullVsPredicted();
    MarkovClassifier resultClassifier = new MarkovClassifier(cl.model,result);
    for(Entry<CmpVertex,Collection<Label>> entry:labelsAdded.entrySet())
      if (!entry.getValue().isEmpty())
      {
View Full Code Here

    LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
    int genScore = ptaClassifier.graph.pairscores.computePairCompatibilityScore_general(null, constructPairsToMergeBasedOnSetsToMerge(ptaClassifier.graph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA), verticesToMerge);
    LearnerGraph graph = MergeStates.mergeCollectionOfVertices(ptaClassifier.graph, null, verticesToMerge);
   
    Set<CmpVertex> tr=graph.transform.trimGraph(10, graph.getInit()).transitionMatrix.keySet();
    ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistency();

    constructPairsToMergeBasedOnSetsToMerge(graph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA);   
    for(CmpVertex v0:tr)
      for(CmpVertex v1:tr)
        if (v0 != v1)
View Full Code Here

        final Configuration deepCopy = pta.config.copy();deepCopy.setLearnerCloneGraph(true);
        LearnerGraph ptaCopy = new LearnerGraph(deepCopy);LearnerGraph.copyGraphs(pta, ptaCopy);

        // now use pathsToMerge to compute which states can/cannot be merged together.
        LearnerGraph trimmedReference = MarkovPassivePairSelection.trimUncoveredTransitions(pta,referenceGraph);
        final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklisting();
        //long inconsistencyForTheReferenceGraph = MarkovClassifier.computeInconsistency(trimmedReference, m, checker,false);
        //System.out.println("Inconsistency of trimmed reference : "+inconsistencyForTheReferenceGraph);
       
        //if (inconsistencyForTheReferenceGraph != 53)
        //  break;// ignore automata where we get good results.
View Full Code Here

  {
    List<StatePair> pairsList = ptaClassifier.buildVerticesToMergeForPath(pathsOfInterest);
    LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
    ptaClassifier.graph.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
    LearnerGraph merged = MergeStates.mergeCollectionOfVertices(ptaClassifier.graph, null, verticesToMerge);// after merging all paths of interest, we get this graph.
    ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistency();
    final long genScoreThreshold = 1;
    int nrOfMergers=0;
    List<StatePair> pairsToMerge = new LinkedList<StatePair>();
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:merged.transitionMatrix.entrySet())
      for(Entry<Label,CmpVertex> transition:entry.getValue().entrySet())
View Full Code Here

    LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
    int genScore = ptaClassifier.graph.pairscores.computePairCompatibilityScore_general(null, constructPairsToMergeBasedOnSetsToMerge(ptaClassifier.graph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA), verticesToMerge);
    LearnerGraph graph = MergeStates.mergeCollectionOfVertices(ptaClassifier.graph, null, verticesToMerge);
   
    Set<CmpVertex> tr=graph.transform.trimGraph(10, graph.getInit()).transitionMatrix.keySet();
    ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistency();

    constructPairsToMergeBasedOnSetsToMerge(graph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA);   
    for(CmpVertex v0:tr)
      for(CmpVertex v1:tr)
        if (v0 != v1)
View Full Code Here

       
        final Configuration deepCopy = pta.config.copy();deepCopy.setLearnerCloneGraph(true);
        LearnerGraph ptaCopy = new LearnerGraph(deepCopy);LearnerGraph.copyGraphs(pta, ptaCopy);

        LearnerGraph trimmedReference = MarkovPassivePairSelection.trimUncoveredTransitions(pta,referenceGraph);
        final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
        long inconsistencyForTheReferenceGraph = MarkovClassifier.computeInconsistency(trimmedReference, m, checker,false);

        LearnerGraph ptaToUseForInference = pta;
        Collection<Set<CmpVertex>> verticesToMergeBasedOnInitialPTA=null;
               
View Full Code Here

                              for(List<Label> seq:sMinus)
                                pta.paths.augmentPTA(seq,false,false,null);
                              final MarkovModel m= new MarkovModel(3,true,true,false);

                              new MarkovClassifier(m, pta).updateMarkov(false);// construct Markov chain if asked for.
                              final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
                           
                              pta.clearColours();
                              EDSM_MarkovLearner learner = new EDSM_MarkovLearner(learnerInitConfiguration,pta,0) {

                                @Override
                                public Stack<PairScore> ChooseStatePairs(LearnerGraph graph)
                                {
                                  reportLearningProgress(graph,message,ref,counter);
                                  // resume learning.
                                  return super.ChooseStatePairs(graph);
                                }
                              };
                              learner.setMarkov(m);learner.setChecker(checker);
                              learner.setUseNewScoreNearRoot(false);learner.setUseClassifyPairs(false);
                              learner.setDisableInconsistenciesInMergers(false);
                             
                              if (learnerInitConfiguration.graph != null)
                              {
                                learnerInitConfiguration.graph.clearColours();learnerInitConfiguration.graph.getInit().setColour(JUConstants.RED);
                                LearnerGraph.copyGraphs(learnerInitConfiguration.graph,learner.getTentativeAutomaton());
                              }
                              LearnerGraph graphLearnt = learner.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
                              outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk,  constructFSM(graphLearnt)});
                            }
                            catch(AskedToTerminateException e)
                            {
                              outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgTerminate});
                            }
                            catch(Throwable ex)
                            {
                              ex.printStackTrace();
                              outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgFailure,new OtpErlangList(ex.getMessage())});
                            }
                            mbox.send(erlangPartner,outcome);
                           
                          }
                        else
                          // Args: Ref,learn, pid
                          // pid is optional, where provided, progress messages are reported in a form of {Ref,'status',step}
                          // in the course of learning, the learner is receptive to messages directed at its normal PID, a {Ref,terminate} command will kill it and the response will be {Ref,terminate}.
                          // Response: Ref,ok,fsm
                          // on error: Ref,failure,text_of_the_error (as string)
                          if (command.equals(msgLearnEDSMMARKOVcentre) && message.arity() >= 2)
                          {
                            OtpErlangObject outcome = null;
                            try
                            {
                              final AtomicLong counter = new AtomicLong();
                              learnerInitConfiguration.config.setLearnerScoreMode(ScoreMode.ONLYOVERRIDE);
                              LearnerGraph ptaInitial=new LearnerGraph(learnerInitConfiguration.config);
                              for(List<Label> seq:sPlus)
                                ptaInitial.paths.augmentPTA(seq,true,false,null);
                              for(List<Label> seq:sMinus)
                                ptaInitial.paths.augmentPTA(seq,false,false,null);
                              final MarkovModel m= new MarkovModel(3,true,true,false);

                              final MarkovClassifier ptaClassifier = new MarkovClassifier(m, ptaInitial);ptaClassifier.updateMarkov(false);
                              LearnerGraph ptaToUseForInference = ptaInitial;
                              final ConsistencyChecker checker = new MarkovClassifier.DifferentPredictionsInconsistencyNoBlacklistingIncludeMissingPrefixes();
                              {
                                Collection<Set<CmpVertex>> verticesToMergeBasedOnInitialPTA=null;
                                final List<List<Label>> pathsToMerge=ptaClassifier.identifyPathsToMerge(checker);
                                // These vertices are merged first and then the learning start from the root as normal.
                                // The reason to learn from the root is a memory cost. if we learn from the middle, we can get a better results
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.MarkovClassifier.ConsistencyChecker

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.