Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovUniversalLearner$MarkovOutcome


  /** Same as {@link #testPredictTransitionsFromStatesSideways1()}, except that the path beyond is non-empty. */
  @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 MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.predictTransitionsAndUpdateMarkov(graph,false,true);
    Assert.assertTrue(m.getMarkov(true).isEmpty());
    Assert.assertEquals(9,m.getMarkov(false).size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testPredictTransitionsFromStatesWithPathBeyondCurrentState2",config, converter);
    final Map<Trace, MarkovOutcome> markovMatrix = m.getMarkov(false);
   
    Helper.checkForCorrectException(new whatToRun() {
      @Override
      public void run() throws NumberFormatException
      {
        MarkovUniversalLearner.predictTransitionsFromState(markovMatrix,graph2,false,graph2.getInit(),graph.pathroutines.computeAlphabet(),Arrays.asList(new Label[]{lblC}),m.getChunkLen(),null);
      }
    }, IllegalArgumentException.class, "cannot be made by extension");
  }
View Full Code Here


  /** Almost the same as {@link #testPredictTransitionsFromStatesForward2()} except that the path beyond is empty rather than null. */
  @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);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.predictTransitionsAndUpdateMarkov(graph,true,true);
    Assert.assertEquals(4,m.getMarkov(true).size());
    Assert.assertTrue(m.getMarkov(false).isEmpty());
    final Map<Trace, MarkovOutcome> markovMatrix = m.getMarkov(true);
   
    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=m.predictTransitionsFromState(markovMatrix,m.computeInverseGraph(graph2, true),true,graph2.findVertex("B"),graph2.getCache().getAlphabet(),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

   */
  @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);
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    m.predictTransitionsAndUpdateMarkov(graph,true,true);
    Assert.assertEquals(4,m.getMarkov(true).size());
    Assert.assertTrue(m.getMarkov(false).isEmpty());
    final Map<Trace, MarkovOutcome> markovMatrix = m.getMarkov(true);

   
    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=m.predictTransitionsFromState(markovMatrix,m.computeInverseGraph(graph2, true),true,graph2.findVertex("B"),graph2.getCache().getAlphabet(),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 testCreateMarkovMatrix2()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter), minusStrings = new HashSet<List<Label>>();
    Map<Trace, MarkovOutcome> matrix = m.createMarkovLearner(plusStrings, minusStrings,false);
    Assert.assertEquals(3,matrix.size());
   
    Assert.assertSame(MarkovOutcome.positive, matrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblU}),true)));

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

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

    Assert.assertSame(MarkovOutcome.negative, matrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblU}),true)));

    Assert.assertSame(MarkovOutcome.positive, matrix.get(new Trace(Arrays.asList(new Label[]{lblA}),true)));
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()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(3);
    Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{"a","u"} },config,converter);
    Map<Trace, MarkovOutcome> matrix = m.createMarkovLearner(plusStrings, minusStrings,false);
    Assert.assertEquals(3,matrix.size());

    Assert.assertSame(MarkovOutcome.negative, matrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblU}),true)));

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

  }
 
  @Test
  public void testCreateMarkovMatrix4()
  {
    MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{"u"} },config,converter);
    Map<Trace, MarkovOutcome> matrix = m.createMarkovLearner(plusStrings, minusStrings,false);
    Assert.assertEquals(1,matrix.size());

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

 
  /** Same as testCreateMarkovMatrix3 but contains an empty trace which is ignored since it does not match any of the valid chunk sizes. */
  @Test
  public void testCreateMarkovMatrix5()
  {
    final MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    final Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{},new String[]{"a","u"} },config,converter);
    Map<Trace, MarkovOutcome> matrix = m.createMarkovLearner(plusStrings, minusStrings,false);
    Assert.assertEquals(3,matrix.size());
   
    Assert.assertSame(MarkovOutcome.negative, matrix.get(new Trace(Arrays.asList(new Label[]{lblA,lblU}),true)));

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

  }
 
  @Test
  public void testCreateMarkovMatrix6()
  {
    final MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    final Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = new HashSet<List<Label>>();
    Helper.checkForCorrectException(new whatToRun() {
      @Override
      public void run() throws NumberFormatException
      {
        m.createMarkovLearner(plusStrings, minusStrings,false);
      }
    }, IllegalArgumentException.class, "empty");
  }
View Full Code Here

  }
 
  @Test
  public void testCreateMarkovMatrix7()
  {
    final MarkovUniversalLearner m = new MarkovUniversalLearner(2);
    final Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{},new String[]{} },config,converter);
    Helper.checkForCorrectException(new whatToRun() {
      @Override
      public void run() throws NumberFormatException
      {
        m.createMarkovLearner(plusStrings, minusStrings,false);
      }
    }, IllegalArgumentException.class, "empty");
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.MarkovUniversalLearner$MarkovOutcome

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.