Examples of computePredictionMatrix()


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

  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);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(11,matrix.size());
   
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblD,lblC})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblB,lblC})));
View Full Code Here

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

  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>>();
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());
   
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblU})));
View Full Code Here

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

  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);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());

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

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

  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);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());

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

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

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

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

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

  public void testCreateMarkovMatrix5()
  {
    final MarkovModel m = new MarkovModel(2,true,true);
    final Set<List<Label>> plusStrings = new HashSet<List<Label>>(), minusStrings = buildSet(new String[][] { new String[]{},new String[]{"a","u"} },config,converter);
    m.createMarkovLearner(plusStrings, minusStrings,false);
    Map<List<Label>, MarkovOutcome> matrix = m.computePredictionMatrix();
    Assert.assertEquals(3,matrix.size());
   
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblA,lblU})));
    Assert.assertSame(MarkovOutcome.positive, matrix.get(Arrays.asList(new Label[]{lblA})));
    Assert.assertSame(MarkovOutcome.negative, matrix.get(Arrays.asList(new Label[]{lblU})));
View Full Code Here

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

  public void testCheckFanoutInconsistencySideways5()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B","testCheckFanoutInconsistencySideways3",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,new MarkovClassifier(m, graph2).checkFanoutInconsistency(graph2.getInit(), new MarkovClassifier.ConsistencyChecker(){
View Full Code Here

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

  public void testCheckFanoutInconsistencySideways6()
  {
    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.computePredictionMatrix().size());
   
    final LearnerGraph graph2 = FsmParser.buildLearnerGraph("A-a->B / A-c->A","testCheckFanoutInconsistencySideways4",config, converter);
    final AtomicInteger counterA=new AtomicInteger(0),counterB=new AtomicInteger(0);
    Assert.assertEquals(0,new MarkovClassifier(m, graph2).checkFanoutInconsistency(graph2.getInit(), new MarkovClassifier.ConsistencyChecker(){
View Full Code Here

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

    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 gives almost the same result. The difference is in PTA-based construction mis-counting the number of times shorter traces occur since it
   * can see that they exist but not the number of tails they lead to. This is left in because I do not use specific values occurrence counts.
View Full Code Here

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

    m.createMarkovLearner(plusStrings, minusStrings,false);

    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(false);
    Assert.assertEquals(m.computePredictionMatrix(),mOther.computePredictionMatrix());
   
    // Workaround around a deficiency in the calculation of occurrences of prefixes by the PTA-based construction of Markov model.
    Assert.assertEquals(new UpdatablePairInteger(2, 0), m.computeOccurrenceMatrix().get(Arrays.asList(new Label[]{lblA})));
    Assert.assertEquals(new UpdatablePairInteger(1, 0), mOther.computeOccurrenceMatrix().get(Arrays.asList(new Label[]{lblA})));
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.