/** Return the fraction of instances that have the correct label as their best predicted label. */ public double getAccuracy () { int numCorrect = 0; for (int i = 0; i < this.size(); i++) if (this.get(i).bestLabelIsCorrect()) numCorrect++; return (double)numCorrect/this.size(); }
/** * Prune the tree using minimum description length */ public void prune() { getRoot().computeCostAndPrune(); }
public Classification[] classify (Instance[] instances) { Classification[] ret = new Classification[instances.length]; for (int i = 0; i < instances.length; i++) ret[i] = classify (instances[i]); return ret; }
/** * @return the total number of nodes in this tree */ public int getSize() { Node root = getRoot(); if (root == null) return 0; return 1+root.getNumDescendants(); }
public ConfidencePredictingClassifierTrainer (ClassifierTrainer underlyingClassifierTrainer, InstanceList validationSet, Pipe confidencePredictingPipe) { this.confidencePredictingPipe = confidencePredictingPipe; this.confidencePredictingClassifierTrainer = new MaxEntTrainer(); this.validationSet = validationSet; //this.confidencePredictingClassifierTrainer = new DecisionTreeTrainer(); //this.confidencePredictingClassifierTrainer = new NaiveBayesTrainer(); this.underlyingClassifierTrainer = underlyingClassifierTrainer; }
public TokenClassifiers(InstanceList trainList, int randSeed, int numCV) { // this(new AdaBoostM2Trainer(new DecisionTreeTrainer(2), 10), trainList, randSeed, numCV); // this(new NaiveBayesTrainer(), trainList, randSeed, numCV); this(new BalancedWinnowTrainer(), trainList, randSeed, numCV); // this(new SVMTrainer(), trainList, randSeed, numCV); }
public void stopGrowth () { if (child0 != null) { child0.stopGrowth(); child1.stopGrowth(); } ilist = null; }
public Optimizable.ByGradientValue getMaximizableTrainer (InstanceList ilist) { if (ilist == null) return new MaximizableTrainer (); return new MaximizableTrainer (ilist, null); }
private static LabelVector[] getLabelVectorsFromClassifications (Classification[] c) { LabelVector[] ret = new LabelVector[c.length]; for (int i = 0; i < c.length; i++) ret[i] = c[i].getLabelVector(); return ret; }
/** * Saves memory by allowing ilist to be garbage collected * (deletes this node's associated instance list) */ public void stopGrowth () { if (m_leftChild != null) m_leftChild.stopGrowth(); if (m_rightChild != null) m_rightChild.stopGrowth(); m_ilist = null; }
/** * Prints the tree rooted at this node */ public void print() { print(""); }
/** Return the fraction of instances that have the correct label as their best predicted label. */ public double getAccuracy () { int numCorrect = 0; for (int i = 0; i < this.size(); i++) if (this.get(i).bestLabelIsCorrect()) numCorrect++; return (double)numCorrect/this.size(); }
/** * Prune the tree using minimum description length */ public void prune() { getRoot().computeCostAndPrune(); }
/** * @return the total number of nodes in this tree */ public int getSize() { Node root = getRoot(); if (root == null) return 0; return 1+root.getNumDescendants(); }
/** Return the fraction of instances that have the correct label as their best predicted label. */ public double getAccuracy () { int numCorrect = 0; for (int i = 0; i < this.size(); i++) if (this.get(i).bestLabelIsCorrect()) numCorrect++; return (double)numCorrect/this.size(); }
/** * Prune the tree using minimum description length */ public void prune() { getRoot().computeCostAndPrune(); }
/** * @return the total number of nodes in this tree */ public int getSize() { Node root = getRoot(); if (root == null) return 0; return 1+root.getNumDescendants(); }