public MultiIterator () { this.i = lists.length == 0 ? null : lists[0].iterator (); }
public MultiIterator () { this.i = lists.length == 0 ? null : lists[0].iterator (); }
public MultiIterator () { this.i = lists.length == 0 ? null : lists[0].iterator (); }
public String toString () { StringBuffer buf = new StringBuffer (); buf.append ("["); for (int listIndex = 0; listIndex < this.lists.length; listIndex++) { if (this.lists[listIndex] != null) { Iterator<Instance> i = this.lists[listIndex].iterator (); boolean hasNext = i.hasNext (); while (hasNext) { Instance o = i.next (); buf.append (String.valueOf (o)); hasNext = i.hasNext (); if (listIndex < this.lists.length || hasNext) { buf.append (", "); } } } } buf.append ("]"); return buf.toString (); }
public String toString () { StringBuffer buf = new StringBuffer (); buf.append ("["); for (int listIndex = 0; listIndex < this.lists.length; listIndex++) { if (this.lists[listIndex] != null) { Iterator<Instance> i = this.lists[listIndex].iterator (); boolean hasNext = i.hasNext (); while (hasNext) { Instance o = i.next (); buf.append (String.valueOf (o)); hasNext = i.hasNext (); if (listIndex < this.lists.length || hasNext) { buf.append (", "); } } } } buf.append ("]"); return buf.toString (); }
public Instance next () { if (this.index < lists.length) { if (this.i.hasNext ()) { return this.i.next (); } for (this.index++; this.index < lists.length; this.index++) { final InstanceList list = lists[this.index]; if (list != null && lists[this.index].size () > 0) { this.i = lists[this.index].iterator (); return this.i.next (); } } } throw new NoSuchElementException (); }
public Instance next () { if (this.index < lists.length) { if (this.i.hasNext ()) { return this.i.next (); } for (this.index++; this.index < lists.length; this.index++) { final InstanceList list = lists[this.index]; if (list != null && lists[this.index].size () > 0) { this.i = lists[this.index].iterator (); return this.i.next (); } } } throw new NoSuchElementException (); }
public Instance next () { if (this.index < lists.length) { if (this.i.hasNext ()) { return this.i.next (); } for (this.index++; this.index < lists.length; this.index++) { final InstanceList list = lists[this.index]; if (list != null && lists[this.index].size () > 0) { this.i = lists[this.index].iterator (); return this.i.next (); } } } throw new NoSuchElementException (); }
public int getSampleCount() { int count = 0; Iterator<?> it = instanceList.iterator(); while (it.hasNext()) { Instance instance = (Instance) it.next(); Object data = instance.getData(); if (data instanceof FeatureVectorSequence) { FeatureVectorSequence fvs = (FeatureVectorSequence) data; count += fvs.size(); } } return count; }
/** * Returns the next training/testing split. * @return A pair of lists, where <code>InstanceList[0]</code> is the larger split (training) * and <code>InstanceList[1]</code> is the smaller split (testing) */ public InstanceList[] nextSplit () { InstanceList[] ret = new InstanceList[2]; ret[0] = new InstanceList (pipe); for (int i=0; i < folds.length; i++) { if (i==index) continue; Iterator<Instance> iter = folds[i].iterator(); while (iter.hasNext()) ret[0].add (iter.next()); } ret[1] = folds[index].shallowClone(); index++; return ret; }
/** * Returns the next training/testing split. * @return A pair of lists, where <code>InstanceList[0]</code> is the larger split (training) * and <code>InstanceList[1]</code> is the smaller split (testing) */ public InstanceList[] nextSplit () { InstanceList[] ret = new InstanceList[2]; ret[0] = new InstanceList (pipe); for (int i=0; i < folds.length; i++) { if (i==index) continue; Iterator<Instance> iter = folds[i].iterator(); while (iter.hasNext()) ret[0].add (iter.next()); } ret[1] = folds[index].shallowClone(); index++; return ret; }
private static SparseVector mean(InstanceList instances, SparseVector meanVector) { if (instances == null || instances.size() == 0) return null; Instance instance; SparseVector v; Iterator<Instance> instanceItr = instances.iterator(); double factor = 1.0 / (double) instances.size(); while (instanceItr.hasNext()) { instance = (Instance) instanceItr.next(); v = (SparseVector) (instance.getData()); meanVector.plusEqualsSparse(v, factor); } return meanVector; }
private static SparseVector mean(InstanceList instances, SparseVector meanVector) { if (instances == null || instances.size() == 0) return null; Instance instance; SparseVector v; Iterator<Instance> instanceItr = instances.iterator(); double factor = 1.0 / (double) instances.size(); while (instanceItr.hasNext()) { instance = (Instance) instanceItr.next(); v = (SparseVector) (instance.getData()); meanVector.plusEqualsSparse(v, factor); } return meanVector; }
public static TestResults computeTestResults (InstanceList testList, List returnedList) { TestResults results = new TestResults (testList); Iterator it1 = testList.iterator (); Iterator it2 = returnedList.iterator (); while (it1.hasNext ()) { Instance inst = (Instance) it1.next (); // System.out.println ("\n\nInstance"); LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget (); LabelsSequence target = lblseq.getLabelsSequence (); LabelsSequence returned = (LabelsSequence) it2.next (); // System.out.println (target); compareLabelings (results, returned, target); } results.computeStatistics (); return results; }
public static TestResults computeTestResults (InstanceList testList, List returnedList) { TestResults results = new TestResults (testList); Iterator it1 = testList.iterator (); Iterator it2 = returnedList.iterator (); while (it1.hasNext ()) { Instance inst = (Instance) it1.next (); // System.out.println ("\n\nInstance"); LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget (); LabelsSequence target = lblseq.getLabelsSequence (); LabelsSequence returned = (LabelsSequence) it2.next (); // System.out.println (target); compareLabelings (results, returned, target); } results.computeStatistics (); return results; }
public static TestResults computeTestResults (InstanceList testList, List returnedList) { TestResults results = new TestResults (testList); Iterator it1 = testList.iterator (); Iterator it2 = returnedList.iterator (); while (it1.hasNext ()) { Instance inst = (Instance) it1.next (); // System.out.println ("\n\nInstance"); LabelsAssignment lblseq = (LabelsAssignment) inst.getTarget (); LabelsSequence target = lblseq.getLabelsSequence (); LabelsSequence returned = (LabelsSequence) it2.next (); // System.out.println (target); compareLabelings (results, returned, target); } results.computeStatistics (); return results; }
private static SparseVector mean(InstanceList instances, SparseVector meanVector) { if (instances == null || instances.size() == 0) return null; Instance instance; SparseVector v; Iterator<Instance> instanceItr = instances.iterator(); double factor = 1.0 / (double) instances.size(); while (instanceItr.hasNext()) { instance = (Instance) instanceItr.next(); v = (SparseVector) (instance.getData()); meanVector.plusEqualsSparse(v, factor); } return meanVector; }
public InstanceList pipeInstances (Iterator<Instance> source) { // I think that pipes should be associated neither with InstanceLists, nor // with Instances. -cas InstanceList toked = new InstanceList (tokenizationPipe); toked.addThruPipe (source); InstanceList piped = new InstanceList (getFeaturePipe ()); piped.addThruPipe (toked.iterator()); return piped; }
public InstanceList pipeInstances (Iterator<Instance> source) { // I think that pipes should be associated neither with InstanceLists, nor // with Instances. -cas InstanceList toked = new InstanceList (tokenizationPipe); toked.addThruPipe (source); InstanceList piped = new InstanceList (getFeaturePipe ()); piped.addThruPipe (toked.iterator()); return piped; }
public InstanceList pipeInstances (Iterator<Instance> source) { // I think that pipes should be associated neither with InstanceLists, nor // with Instances. -cas InstanceList toked = new InstanceList (tokenizationPipe); toked.addThruPipe (source); InstanceList piped = new InstanceList (getFeaturePipe ()); piped.addThruPipe (toked.iterator()); return piped; }