Package statechum.analysis.learning

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


 
  @Test
  public void testUpdateMarkovSideways1a()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-a->C / B-b->C","testUpdateMarkovSideways1",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertEquals(4,m.predictionsMatrix.size());
    Assert.assertEquals(4,m.occurrenceMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));Assert.assertEquals(new UpdatablePairInteger(2, 0),m.occurrenceMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));Assert.assertEquals(new UpdatablePairInteger(1, 0),m.occurrenceMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
View Full Code Here


 
  @Test
  public void testUpdateMarkovSideways1b()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-a->C / B-b->C","testUpdateMarkovSideways1",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(6,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));Assert.assertEquals(new UpdatablePairInteger(2, 0),m.occurrenceMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));Assert.assertEquals(new UpdatablePairInteger(1, 0),m.occurrenceMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));Assert.assertEquals(new UpdatablePairInteger(1, 0),m.occurrenceMatrix.get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));
View Full Code Here

  @Test
  public void testUpdateMarkovSideways1c()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-a->C / B-b->C-a-#D / B-c-#D","testUpdateMarkovSideways1c",config, converter);

    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(9,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));
View Full Code Here

  /** This one is similar to the {@link #testUpdateMarkovSideways1b}, except that there are a few additional negative transitions and the computation is forward. */
  @Test
  public void testUpdateMarkovSideways1d()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-a->C / B-b->C-a-#D / B-c-#D","testUpdateMarkovSideways1c",config, converter);
    MarkovModel m = new MarkovModel(2,true,true);
    new MarkovClassifier(m,graph).updateMarkov(false);
    Assert.assertEquals(7,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.failure,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblB,lblA}),true)));

    Assert.assertEquals(MarkovOutcome.failure,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblC}),true)));
   
    Set<List<Label>> plusStrings = buildSet(new String[][] {},config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","a","a"},new String[]{"a","b","a"},new String[]{"a","c"} },config,converter);
    MarkovModel another = new MarkovModel(2,true,true);
    another.createMarkovLearner(plusStrings, minusStrings, false);

    Assert.assertEquals(7,another.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.failure,another.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,another.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.negative,another.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
View Full Code Here

  @Test
  public void testUpdateMarkovSideways2()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-c->C / B-b-#D","testUpdateMarkovSideways2",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertEquals(3,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.negative,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblC,lblB}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblC,lblC}),true)));
View Full Code Here

 
  @Test
  public void testUpdateMarkovSideways3()
  {
    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(true);
    Assert.assertEquals(9,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblA}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblC,lblA}),true)));
View Full Code Here

 
  @Test
  public void testUpdateMarkovSideways4()
  {
    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(3,false,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertEquals(6,m.predictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true)));
    Assert.assertEquals(MarkovOutcome.positive,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblA}),true)));
   
View Full Code Here

 
  @Test
  public void testUpdateMarkovSideways5()
  {
    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(4,false,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
    Assert.assertTrue(m.predictionsMatrix.isEmpty());
  }
View Full Code Here

  @Test
  public void testPredictTransitionsSideways1()
  {
    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 mSideways = new MarkovModel(2,false,true), mForward = new MarkovModel(2,true,true);
    new MarkovClassifier(mSideways,graph).updateMarkov(true);
    Assert.assertEquals(9,mSideways.predictionsMatrix.size());Assert.assertTrue(mForward.predictionsMatrix.isEmpty());
   
    List<List<Label>> interestingPaths = new LinkedList<List<Label>>();
    // nothing in Markov matrix hence no predictions.
View Full Code Here

  @Test
  public void testPredictTransitionsSideways2()
  {
    final LearnerGraph graph = FsmParser.buildLearnerGraph("A-a->B-b->C / B-u-#D / A-c->E-u->F / E-b->G","testUpdateMarkovSideways3",config, converter);
    MarkovModel m = new MarkovModel(2,false,true);
    new MarkovClassifier(m,graph).updateMarkov(true);
   
    Assert.assertEquals(8,m.predictionsMatrix.size());
   
    Assert.assertEquals(MarkovOutcome.failure,m.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{lblB,lblU}),true)));
View Full Code Here

TOP

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

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.