public Label getBestLabel () { return ((LabelAlphabet)dictionary).lookupLabel (getBestIndex()); }
public Label getBestLabel () { return ((LabelAlphabet)dictionary).lookupLabel (getBestIndex()); }
public Label getBestLabel () { return ((LabelAlphabet)dictionary).lookupLabel (getBestIndex()); }
/** * Constructs matrix and calculates values * @param t the trial to build matrix from */ public ConfusionMatrix(Trial t) { this.trial = t; this.classifications = t; Labeling tempLabeling = ((Classification)classifications.get(0)).getLabeling(); this.numClasses = tempLabeling.getLabelAlphabet().size(); values = new int[numClasses][numClasses]; for(int i=0; i < classifications.size(); i++) { LabelVector lv = ((Classification)classifications.get(i)).getLabelVector(); Instance inst = ((Classification)classifications.get(i)).getInstance(); int bestIndex = lv.getBestIndex(); int correctIndex = inst.getLabeling().getBestIndex(); assert(correctIndex != -1); //System.out.println("Best index="+bestIndex+". Correct="+correctIndex); values[correctIndex][bestIndex]++; } }
/** * Constructs matrix and calculates values * @param t the trial to build matrix from */ public ConfusionMatrix(Trial t) { this.trial = t; this.classifications = t; Labeling tempLabeling = ((Classification) classifications.get(0)).getLabeling(); this.numClasses = tempLabeling.getLabelAlphabet().size(); values = new int[numClasses][numClasses]; for (int i=0; i < classifications.size(); i++) { LabelVector lv = ((Classification)classifications.get(i)).getLabelVector(); Instance inst = ((Classification)classifications.get(i)).getInstance(); int bestIndex = lv.getBestIndex(); int correctIndex = inst.getLabeling().getBestIndex(); assert(correctIndex != -1); //System.out.println("Best index="+bestIndex+". Correct="+correctIndex); values[correctIndex][bestIndex]++; } }
/** * Constructs matrix and calculates values * @param t the trial to build matrix from */ public ConfusionMatrix(Trial t) { this.trial = t; this.classifications = t; Labeling tempLabeling = ((Classification) classifications.get(0)).getLabeling(); this.numClasses = tempLabeling.getLabelAlphabet().size(); values = new int[numClasses][numClasses]; for (int i=0; i < classifications.size(); i++) { LabelVector lv = ((Classification)classifications.get(i)).getLabelVector(); Instance inst = ((Classification)classifications.get(i)).getInstance(); int bestIndex = lv.getBestIndex(); int correctIndex = inst.getLabeling().getBestIndex(); assert(correctIndex != -1); //System.out.println("Best index="+bestIndex+". Correct="+correctIndex); values[correctIndex][bestIndex]++; } }
public void print(String prefix) int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); System.out.println("root:" + getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + getSize()); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); System.out.println(m_leftChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_leftChild.getSize()); int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize()); System.out.println(m_rightChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_rightChild.getSize());
public void print(String prefix) int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); System.out.println("root:" + getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + getSize()); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); System.out.println(m_leftChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_leftChild.getSize()); int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize()); System.out.println(m_rightChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_rightChild.getSize());
public void print(String prefix) int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); System.out.println("root:" + getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + getSize()); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); System.out.println(m_leftChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_leftChild.getSize()); int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize()); System.out.println(m_rightChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_rightChild.getSize());
int labelIndex = latticeLabeling.getBestIndex();
int labelIndex = latticeLabeling.getBestIndex();
int labelIndex = latticeLabeling.getBestIndex();
Classification cpc = confidencePredictingClassifier.classify (c); LabelVector lv = c.getLabelVector(); int bestIndex = lv.getBestIndex(); double [] values = new double[lv.numLocations()];
Classification cpc = confidencePredictingClassifier.classify (c); LabelVector lv = c.getLabelVector(); int bestIndex = lv.getBestIndex(); double [] values = new double[lv.numLocations()];
Classification cpc = confidencePredictingClassifier.classify (c); LabelVector lv = c.getLabelVector(); int bestIndex = lv.getBestIndex(); double [] values = new double[lv.numLocations()];
LabelVector l = (LabelVector) cf.getLabeling(); System.out.println ("l.getBestIndex="+l.getBestIndex()); assertTrue (cf.getLabeling().getBestLabel() == ldict.lookupLabel("politics"));
LabelVector l = (LabelVector) cf.getLabeling(); System.out.println ("l.getBestIndex="+l.getBestIndex()); assertTrue (cf.getLabeling().getBestLabel() == ldict.lookupLabel("politics"));