Package statechum.analysis.learning

Examples of statechum.analysis.learning.MarkovModel$MarkovMatrixEngine


 
  @Test
  public void testMarkovPerformance1()
  {
    final LearnerGraph trainingGraph = 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);
    MarkovClassifier cl=new MarkovClassifier(m,trainingGraph);cl.updateMarkov(false);
    statechum.Pair<Double,Double> pairTraining = cl.evaluateCorrectnessOfMarkov();
    Assert.assertEquals(2./3,pairTraining.firstElem,Configuration.fpAccuracy);// reflects that transitions u and c from G are not present but predicted
    Assert.assertEquals(2./3.,pairTraining.secondElem,Configuration.fpAccuracy);// reflects that transitions a and c are not predicted but present.
   
View Full Code Here


 
  @Test
  public void testMarkovPerformance2()
  {
    final LearnerGraph trainingGraph = 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);
    MarkovClassifier cl=new MarkovClassifier(m,trainingGraph);cl.updateMarkov(false);
   
    MarkovClassifier eval = new MarkovClassifier(m,FsmParser.buildLearnerGraph("A-a->B-u-#D / B-b->G","testMarkovPerformance2",config, converter));
    statechum.Pair<Double,Double> pair = eval.evaluateCorrectnessOfMarkov();
    Assert.assertEquals(1,pair.firstElem,Configuration.fpAccuracy);Assert.assertEquals(2./3,pair.secondElem,Configuration.fpAccuracy);// transition a is not predicted
View Full Code Here

 
  @Test
  public void testMarkovPerformance3()
  {
    final LearnerGraph trainingGraph = 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);
    MarkovClassifier cl=new MarkovClassifier(m,trainingGraph);cl.updateMarkov(false);
   
    MarkovClassifier eval = new MarkovClassifier(m,FsmParser.buildLearnerGraph("A-a->B-u-#D / B-b->G / B-e->Z","testMarkovPerformance3",config, converter));
    statechum.Pair<Double,Double> pair = eval.evaluateCorrectnessOfMarkov();
    Assert.assertEquals(1,pair.firstElem,Configuration.fpAccuracy);Assert.assertEquals(0.5,pair.secondElem,Configuration.fpAccuracy);// transition a is not predicted
View Full Code Here

 
  @Test
  public void testMarkovPerformance4()
  {
    final LearnerGraph trainingGraph = 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);
    MarkovClassifier cl=new MarkovClassifier(m,trainingGraph);cl.updateMarkov(false);
   
    MarkovClassifier eval = new MarkovClassifier(m,FsmParser.buildLearnerGraph("A-a->B-b->C-c->D-u->E","testMarkovPerformance4",config, converter));
    statechum.Pair<Double,Double> pair = eval.evaluateCorrectnessOfMarkov();
    Assert.assertEquals(3./4,pair.firstElem,Configuration.fpAccuracy);// u is predicted as negative and is indeed missing, b is correctly predicted as a positive; u after c is correctly predicted as positive and c after c is not correctly predicted.
View Full Code Here

 
  @Test
  public void testMarkovPerformance5()
  {
    final LearnerGraph trainingGraph = 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);
    MarkovClassifier cl=new MarkovClassifier(m,trainingGraph);cl.updateMarkov(false);
   
    MarkovClassifier eval = new MarkovClassifier(m,FsmParser.buildLearnerGraph("A-a->B-b->G","testMarkovPerformance5",config, converter));
    statechum.Pair<Double,Double> pair = eval.evaluateCorrectnessOfMarkov();
    Assert.assertEquals(1,pair.firstElem,Configuration.fpAccuracy);// u is predicted as negative and is indeed missing, b is correctly predicted as a positive
View Full Code Here

    Helper.checkForCorrectException(new whatToRun() {
      @SuppressWarnings("unused")
      @Override
      public void run() throws NumberFormatException
      {
        new MarkovModel(1,true,true);
      }
    }, IllegalArgumentException.class, "chunkLen");
  }
View Full Code Here

  }
 
  @Test
  public void testCreateMarkovMatrix1()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    Set<List<Label>> plusStrings = buildSet(new String[][] { new String[]{"a","b","c"}, new String[]{"a","b"}, new String[]{"a","d","c"}},config,converter), minusStrings = buildSet(new String[][] { new String[]{"a","b","c","d"}, new String[]{"a","u"} },config,converter);
    Map<Trace, MarkovOutcome> matrix = m.createMarkovLearner(plusStrings, minusStrings,false);
    Assert.assertEquals(11,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[]{lblD,lblC}),true)));
View Full Code Here

 

  @Test
  public void testCreateMarkovMatrix2()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    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()
  {
    MarkovModel m = new MarkovModel(2,true,true);
    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()
  {
    MarkovModel m = new MarkovModel(3,true,true);
    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

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.