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 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 MaxEntSequenceConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public MaxEntConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
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 MaxEntConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public MaxEntSequenceConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public MaxEntSequenceConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public MaxEntConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public void testRandomTrained () { ClassifierTrainer[] trainers = new ClassifierTrainer[1]; //trainers[0] = new NaiveBayesTrainer(); trainers[0] = new MaxEntTrainer(); //trainers[2] = new DecisionTreeTrainer(); Alphabet fd = dictOfSize (3); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 200); InstanceList lists[] = ilist.split (new java.util.Random(2), new double[] {.5, .5}); //System.out.println ("Training set size = "+lists[0].size()); //System.out.println ("Testing set size = "+lists[1].size()); Classifier[] classifiers = new Classifier[trainers.length]; for (int i = 0; i < trainers.length; i++) classifiers[i] = trainers[i].train (lists[0]); System.out.println ("Accuracy on training set:"); for (int i = 0; i < trainers.length; i++) System.out.println (classifiers[i].getClass().getName() + ": " + new Trial (classifiers[i], lists[0]).getAccuracy()); System.out.println ("Accuracy on testing set:"); for (int i = 0; i < trainers.length; i++) System.out.println (classifiers[i].getClass().getName() + ": " + new Trial (classifiers[i], lists[1]).getAccuracy()); }
public void testRandomTrained () { ClassifierTrainer[] trainers = new ClassifierTrainer[1]; //trainers[0] = new NaiveBayesTrainer(); trainers[0] = new MaxEntTrainer(); //trainers[2] = new DecisionTreeTrainer(); Alphabet fd = dictOfSize (3); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 200); InstanceList lists[] = ilist.split (new java.util.Random(2), new double[] {.5, .5}); //System.out.println ("Training set size = "+lists[0].size()); //System.out.println ("Testing set size = "+lists[1].size()); Classifier[] classifiers = new Classifier[trainers.length]; for (int i = 0; i < trainers.length; i++) classifiers[i] = trainers[i].train (lists[0]); System.out.println ("Accuracy on training set:"); for (int i = 0; i < trainers.length; i++) System.out.println (classifiers[i].getClass().getName() + ": " + new Trial (classifiers[i], lists[0]).getAccuracy()); System.out.println ("Accuracy on testing set:"); for (int i = 0; i < trainers.length; i++) System.out.println (classifiers[i].getClass().getName() + ": " + new Trial (classifiers[i], lists[1]).getAccuracy()); }
public static Trial testTrainSplit(InstanceList instances) { InstanceList[] instanceLists = instances.split(new Randoms(), new double[] { 0.9, 0.1, 0.0 }); // LOG.debug("{} training instance, {} testing instances", // instanceLists[0].size(), instanceLists[1].size()); @SuppressWarnings("rawtypes") ClassifierTrainer trainer = new MaxEntTrainer(); Classifier classifier = trainer.train(instanceLists[TRAINING]); return new Trial(classifier, instanceLists[TESTING]); }
private double testRandomTrainedOn (InstanceList training) { ClassifierTrainer trainer = new MaxEntTrainer (); Alphabet fd = dictOfSize (3); String[] classNames = new String[] {"class0", "class1", "class2"}; Randoms r = new Randoms (1); Iterator<Instance> iter = new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0), 30, 0, 10, 200, classNames); training.addThruPipe (iter); InstanceList testing = new InstanceList (training.getPipe ()); testing.addThruPipe (new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0), 30, 0, 10, 200, classNames)); System.out.println ("Training set size = "+training.size()); System.out.println ("Testing set size = "+testing.size()); Classifier classifier = trainer.train (training); System.out.println ("Accuracy on training set:"); System.out.println (classifier.getClass().getName() + ": " + new Trial (classifier, training).getAccuracy()); System.out.println ("Accuracy on testing set:"); double testAcc = new Trial (classifier, testing).getAccuracy(); System.out.println (classifier.getClass().getName() + ": " + testAcc); return testAcc; }
private double testRandomTrainedOn (InstanceList training) { ClassifierTrainer trainer = new MaxEntTrainer (); Alphabet fd = dictOfSize (3); String[] classNames = new String[] {"class0", "class1", "class2"}; Randoms r = new Randoms (1); Iterator<Instance> iter = new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0), 30, 0, 10, 200, classNames); training.addThruPipe (iter); InstanceList testing = new InstanceList (training.getPipe ()); testing.addThruPipe (new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0), 30, 0, 10, 200, classNames)); System.out.println ("Training set size = "+training.size()); System.out.println ("Testing set size = "+testing.size()); Classifier classifier = trainer.train (training); System.out.println ("Accuracy on training set:"); System.out.println (classifier.getClass().getName() + ": " + new Trial (classifier, training).getAccuracy()); System.out.println ("Accuracy on testing set:"); double testAcc = new Trial (classifier, testing).getAccuracy(); System.out.println (classifier.getClass().getName() + ": " + testAcc); return testAcc; }
public void testSetGetParameters () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testGetSetParameters (maxable); }
public void testSetGetParameters () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testGetSetParameters (maxable); }
public void testRandomMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testValueAndGradient (maxable); }
public void testRandomMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testValueAndGradient (maxable); }
public void testTrainedMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); MaxEnt me = (MaxEnt)trainer.train(ilist); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist, me); TestOptimizable.testValueAndGradientCurrentParameters (maxable); }
public void testTrainedMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); MaxEnt me = (MaxEnt)trainer.train(ilist); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist, me); TestOptimizable.testValueAndGradientCurrentParameters (maxable); }