/** * Trains a GIS model on the event in the specified event stream, using the specified number * of iterations and the specified count cutoff. * @param eventStream A stream of all events. * @param iterations The number of iterations to use for GIS. * @param cutoff The number of times a feature must occur to be included. * @return A GIS model trained with specified */ public GISModel trainModel(EventStream eventStream, int iterations, int cutoff) throws IOException { return trainModel(iterations, new OnePassDataIndexer(eventStream,cutoff),cutoff); }
/** * Two argument constructor for DataIndexer. * * @param eventStream * An Event[] which contains the a list of all the Events seen in the * training data. * @param cutoff * The minimum number of times a predicate must have been observed in * order to be included in the model. */ public OnePassDataIndexer(EventStream eventStream, int cutoff, boolean sort) throws IOException { Map<String, Integer> predicateIndex = new HashMap<String, Integer>(); LinkedList<Event> events; List<ComparableEvent> eventsToCompare; System.out.println("Indexing events using cutoff of " + cutoff + "\n"); System.out.print("\tComputing event counts... "); events = computeEventCounts(eventStream, predicateIndex, cutoff); System.out.println("done. " + events.size() + " events"); System.out.print("\tIndexing... "); eventsToCompare = index(events, predicateIndex); // done with event list events = null; // done with predicates predicateIndex = null; System.out.println("done."); System.out.print("Sorting and merging events... "); sortAndMerge(eventsToCompare, sort); System.out.println("Done indexing."); }
protected int sortAndMerge(List<ComparableEvent> eventsToCompare,boolean sort) { int numUniqueEvents = super.sortAndMerge(eventsToCompare,sort); values = new float[numUniqueEvents][]; int numEvents = eventsToCompare.size(); for (int i = 0, j = 0; i < numEvents; i++) { ComparableEvent evt = (ComparableEvent) eventsToCompare.get(i); if (null == evt) { continue; // this was a dupe, skip over it. } values[j++] = evt.values; } return numUniqueEvents; }
Event ev = eventStream.next(); events.addLast(ev); update(ev.getContext(), predicateSet, counter, cutoff);
outcomeLabels = toIndexedStringArray(omap); predLabels = toIndexedStringArray(predicateIndex); return eventsToCompare;
protected int sortAndMerge(List<ComparableEvent> eventsToCompare,boolean sort) { int numUniqueEvents = super.sortAndMerge(eventsToCompare,sort); values = new float[numUniqueEvents][]; int numEvents = eventsToCompare.size(); for (int i = 0, j = 0; i < numEvents; i++) { ComparableEvent evt = (ComparableEvent) eventsToCompare.get(i); if (null == evt) { continue; // this was a dupe, skip over it. } values[j++] = evt.values; } return numUniqueEvents; }
Event ev = eventStream.next(); events.addLast(ev); update(ev.getContext(), predicateSet, counter, cutoff);
outcomeLabels = toIndexedStringArray(omap); predLabels = toIndexedStringArray(predicateIndex); return eventsToCompare;
/** * Trains a GIS model on the event in the specified event stream, using the specified number * of iterations and the specified count cutoff. * @param eventStream A stream of all events. * @param iterations The number of iterations to use for GIS. * @param cutoff The number of times a feature must occur to be included. * @return A GIS model trained with specified */ public GISModel trainModel(EventStream eventStream, int iterations, int cutoff) throws IOException { return trainModel(iterations, new OnePassDataIndexer(eventStream,cutoff),cutoff); }
/** * Two argument constructor for DataIndexer. * * @param eventStream * An Event[] which contains the a list of all the Events seen in the * training data. * @param cutoff * The minimum number of times a predicate must have been observed in * order to be included in the model. */ public OnePassDataIndexer(EventStream eventStream, int cutoff, boolean sort) throws IOException { Map<String, Integer> predicateIndex = new HashMap<String, Integer>(); LinkedList<Event> events; List<ComparableEvent> eventsToCompare; System.out.println("Indexing events using cutoff of " + cutoff + "\n"); System.out.print("\tComputing event counts... "); events = computeEventCounts(eventStream, predicateIndex, cutoff); System.out.println("done. " + events.size() + " events"); System.out.print("\tIndexing... "); eventsToCompare = index(events, predicateIndex); // done with event list events = null; // done with predicates predicateIndex = null; System.out.println("done."); System.out.print("Sorting and merging events... "); sortAndMerge(eventsToCompare, sort); System.out.println("Done indexing."); }
/** * Trains a GIS model on the event in the specified event stream, using the * specified number of iterations and the specified count cutoff. * * @param eventStream * A stream of all events. * @param iterations * The number of iterations to use for GIS. * @param cutoff * The number of times a feature must occur to be included. * @return A GIS model trained with specified */ public GISModel trainModel(EventStream eventStream, int iterations, int cutoff) throws IOException { return trainModel(iterations, new OnePassDataIndexer(eventStream, cutoff), cutoff); }
model = new PerceptronTrainer().trainModel(maxit, new OnePassDataIndexer(es, cutoff), cutoff);
model = new PerceptronTrainer().trainModel(maxit, new OnePassDataIndexer(es, cutoff), cutoff);
indexer = new OnePassDataIndexer(hses, cutoff, sortAndMerge);
indexer = new OnePassDataIndexer(hses, cutoff, sortAndMerge);
public AbstractModel trainModel(int iterations, SequenceStream sequenceStream, int cutoff, boolean useAverage) throws IOException { this.iterations = iterations; this.sequenceStream = sequenceStream; DataIndexer di = new OnePassDataIndexer(new SequenceStreamEventStream(sequenceStream),cutoff,false); numSequences = 0; for (Sequence s : sequenceStream) {
public AbstractModel trainModel(int iterations, SequenceStream sequenceStream, int cutoff, boolean useAverage) throws IOException { this.iterations = iterations; this.sequenceStream = sequenceStream; DataIndexer di = new OnePassDataIndexer(new SequenceStreamEventStream(sequenceStream),cutoff,false); numSequences = 0; for (Sequence s : sequenceStream) {