Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovClassifier$DifferentPredictionsInconsistencyAcrossAllElementsOfAlphabet


  @Test
  public void testPredictTransitionsFromStatesSideways1()
  {
    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 / T-u->T-b->T","testCheckFanoutInconsistencySideways4",config, converter);// T is there to ensure that graph2's alphabet is the same as that of graph.
    Map<Label, MarkovOutcome> predictions = new MarkovClassifier(m,graph2).predictTransitionsFromState(graph2.getInit(),null,m.getChunkLen(),null);
   
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblU));
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblC));
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblA));
  }
View Full Code Here


  {
    MarkovModel m = new MarkovModel(2,true,true);
    Assert.assertTrue(m.predictionsMatrix.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

  @Test
  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.predictionsMatrix.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
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(graph2.findVertex("A")).get(lblC));
    Assert.assertEquals(MarkovOutcome.negative,predictions.get(graph2.findVertex("B")).get(lblU));
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(graph2.findVertex("B")).get(lblB));
View Full Code Here

  @Test
  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.predictionsMatrix.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();
    Assert.assertTrue(predictions.isEmpty());
  }
View Full Code Here

  @Test
  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.predictionsMatrix.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

  @Test
  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.predictionsMatrix.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

  @Test
  public void testPredictTransitionsFromStatesSideways3()
  {
    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());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / T-a->T-u->T-b->T-c->T","testPredictTransitionsFromStatesSideways3",config, converter);
    LearnerGraph extendedGraph = new MarkovClassifier(m,graph2).constructMarkovTentative();
    Assert.assertNull(WMethod.checkM(FsmParser.buildLearnerGraph("A-a->B / A-c->F","testPredictTransitionsFromStatesForward3",config, converter), extendedGraph));// FSM comparison ignores unreachable states here
    Assert.assertTrue(extendedGraph.findVertex("T") != null);// extended graph starts as a replica of an original one.
  }
View Full Code Here

  @Test
  public void testPredictTransitionsFromStatesWithPathBeyondCurrentState1()
  {
    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 / T-u->T-b->T","testCheckFanoutInconsistencySideways4",config, converter);// T is there to ensure that graph2's alphabet is the same as that of graph.
    Map<Label, MarkovOutcome> predictions = new MarkovClassifier(m, graph2).predictTransitionsFromState(graph2.getInit(),Arrays.asList(new Label[]{}),m.getChunkLen(),null);
   
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblU));
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblC));
    Assert.assertEquals(MarkovOutcome.positive,predictions.get(lblA));
  }
View Full Code Here

  @Test
  public void testPredictTransitionsFromStatesWithPathBeyondCurrentState2()
  {
    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,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","testPredictTransitionsFromStatesWithPathBeyondCurrentState2",config, converter);
   
    Helper.checkForCorrectException(new whatToRun() {
      @Override
      public void run() throws NumberFormatException
      {
        new MarkovClassifier(m, graph2).predictTransitionsFromState(graph2.getInit(),Arrays.asList(new Label[]{lblC}),m.getChunkLen(),null);
      }
    }, IllegalArgumentException.class, "cannot be made by extension");
  }
View Full Code Here

  @Test
  public void testPredictTransitionsFromStatesWithPathBeyondCurrentState3()
  {
    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-a->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[]{}),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

TOP

Related Classes of statechum.analysis.learning.MarkovClassifier$DifferentPredictionsInconsistencyAcrossAllElementsOfAlphabet

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.