Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovModel$MarkovMatrixEngine


   */
  @Test
  public void testPredictTransitionsFromStatesWithPathBeyondCurrentState4()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,true,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertEquals(4,m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-d->B / A-c->A/ T-u->T-b->T","testPredictTransitionsFromStatesForward2",config, converter);
    Map<Label,MarkovOutcome> outgoing_labels_probabilities=new MarkovClassifier(m, graph2).predictTransitionsFromState(graph2.findVertex("B"),Arrays.asList(new Label[]{lblA}),m.getChunkLen(),null);
    Assert.assertEquals(2,outgoing_labels_probabilities.size());
    Assert.assertEquals(MarkovOutcome.negative,outgoing_labels_probabilities.get(lblU));
    Assert.assertEquals(MarkovOutcome.positive,outgoing_labels_probabilities.get(lblB));
  }
View Full Code Here


   */
  @Test
  public void testPredictTransitionsFromStatesWithPathBeyondCurrentState5()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    final MarkovModel m = new MarkovModel(2,true,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertEquals(4,m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-d->B / A-c->A/ T-u->T-b->T","testPredictTransitionsFromStatesForward2",config, converter);
    Helper.checkForCorrectException(new whatToRun() {
      @Override
      public void run() throws NumberFormatException
      {
        new MarkovClassifier(m, graph2).predictTransitionsFromState(graph2.findVertex("B"),Arrays.asList(new Label[]{lblA,lblB}),m.getChunkLen(),null);
      }
    }, IllegalArgumentException.class, "supplied path");
  }
View Full Code Here

  /** Here we look for path "s" in Markov that has never been seen, hence we cannot do much about it and it is being ignored. */
  @Test
  public void testCheckFanoutInconsistencySideways1_s()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-s->B","testCheckFanoutInconsistencySideways1",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  /** Here we look for path "s" in Markov that has never been seen, hence we cannot do much about it and it is being ignored. */
  @Test
  public void testCheckFanoutInconsistencySideways1_a()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways1",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  /** Checks that where we did not build prefix-closed paths, nothing can be predicted because we check whether shorter chunklen-1 -long paths exist and ignore anything where such paths do not exist. */
  @Test
  public void testCheckFanoutInconsistencySideways2()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B-a->B-b->B","testCheckFanoutInconsistencySideways2",config, converter);
    graph2.transitionMatrix.get(graph2.getInit()).clear();// make it look like a graph has no transitions
View Full Code Here

 
  @Test
  public void testCheckFanoutInconsistencySideways3()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways3",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  /** Similar to 3 but with multiple outgoing paths. */
  @Test
  public void testCheckFanoutInconsistencySideways4()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  /** Tests that with only one path, we do a single check anyway, hence returning false from obtainAlphabet does not change anything. */
  @Test
  public void testCheckFanoutInconsistencySideways5()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways3",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  /** Tests that upon a label labelled as invalid, subsequent inconsistency checks are stopped. It is hence equivalent to a single incoming path. */
  @Test
  public void testCheckFanoutInconsistencySideways6()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-c->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9+graph.getCache().getAlphabet().size(),m.predictionsMatrix.size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
View Full Code Here

  {
    LearnerGraph gr=FsmParser.buildLearnerGraph("A-a->B / A-b->A / B-a->C-b->D-a->E / D-c->D / E-c->E","testBuildVerticesToMergeForPath1",config, converter);
    Collection<List<Label>> paths = new LinkedList<List<Label>>();paths.add(Arrays.asList(new Label[]{lblA}));paths.add(Arrays.asList(new Label[]{lblB}));paths.add(Arrays.asList(new Label[]{lblC}));
   
    //for(LearnerGraph g:grForPaths.values())  System.out.println(g.transitionMatrix);
    Collection<Set<CmpVertex>> collectionOfSets=new MarkovClassifier(new MarkovModel(2,true,true),gr).buildVerticesToMergeForPaths(paths);
    Assert.assertEquals(1,collectionOfSets.size());
    Assert.assertEquals(gr.transitionMatrix.keySet(), collectionOfSets.iterator().next());
  }
View Full Code Here

TOP

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

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.