Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovModel$MarkovMatrixEngine$PredictionForSequence


 
  /** One inconsistency: transition u. */
  @Test
  public void testCheckFanoutInconsistency3()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B / A-c->B-u->C / T-b->T-u->T","testCheckFanoutInconsistency3",config, converter);
   
    Assert.assertEquals(1,new MarkovClassifier(m,graph).checkFanoutInconsistency(graph.findVertex("B"),new MarkovClassifier.DifferentPredictionsInconsistency()));
  }
View Full Code Here


 
  /** No inconsistencies since there are very few paths. */
  @Test
  public void testCheckFanoutInconsistency4()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"},new String[]{"c","b"},new String[]{"c","u"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->D-b->C / A-c->B-b->C / B-u->E / T-b->T-u->T","testCheckFanoutInconsistency4",config, converter);
   
   
    Assert.assertEquals(0,new MarkovClassifier(m,graph).checkFanoutInconsistency(graph.findVertex("B"),new MarkovClassifier.DifferentPredictionsInconsistency()));// everything as expected.
    Assert.assertEquals(0,new MarkovClassifier(m,graph).checkFanoutInconsistency(graph.findVertex("D"),new MarkovClassifier.DifferentPredictionsInconsistency()));// missing reject-transition with label u is ignored because we are only considering actual outgoing transitions
View Full Code Here

    final Collection<List<Label>> pathsToMerge2=identifyPathsToMerge(merged,referenceGraph,m,!directionForwardOrInverse);
    /*
    m.updateMarkov(merged,predictForwardOrSideways,false);// now we construct sideways learner ...
    m.constructMarkovTentative(graph,predictForwardOrSideways);// ... and use it to add more transitions.
    */
    MarkovModel inverseModel = new MarkovModel(ptaClassifier.model.getChunkLen(),true,!ptaClassifier.model.directionForwardOrInverse);
    MarkovClassifier cl = new MarkovClassifier(inverseModel,ptaClassifier.graph);cl.updateMarkov(false);
    Collection<Set<CmpVertex>> verticesToMergeUsingSideways=cl.buildVerticesToMergeForPaths(pathsOfInterest);
    return verticesToMergeUsingSideways;
  }
View Full Code Here

            return !((statechum.analysis.learning.rpnicore.RandomPathGenerator.StateName)name).accept;
          }
        });
        assert sPlus.size() > 0;
        assert sMinus.size() > 0;
        final MarkovModel m= new MarkovModel(chunkLen,true,true);
        m.createMarkovLearner(sPlus, sMinus,false);
       
        pta.clearColours();
        synchronized (AbstractLearnerGraph.syncObj) {
          //PaperUAS.computePTASize(selectionID+" attempt: "+attempt+" with unique: ", pta, referenceGraph);
        }
View Full Code Here

    Helper.checkForCorrectException(new whatToRun() {
      @SuppressWarnings("unused")
      @Override
      public void run() throws NumberFormatException
      {
        new MarkovModel(1,true,true);
      }
    }, IllegalArgumentException.class, "chunkLen");
  }
View Full Code Here

  }
 
  @Test
  public void testCreateMarkovMatrix1()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b","c"}, new String[]{"a","b"}, new String[]{"a","d","c"}},config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","b","c","d"}, new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(11,matrix.size());
   
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblD,lblC})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblB,lblC})));
View Full Code Here

 

  @Test
  public void testCreateMarkovMatrix2()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter), minusStrings = new HashSet<List<Label>>();
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());
   
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblU})));
View Full Code Here

  }
 
  @Test
  public void testCreateMarkovMatrix3a()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());

    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA})));
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblU})));
View Full Code Here

 
  /** Only differs from 3a by the use of chunk_length of 3. The outcome should be the same. */
  @Test
  public void testCreateMarkovMatrix3b()
  {
    MarkovModel m = new MarkovModel(3,true,true);
    Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());

    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA})));
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblU})));
View Full Code Here

    Helper.checkForCorrectException(new whatToRun() {
      @SuppressWarnings("unused")
      @Override
      public void run() throws NumberFormatException
      {
        new MarkovModel(1,true,true);
      }
    }, IllegalArgumentException.class, "chunkLen");
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.MarkovModel$MarkovMatrixEngine$PredictionForSequence

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.