Examples of computePredictionMatrix()


Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

    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[][] {},config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,true);

    final LearnerGraph graph = new LearnerGraph(config);graph.paths.augmentPTA(plusStrings, true, false);graph.paths.augmentPTA(minusStrings, false, false);
    MarkovModel mOther = new MarkovModel(2,true,true);new MarkovClassifier(mOther,graph).updateMarkov(true);
    Assert.assertEquals(m.computePredictionMatrix(),mOther.computePredictionMatrix());
    Assert.assertEquals(m.computeOccurrenceMatrix(),mOther.computeOccurrenceMatrix());
  }
 
  /** Tests that creating a model from PTA and from initial traces give the same result. */
  @Test
 
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

    Set<List<Label>> plusStrings = buildSet(new String[][] {},config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,true);

    final LearnerGraph graph = new LearnerGraph(config);graph.paths.augmentPTA(plusStrings, true, false);graph.paths.augmentPTA(minusStrings, false, false);
    MarkovModel mOther = new MarkovModel(2,true,true);new MarkovClassifier(mOther,graph).updateMarkov(true);
    Assert.assertEquals(m.computePredictionMatrix(),mOther.computePredictionMatrix());
    Assert.assertEquals(m.computeOccurrenceMatrix(),mOther.computeOccurrenceMatrix());
  }
 
  @Test
  /** Tests that creating a model from PTA and from initial traces give the same result. */
 
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b"} },config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,true);

    final LearnerGraph graph = new LearnerGraph(config);graph.paths.augmentPTA(plusStrings, true, false);graph.paths.augmentPTA(minusStrings, false, false);
    MarkovModel mOther = new MarkovModel(2,true,true);new MarkovClassifier(mOther,graph).updateMarkov(true);
    Assert.assertEquals(m.computePredictionMatrix(),mOther.computePredictionMatrix());
    Assert.assertEquals(m.computeOccurrenceMatrix(),mOther.computeOccurrenceMatrix());
  }
 
  @Test
  public void testUpdateMarkovSideways1a()
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  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);
    Map<List<Label>,UpdatablePairInteger> mOccurrenceMatrix = m.computeOccurrenceMatrix();Map<List<Label>,MarkovOutcome> mPredictionsMatrix = m.computePredictionMatrix();
    Assert.assertEquals(4,mPredictionsMatrix.size());
    Assert.assertEquals(4,mOccurrenceMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblA,lblA})));Assert.assertEquals(new UpdatablePairInteger(2, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblA,lblA})));
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblA,lblB})));Assert.assertEquals(new UpdatablePairInteger(1, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblA,lblB})));
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblB,lblA})));Assert.assertEquals(new UpdatablePairInteger(1, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblB,lblA})));
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  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);
    Map<List<Label>,UpdatablePairInteger> mOccurrenceMatrix = m.computeOccurrenceMatrix();Map<List<Label>,MarkovOutcome> mPredictionsMatrix = m.computePredictionMatrix();
    Assert.assertEquals(6,mPredictionsMatrix.size());
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblA,lblA})));Assert.assertEquals(new UpdatablePairInteger(2, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblA,lblA})));
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblA,lblB})));Assert.assertEquals(new UpdatablePairInteger(1, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblA,lblB})));
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblB,lblA})));Assert.assertEquals(new UpdatablePairInteger(1, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblB,lblA})));
    Assert.assertEquals(MarkovOutcome.positive,mPredictionsMatrix.get(Arrays.asList(new Label[]{lblB,lblB})));Assert.assertEquals(new UpdatablePairInteger(1, 0),mOccurrenceMatrix.get(Arrays.asList(new Label[]{lblB,lblB})));
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

 
  @Test
  public void testPredictTransitionsFromStatesForward1()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Assert.assertTrue(m.computePredictionMatrix().isEmpty());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> predictions = new MarkovClassifier(m, graph2).predictTransitions();
    Assert.assertTrue(predictions.isEmpty());// empty Markov means no predictions.
  }
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  public void testPredictTransitionsFromStatesForward2a()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A/ T-u->T-b->T","testPredictTransitionsFromStatesForward2",config, converter);
    Map<CmpVertex, Map<Label, MarkovOutcome>> predictions = new MarkovClassifier(m, graph2).predictTransitions();
    Assert.assertEquals(2,predictions.size());Assert.assertEquals(2,predictions.get(graph2.findVertex("A")).size());Assert.assertEquals(2,predictions.get(graph2.findVertex("B")).size());
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(graph2.findVertex("A")).get(lblU));// because c is looping in the A state
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  public void testPredictTransitionsFromStatesForward2b()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = new LearnerGraph(config);graph2.getInit().setAccept(false);
    Map<CmpVertex, Map<Label, MarkovOutcome>> predictions = new MarkovClassifier(m, graph2).predictTransitions();
    Assert.assertTrue(predictions.isEmpty());
    predictions = new MarkovClassifier(new MarkovModel(2,false,true),graph2).predictTransitions();
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  public void testPredictTransitionsFromStatesForward3()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A/ T-a->T-u->T-b->T","testPredictTransitionsFromStatesForward2",config, converter);
    LearnerGraph extendedGraph = new MarkovClassifier(m,graph2).constructMarkovTentative();
    Assert.assertNull(WMethod.checkM(FsmParser.buildLearnerGraph("A-a->B / A-c->A / A-u->E / B-b->C / B-u-#D","testPredictTransitionsFromStatesForward3",config, converter), extendedGraph));
    Assert.assertTrue(extendedGraph.findVertex("T") != null);// extended graph starts as a replica of an original one.
View Full Code Here

Examples of statechum.analysis.learning.MarkovModel.computePredictionMatrix()

  public void testPredictTransitionsFromStatesSideways2()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways4",config, converter);
    LearnerGraph extendedGraph = new MarkovClassifier(m,graph2).constructMarkovTentative();
    Assert.assertNull(WMethod.checkM(graph2,extendedGraph));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.