/** You should never call this directly. New Label objects are created on-demand by calling LabelAlphabet.lookupIndex(obj). */ Label (Object entry, LabelAlphabet dict, int index) { this.entry = entry; this.dictionary = dict; assert (dict.lookupIndex (entry, false) == index); this.index = index; }
public Label lookupLabel (Object entry, boolean addIfNotPresent) { int index = lookupIndex (entry, addIfNotPresent); if (index >= 0) return (Label) labels.get(index); else return null; }
protected void setUp () { ld = new LabelAlphabet (); lv = new LabelVector (ld, new int[] { ld.lookupIndex ("a"), ld.lookupIndex ("b"), ld.lookupIndex ("c"), ld.lookupIndex ("d")}, new double[] {3, 4, 2, 1}); }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
private static LabelAlphabet createBlankAlphabet (int numOutcomes) { if (numOutcomes > 0) { LabelAlphabet outcomes = new LabelAlphabet (); /* Setup default outcomes */ for (int i = 0; i < numOutcomes; i++) { outcomes.lookupIndex (new Integer (i)); } return outcomes; } else return null; }
private static LabelAlphabet labelDictOfSize (int n) { LabelAlphabet dict = new LabelAlphabet (); for (int i = 0; i < n; i++) { dict.lookupIndex ("LABEL"+i); } return dict; }
private static LabelAlphabet labelDictOfSize (int n) { LabelAlphabet dict = new LabelAlphabet (); for (int i = 0; i < n; i++) { dict.lookupIndex ("LABEL"+i); } return dict; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
/** Create a dummy label alphabet with <code>n</code> dimensions */ public static LabelAlphabet labelAlphabetOfSize (int n) { LabelAlphabet alphabet = new LabelAlphabet(); for (int i = 0; i < n; i++) { alphabet.lookupIndex("d" + i); } return alphabet; }
/** Create a dummy label alphabet with <code>n</code> dimensions */ public static LabelAlphabet labelAlphabetOfSize (int n) { LabelAlphabet alphabet = new LabelAlphabet(); for (int i = 0; i < n; i++) { alphabet.lookupIndex("d" + i); } return alphabet; }
private static LabelAlphabet newLabelAlphabet (int numTopics) { LabelAlphabet ret = new LabelAlphabet(); for (int i = 0; i < numTopics; i++) ret.lookupIndex("topic"+i); return ret; }
/** Calculate the precision of the classifier on an instance list for a particular target entry */ public double getPrecision (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getPrecision (index); }
/** Calculate the F1-measure of the classifier on an instance list for a particular target entry */ public double getF1 (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getF1 (index); }
/** Calculate the F1-measure of the classifier on an instance list for a particular target entry */ public double getF1 (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getF1 (index); }
/** Calculate the F1-measure of the classifier on an instance list for a particular target entry */ public double getF1 (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getF1 (index); }
/** Calculate the precision of the classifier on an instance list for a particular target entry */ public double getPrecision (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getPrecision (index); }