Changeset 22 for trunk/EventBenchCore/src/de/ugoe
- Timestamp:
- 04/14/11 11:56:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java
r16 r22 1 1 package de.ugoe.cs.eventbench.models; 2 2 3 import java.util.ArrayList;4 3 import java.util.LinkedList; 5 4 import java.util.List; … … 7 6 8 7 import de.ugoe.cs.eventbench.data.Event; 9 import de.ugoe.cs.util.console.Console;10 8 11 9 public class PredictionByPartialMatch extends TrieBasedModel { … … 62 60 return result; 63 61 } 64 65 public void testStuff() {66 // basically an inline unit test without assertions but manual observation67 List<Event<?>> list = new ArrayList<Event<?>>();68 list.add(new Event<Object>("a"));69 list.add(new Event<Object>("b"));70 list.add(new Event<Object>("r"));71 list.add(new Event<Object>("a"));72 list.add(new Event<Object>("c"));73 list.add(new Event<Object>("a"));74 list.add(new Event<Object>("d"));75 list.add(new Event<Object>("a"));76 list.add(new Event<Object>("b"));77 list.add(new Event<Object>("r"));78 list.add(new Event<Object>("a"));79 80 int maxOrder = 3;81 PredictionByPartialMatch model = new PredictionByPartialMatch(maxOrder, new Random());82 model.trie = new Trie<Event<?>>();83 model.trie.train(list, maxOrder);84 model.trie.display();85 86 List<Event<?>> context = new ArrayList<Event<?>>();87 Event<Object> symbol = new Event<Object>("a");88 // expected: 589 Console.traceln(""+model.trie.getCount(context, symbol));90 91 // expected: 092 context.add(new Event<Object>("b"));93 Console.traceln(""+model.trie.getCount(context, symbol));94 95 // expected: 296 context.add(new Event<Object>("r"));97 Console.traceln(""+model.trie.getCount(context, symbol));98 99 // exptected: [b, r]100 context = new ArrayList<Event<?>>();101 context.add(new Event<Object>("a"));102 context.add(new Event<Object>("b"));103 context.add(new Event<Object>("r"));104 Console.traceln(model.trie.getContextSuffix(context).toString());105 106 // exptected: []107 context = new ArrayList<Event<?>>();108 context.add(new Event<Object>("e"));109 Console.traceln(model.trie.getContextSuffix(context).toString());110 111 // exptected: {a, b, c, d, r}112 context = new ArrayList<Event<?>>();113 Console.traceln(model.trie.getFollowingSymbols(context).toString());114 115 // exptected: {b, c, d}116 context = new ArrayList<Event<?>>();117 context.add(new Event<Object>("a"));118 Console.traceln(model.trie.getFollowingSymbols(context).toString());119 120 // exptected: []121 context = new ArrayList<Event<?>>();122 context.add(new Event<Object>("a"));123 context.add(new Event<Object>("b"));124 context.add(new Event<Object>("r"));125 Console.traceln(model.trie.getFollowingSymbols(context).toString());126 127 // exptected: 0.0d128 context = new ArrayList<Event<?>>();129 context.add(new Event<Object>("a"));130 Console.traceln(""+model.getProbability(context, new Event<Object>("z")));131 }132 62 }
Note: See TracChangeset
for help on using the changeset viewer.